static gboolean on_key_release (ClutterActor *actor, ClutterEvent *event, gpointer data) { GFreenectDevice *kinect; gdouble angle; guint key; g_return_val_if_fail (event != NULL, FALSE); kinect = GFREENECT_DEVICE (data); key = clutter_event_get_key_symbol (event); switch (key) { case CLUTTER_KEY_space: SHOW_SKELETON = !SHOW_SKELETON; break; case CLUTTER_KEY_plus: set_threshold (100); break; case CLUTTER_KEY_minus: set_threshold (-100); break; case CLUTTER_KEY_Up: set_tilt_angle (kinect, 5); break; case CLUTTER_KEY_Down: set_tilt_angle (kinect, -5); break; } set_info_text (); return TRUE; }
static gboolean decrease_time_to_take_shot (gpointer data) { gboolean call_again = TRUE; set_info_text (seconds_to_shoot); if (seconds_to_shoot < 0) { seconds_to_shoot = DEFAULT_SECONDS_TO_SHOOT; call_again = FALSE; } else if (seconds_to_shoot == 0) { record_shot = TRUE; } seconds_to_shoot--; return call_again; }
int main (int argc, char *argv[]) { guchar *buffer; gchar *file_name; guint width, height; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return -1; signal (SIGINT, quit); if (argc < 2) { g_print ("Usage: %s DEPTH_FILE [COLOR_STRING POINT_X POINT_Y]\n", argv[0]); return 0; } width = 640; height = 480; file_name = argv[1]; create_stage (width, height); set_info_text (file_name); buffer = load_image (file_name, width, height); if (buffer == NULL) return -1; if (argc > 2) { if ((argc - 2) % 3 == 0) { guint i; for (i = 2; i < argc; i+=3) { gchar *color; guint x, y; color = argv[i]; x = g_ascii_strtod (argv[i + 1], NULL); y = g_ascii_strtod (argv[i + 2], NULL); if (errno == 0) { draw_point (buffer, width, height, color, x, y); } } } else { g_print ("Wrong number of arguments...\n"); } } if (!paint_texture (buffer, width, height)) { return -1; } clutter_main (); return 0; }
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); }