GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Apr 20, 2014 11:28 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: How to refresh an IplImage which is inside a GtkPixbuf?
PostPosted: Thu Nov 24, 2011 12:44 pm 
Offline
Familiar Face

Joined: Mon Oct 17, 2011 10:18 am
Posts: 26
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group