How to convert cv::Mat to Gdk::Pixbuf?
Hello, everyone
Recently, I am trying to write a GUI for my image processing application(commandline), 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. I need some advice to make it right. Thank you.
You should post a screenshot of the displayed image.
Also, you should print the value of
temp.step[0]
,width
andheight
.@Eduardo Same question asked on the stack overflow with no answer:
link text
The key issue is how to determine rowstride parameter. Prototype of: