/*! \fn void SkeltrackHeuristicGestures::createObjects() * \brief Creates GObjects corresponding to Kinect and Skeltrack. */ void SkeltrackHeuristicGestures::createObjects(Gobject *obj, GAsyncResult *res, gpointer user_data) { GError *error = NULL; gint width = 640; gint height = 480; kinect = gfreenect_device_new_finish(res, &error); if (kinect == NULL) { g_debug("Failed to create Kinect device: %s", error->message); g_error_free(error); return; } g_debug("Kinect device created!!"); skeleton = skeltrack_skeleton_new(); // TODO: Code for setting smoothing factor and threshold using OpenCV GUI g_signal_connect(kinect, "depth-frame", G_CALLBACK(recieveDepthFrame)); g_signal_connect(kinect, "video-frame", G_CALLBACK(recieveVideoFrame)); // TODO: add code to draw skeleton in a window in GUI gfreenect_device_set_tilt_angle(kinect, 0, NULL, NULL, NULL); gfreenect_device_start_depth_stream(kinect, GFREENECT_DEPTH_FORMAT_MM, NULL); gfreenect_device_start_video_stream(kinect, GFREENECT_RESOLUTION_MEDIUM, GFREENECT_VIDEO_FORMAT_RGB, NULL); // TODO: add code for showing the video and depth stream from Kinect in GUI window. }
static void on_new_kinect_device (GObject *obj, GAsyncResult *res, gpointer user_data) { ClutterActor *stage, *instructions; GError *error = NULL; gint width = 640; gint height = 480; kinect = gfreenect_device_new_finish (res, &error); if (kinect == NULL) { g_debug ("Failed to created kinect device: %s", error->message); g_error_free (error); clutter_main_quit (); return; } g_debug ("Kinect device created!"); stage = clutter_stage_get_default (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Kinect Test"); clutter_actor_set_size (stage, width * 2, height + 200); clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE); g_signal_connect (stage, "destroy", G_CALLBACK (on_destroy), kinect); g_signal_connect (stage, "key-release-event", G_CALLBACK (on_key_release), kinect); depth_tex = clutter_cairo_texture_new (width, height); clutter_container_add_actor (CLUTTER_CONTAINER (stage), depth_tex); video_tex = clutter_cairo_texture_new (width, height); clutter_actor_set_position (video_tex, width, 0.0); clutter_container_add_actor (CLUTTER_CONTAINER (stage), video_tex); info_text = clutter_text_new (); set_info_text (); clutter_actor_set_position (info_text, 50, height + 20); clutter_container_add_actor (CLUTTER_CONTAINER (stage), info_text); instructions = create_instructions (); clutter_actor_set_position (instructions, 50, height + 70); clutter_container_add_actor (CLUTTER_CONTAINER (stage), instructions); clutter_actor_show_all (stage); skeleton = SKELTRACK_SKELETON (skeltrack_skeleton_new ()); g_signal_connect (kinect, "depth-frame", G_CALLBACK (on_depth_frame), NULL); g_signal_connect (kinect, "video-frame", G_CALLBACK (on_video_frame), NULL); g_signal_connect (depth_tex, "draw", G_CALLBACK (on_texture_draw), NULL); gfreenect_device_set_tilt_angle (kinect, 0, NULL, NULL, NULL); gfreenect_device_start_depth_stream (kinect, GFREENECT_DEPTH_FORMAT_MM, NULL); gfreenect_device_start_video_stream (kinect, GFREENECT_RESOLUTION_MEDIUM, GFREENECT_VIDEO_FORMAT_RGB, NULL); }