23 #include "depth_drawer.h"
24 #include "image_drawer.h"
25 #include "skel_drawer.h"
28 #include <blackboard/interface_observer.h>
29 #include <blackboard/remote.h>
30 #include <core/threading/mutex.h>
31 #include <core/threading/thread.h>
32 #include <fvcams/net.h>
33 #include <fvcams/shmem.h>
34 #include <plugins/openni/utils/hand_if_observer.h>
35 #include <plugins/openni/utils/skel_if_observer.h>
36 #include <utils/system/argparser.h>
44 #define GL_WIN_SIZE_X 640
45 #define GL_WIN_SIZE_Y 480
48 using namespace fawkes::openni;
49 using namespace firevision;
53 bool g_draw_image =
true;
54 bool g_draw_depth =
false;
55 bool g_draw_skeleton =
true;
75 for (UserMap::iterator i = g_users.begin(); i != g_users.end(); ++i) {
76 g_rbb->
close(i->second.skel_if);
77 g_rbb->
close(i->second.proj_if);
84 delete g_image_drawer;
85 delete g_depth_drawer;
86 delete g_skeleton_drawer;
95 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
98 glMatrixMode(GL_PROJECTION);
102 glOrtho(0, GL_WIN_SIZE_X, GL_WIN_SIZE_Y, 0, -1.0, 1.0);
104 if (g_draw_image && g_image_drawer)
105 g_image_drawer->
draw();
106 if (g_draw_depth && g_depth_drawer)
107 g_depth_drawer->
draw();
109 if (!g_users.empty() || !g_hands.empty()) {
111 for (UserMap::iterator i = g_users.begin(); i != g_users.end(); ++i) {
112 i->second.skel_if->read();
113 i->second.proj_if->read();
115 for (HandMap::iterator i = g_hands.begin(); i != g_hands.end(); ++i) {
116 i->second.hand_if->read();
122 g_skeleton_drawer->
draw();
142 glut_keyboard(
unsigned char key,
int x,
int y)
146 case 'q': clean_exit();
148 g_draw_image = !g_draw_image;
150 g_draw_depth =
false;
153 g_draw_depth = !g_draw_depth;
155 g_draw_image =
false;
157 case 's': g_draw_skeleton = !g_draw_skeleton;
break;
163 case 'p': g_pause = !g_pause;
break;
168 glInit(
int *pargc,
char **argv)
170 glutInit(pargc, argv);
171 glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
172 glutInitWindowSize(GL_WIN_SIZE_X, GL_WIN_SIZE_Y);
173 glutCreateWindow(
"Fawkes Skeleton GUI");
175 glutSetCursor(GLUT_CURSOR_NONE);
177 glutKeyboardFunc(glut_keyboard);
178 glutDisplayFunc(glut_display);
179 glutIdleFunc(glut_idle);
181 glDisable(GL_DEPTH_TEST);
182 glEnable(GL_TEXTURE_2D);
184 glEnableClientState(GL_VERTEX_ARRAY);
185 glDisableClientState(GL_COLOR_ARRAY);
189 main(
int argc,
char **argv)
196 std::string host =
"localhost";
197 unsigned short int port = 1910;
198 if (argp.has_arg(
"r")) {
199 argp.parse_hostport(
"r", host, port);
202 std::string fvhost = host;
203 unsigned short int fvport = 2208;
204 if (argp.has_arg(
"n")) {
205 argp.parse_hostport(
"n", fvhost, fvport);
208 printf(
"Connecting to %s:%u\n", host.c_str(), port);
221 g_image_drawer = NULL;
223 if (argp.has_arg(
"n") || argp.has_arg(
"s")) {
224 if (argp.has_arg(
"n")) {
225 g_image_cam =
new NetworkCamera(fvhost.c_str(), fvport,
"openni-image", argp.has_arg(
"j"));
226 g_depth_cam =
new NetworkCamera(fvhost.c_str(), fvport,
"openni-depth");
227 g_label_cam =
new NetworkCamera(fvhost.c_str(), fvport,
"openni-labels");
234 g_label_cam->
start();
242 printf(
"Cannot open label cam, user tracker not running? "
243 "Disabling labels.\n");
247 g_image_cam->
start();
249 g_depth_cam->
start();
252 g_label_cam->
start();
259 printf(
"Image size different from window size, closing camera");
262 g_image_cam = g_depth_cam = NULL;
Draw images from camera in texture.
void toggle_show_labels()
Toggle label state.
Draw images from camera in texture.
Draw body skeleton using OpenGL.
void draw()
Draw skeletons.
void toggle_print_state()
Toggle the printing state.
void draw()
Draw texture to screen.
Parse command line arguments.
Base class for exceptions in Fawkes.
void print_trace()
Prints trace to stderr.
virtual void close(Interface *interface)
Close interface.
static void init_main()
Initialize Thread wrapper instance for main thread.
void process_queue()
Process internal queue.
Skeleton interface observer.
void process_queue()
Process internal queue.
Camera interface for image aquiring devices in FireVision.
virtual unsigned int pixel_height()=0
Height of image in pixels.
virtual unsigned int pixel_width()=0
Width of image in pixels.
virtual void open()=0
Open the camera.
virtual void start()=0
Start image transfer from the camera.
Fawkes library namespace.