How to convert OpenCV cv::Mat to gtkmm Gdk::Pixbuf?



Hi,

 

I am new to gtkmm, and I am trying to write a GUI for my image processing application(command-line), using gtkmm. After processing a image using opencv, I want to display the result in a Gtkmm' s Image widget. The following is the code I used to setup Gtk::Image:

 

cv::Mat temp;
const int width = img_window.get_allocation().get_width();
const int height = img_window.get_allocation().get_height();
cv::resize(fusion_img, temp, cv::Size(width, height));
cv::cvtColor(temp, temp, cv::COLOR_BGR2RGB);
 
img.set(Gdk::Pixbuf::create_from_data(temp.data, Gdk::COLORSPACE_RGB, false, 8, width, height, temp.step[0]));

but it display a damaged image. It seems like cv::Mat is not compatible with Gdk::Pixbuf. I need some advice to make it right. Thanks.

 

Version : opencv4; gtkmm3.0

 

 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]