Hello all,
How can I refresh an image (in my case IplImage) that is pointed by GtkPixbuf?
What I am currently doing is the next: In the first time I receive the image from the camera I create the GtkPixbuf, otherwise, I just refresh it.
Here is my code:
Code:
GtkWidget* convertOpenCv2Gtk (IplImage* srcImage, functionFlag flag )
{
if ( flag == CREATE )
{
// Creating the destionation image.
globalDstIplImage = cvCreateImage( cvSize(srcImage->width,srcImage->height), IPL_DEPTH_8U, 3);
// Converting the format of the picture from BGR to RGB.
cvCvtColor ( srcImage, globalDstIplImage, CV_BGR2RGB );
// Creates a new GdkPixbuf out of in-memory image data.
globalGtkPixbuf = gdk_pixbuf_new_from_data ( (guchar*)globalDstIplImage->imageData,
GDK_COLORSPACE_RGB,
FALSE,
globalDstIplImage->depth,
globalDstIplImage->width,
globalDstIplImage->height,
(globalDstIplImage->widthStep),
NULL,
NULL
);
// Create new GtkImage displaying pixbuf.
globalGtkImg = gtk_image_new_from_pixbuf ( globalGtkPixbuf );
}
else
{
// Converting the format of the picture from BGR to RGB (refreshing the globalDstIplImage).
cvCvtColor ( srcImage, globalDstIplImage, CV_BGR2RGB );
// Refreshing the GDK window, which contains the image.
gtk_widget_queue_draw ( globalGtkImg );
}
return globalGtkImg;
}
I would like to eliminate the format conversion from BGR to RGB by using cvCvtColor, in order to achieve better performance.
In the first case (create) it is easy, but how can I refresh ???
Many thanks to you all,
Felix.