How to convert OpenCV cv::Mat to gtkmm Gdk::Pixbuf?
Wei Wei-Ddeng via gtkmm-list <[email protected]> Sat, 18 Apr 2020 05:31:00 +0000
| Newsgroups | gmane.comp.gnome.gtkmm |
|---|---|
| Message-ID | <MN2PR04MB6879423E5632E06204190ACBD3D60@MN2PR04MB6879.namprd04.prod.outlook.com> |
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 _______________________________________________ gtkmm-list mailing list [email protected] https://mail.gnome.org/mailman/listinfo/gtkmm-list