23 #include "skel_drawer.h" 24 #include "image_drawer.h" 25 #include "depth_drawer.h" 26 #include <plugins/openni/utils/skel_if_observer.h> 27 #include <plugins/openni/utils/hand_if_observer.h> 29 #include <core/threading/thread.h> 30 #include <core/threading/mutex.h> 31 #include <blackboard/remote.h> 32 #include <blackboard/interface_observer.h> 33 #include <utils/system/argparser.h> 34 #include <fvcams/net.h> 35 #include <fvcams/shmem.h> 44 #define GL_WIN_SIZE_X 640 45 #define GL_WIN_SIZE_Y 480 53 bool g_draw_image =
true;
54 bool g_draw_depth =
false;
55 bool g_draw_skeleton =
true;
74 for (UserMap::iterator i = g_users.begin(); i != g_users.end(); ++i) {
75 g_rbb->
close(i->second.skel_if);
76 g_rbb->
close(i->second.proj_if);
83 delete g_image_drawer;
84 delete g_depth_drawer;
85 delete g_skeleton_drawer;
92 void glut_display (
void)
94 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
97 glMatrixMode(GL_PROJECTION);
101 glOrtho(0, GL_WIN_SIZE_X, GL_WIN_SIZE_Y, 0, -1.0, 1.0);
103 if (g_draw_image && g_image_drawer) g_image_drawer->
draw();
104 if (g_draw_depth && g_depth_drawer) g_depth_drawer->
draw();
106 if (! g_users.empty() || ! g_hands.empty() ) {
108 for (UserMap::iterator i = g_users.begin(); i != g_users.end(); ++i) {
109 i->second.skel_if->read();
110 i->second.proj_if->read();
112 for (HandMap::iterator i = g_hands.begin(); i != g_hands.end(); ++i) {
113 i->second.hand_if->read();
118 if (g_draw_skeleton) g_skeleton_drawer->
draw();
127 if (g_quit) clean_exit();
137 glut_keyboard(
unsigned char key,
int x,
int y)
144 g_draw_image = ! g_draw_image;
145 if (g_draw_image) g_draw_depth =
false;
148 g_draw_depth = ! g_draw_depth;
149 if (g_draw_depth) g_draw_image =
false;
152 g_draw_skeleton = ! g_draw_skeleton;
166 void glInit (
int * pargc,
char ** argv)
168 glutInit(pargc, argv);
169 glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
170 glutInitWindowSize(GL_WIN_SIZE_X, GL_WIN_SIZE_Y);
171 glutCreateWindow (
"Fawkes Skeleton GUI");
173 glutSetCursor(GLUT_CURSOR_NONE);
175 glutKeyboardFunc(glut_keyboard);
176 glutDisplayFunc(glut_display);
177 glutIdleFunc(glut_idle);
179 glDisable(GL_DEPTH_TEST);
180 glEnable(GL_TEXTURE_2D);
182 glEnableClientState(GL_VERTEX_ARRAY);
183 glDisableClientState(GL_COLOR_ARRAY);
186 int main(
int argc,
char **argv)
193 std::string host =
"localhost";
194 unsigned short int port = 1910;
195 if ( argp.has_arg(
"r") ) {
196 argp.parse_hostport(
"r", host, port);
199 std::string fvhost = host;
200 unsigned short int fvport = 2208;
201 if ( argp.has_arg(
"n") ) {
202 argp.parse_hostport(
"n", fvhost, fvport);
205 printf(
"Connecting to %s:%u\n", host.c_str(), port);
218 g_image_drawer = NULL;
220 if (argp.has_arg(
"n") || argp.has_arg(
"s")) {
221 if (argp.has_arg(
"n")) {
222 g_image_cam =
new NetworkCamera(fvhost.c_str(), fvport,
"openni-image",
224 g_depth_cam =
new NetworkCamera(fvhost.c_str(), fvport,
"openni-depth");
225 g_label_cam =
new NetworkCamera(fvhost.c_str(), fvport,
"openni-labels");
232 g_label_cam->
start();
233 if ((g_label_cam->
pixel_width() != GL_WIN_SIZE_X) ||
240 printf(
"Cannot open label cam, user tracker not running? " 241 "Disabling labels.\n");
245 g_image_cam->
start();
247 g_depth_cam->
start();
250 g_label_cam->
start();
253 if ((g_image_cam->
pixel_width() != GL_WIN_SIZE_X) ||
258 printf(
"Image size different from window size, closing camera");
261 g_image_cam = g_depth_cam = NULL;
virtual unsigned int pixel_height()
Height of image in pixels.
void toggle_print_state()
Toggle the printing state.
Draw body skeleton using OpenGL.
Camera interface for image aquiring devices in FireVision.
void draw()
Draw skeletons.
Draw images from camera in texture.
Fawkes library namespace.
void toggle_show_labels()
Toggle label state.
void process_queue()
Process internal queue.
virtual unsigned int pixel_width()=0
Width of image in pixels.
Parse command line arguments.
virtual void open()
Open the camera.
static void init_main()
Initialize Thread wrapper instance for main thread.
void process_queue()
Process internal queue.
virtual void close(Interface *interface)
Close interface.
Skeleton interface observer.
Base class for exceptions in Fawkes.
void draw()
Draw texture to screen.
virtual void start()
Start image transfer from the camera.
virtual unsigned int pixel_width()
Width of image in pixels.
virtual void open()=0
Open the camera.
Draw images from camera in texture.
void print_trace()
Prints trace to stderr.
virtual unsigned int pixel_height()=0
Height of image in pixels.
virtual void start()=0
Start image transfer from the camera.