Im currently working on linux. Im given a task to code in C using libuvc to stream a video from a USB camera to the window using GTK. I'm getting the out from the uvc_frame_t but I have a problem in streaming it in gtk window. Can someone help?
Use gdk_pixbuf_new_from_data to convert the data from uvc_any2rgb
into a GdkPixbuf
. A basic GTK UI would be a GtkWindow
with a GtkImage
in it.
To update the image, call gtk_image_set_from_pixbuf
with a fresh new pixbuf you created. Don't forget to either reuse the pixbuf or destroy it after use, otherwise you'll face some massive memory leak. Oh, and you'll have to handle the framerate by yourself, and use a GLib event source to be notified when a new image is available from libuvc
.