Skip to content

Instantly share code, notes, and snippets.

@tilarids
Created November 11, 2012 14:22
Show Gist options
  • Save tilarids/4055021 to your computer and use it in GitHub Desktop.
Save tilarids/4055021 to your computer and use it in GitHub Desktop.
/*
gcc camera-shot.c -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include/ -I/usr/include/clutter-gtk-1.0 -I /usr/include/gtk-3.0/ -I /usr/include/pango-1.0 -I /usr/include/cairo/ -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/clutter-1.0 -I /usr/include/cogl -I /usr/include/json-glib-1.0 -I /usr/include/gstreamer-0.10/ -I /usr/include/libxml2 -I /usr/include/cheese -lcheese -lgtk-3 -lclutter-gtk-1.0 -o camera-shot
*/
#define HAVE_DLFCN_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_MEMORY_H 1
#define HAVE_STDINT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRINGS_H 1
#define HAVE_STRING_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_UDEV /**/
#define HAVE_UNISTD_H 1
#include <glib.h>
#include <glib/gi18n.h>
#include <clutter-gtk/clutter-gtk.h>
#include <gst/gst.h>
#include <cheese/cheese-camera.h>
#include <cheese/cheese.h>
char * filename;
static gboolean
time_cb (CheeseCamera *camera)
{
g_print ("Cheese! filename: %s\n", filename);
cheese_camera_take_photo (camera, filename);
g_timeout_add_seconds (2, (GSourceFunc) (exit), 0);
return FALSE;
}
int
main (int argc, char **argv)
{
filename = argv[1];
CheeseCamera *camera;
ClutterActor *texture;
g_thread_init (NULL);
gdk_threads_init ();
if (gtk_clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
{
return EXIT_FAILURE;
}
if (!cheese_init (&argc, &argv))
{
return EXIT_FAILURE;
}
texture = clutter_texture_new ();
clutter_actor_set_size (texture, 640, 480);
clutter_actor_show (texture);
gdk_threads_enter ();
camera = cheese_camera_new (CLUTTER_TEXTURE (texture), NULL, 640, 480);
gdk_threads_leave ();
cheese_camera_setup (camera, NULL, NULL);
cheese_camera_play (camera);
g_timeout_add_seconds (2, (GSourceFunc) (time_cb), camera);
gtk_main ();
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment