Bonjour,

Je cherche a avoir une vidéo dans une interface gtk. J'arrive a faire la conversion, mais je n'arrive pas a avoir plusieurs images de d'affilées.
Le code est la :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 
#include <stdlib.h>
#include <gtk/gtk.h>
#include <OpenCV/highgui.h>
#include <OpenCV/cv.h>
 
GtkWidget			*window = NULL;
 
GtkImage			*image_from_ocv(IplImage * img, int dst_w, int dst_h)
{
	GtkImage		*image = NULL;
    GdkPixbuf		*pix_src, *pix_dst;
 
    pix_src = gdk_pixbuf_new_from_data((guchar*)img->imageData, GDK_COLORSPACE_RGB, FALSE, 8, img->width, img->height, img->widthStep, NULL, NULL);
    pix_dst = gdk_pixbuf_scale_simple(pix_src, dst_w, dst_h, GDK_INTERP_BILINEAR);
	image = (GtkImage*)gtk_image_new_from_pixbuf(pix_dst);
	g_object_unref(pix_src);
	g_object_unref(pix_dst);
    return image;
}
 
void				display_image(gpointer capture)
{
	IplImage		*ocv_image = NULL;
	GtkImage		*gtk_image = NULL;
 
	if (!(ocv_image = cvQueryFrame(capture)))
		exit(-1);
	cvConvertImage(ocv_image, ocv_image, CV_CVTIMG_SWAP_RB);
	gtk_image = image_from_ocv(ocv_image, window->allocation.width, window->allocation.height);
	gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(gtk_image));
	gtk_widget_show(GTK_WIDGET(gtk_image));
}
 
int					main(int argc, char **argv)
{
	CvCapture		*capture = NULL;
 
	gtk_init(&argc, &argv);
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_default_size(GTK_WINDOW(window), 500, 500);
	g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
	gtk_widget_show(window);
	if (!(capture = cvCreateCameraCapture(0)))
		return (EXIT_FAILURE);
	g_timeout_add(100, display_image, capture);
	gtk_main();
    return EXIT_SUCCESS;
}
Même si je gtk_container_remove après gtk_widget_show(GTK_WIDGET(gtk_image)).. plus rien ne s'affiche.

Je ne sais pas pourquoi ça fait ça. Pourtant la logique est bonne non ?
Merci d'avance.