void GUI::set_img(const cv::Mat &frame, cv::Mat &result, Controller &controller) { /** result == controller.current_image_to_display. */ // Convert controller.current_image_to_process (as src) to RGB(A) controller.current_image_to_display (as dst). convert_image_to_gui_output_format(frame, result) ; if (widget_current_image_to_display != NULL) { delete widget_current_image_to_display ; } widget_current_image_to_display = Gtk::manage(new Gtk::Image()); widget_current_image_to_display->clear() ; if (result.depth() != CV_8U) { // This desnt' should be ! result.assignTo(result, CV_8U) ; } // We resize the original image every time we display it. // It's better like this because the image is resized (if needed) only one time per changement // Not always resizing the same image. //controller.resize_image_to_display(result) ; if (controller.get_image_size_gt_layout()) { cv::resize(result, result, cv::Size(controller.display_image_size.first, controller.display_image_size.second), 1.0, 1.0, cv::INTER_LINEAR) ; } IplImage iplimg = _IplImage(result) ; widget_current_image_to_display->set(Gdk::Pixbuf::create_from_data( (const guint8 *) iplimg.imageData, Gdk::COLORSPACE_RGB, (result.channels() == 4), iplimg.depth, iplimg.width, iplimg.height, iplimg.widthStep)) ; widget_current_image_to_display->show() ; display_area.put(*widget_current_image_to_display, controller.current_image_position.first, controller.current_image_position.second) ; }