Example #1
0
void Module_Rectifier::display( const colorspaces::Image& image)
{
	colorspaces::ImageRGB8 img_rgb8(image);//conversion will happen if needed
	Glib::RefPtr<Gdk::Pixbuf> imgBuff = 
	Gdk::Pixbuf::create_from_data((const guint8*)img_rgb8.data,
		Gdk::COLORSPACE_RGB,
		false,
		8,
		img_rgb8.width,
		img_rgb8.height,
		img_rgb8.step);


	/* Image */
	gtkimage_notrectified->clear(); /**/
	gtkimage_notrectified->set(imgBuff);
	mybuffer = imgBuff->get_pixels();
	
	/* Rectified Image */
	imgRectifiedBuff = imgBuff->copy();
	gtkimage_rectified->clear(); /**/
	gtkimage_rectified->set(imgRectifiedBuff);
	mybuffer_rectified = imgRectifiedBuff->get_pixels();


	/* if the user have selected 4 points on each image the application rectify the second image */
	if ((counter_points_image == NUM_POINTS) and (counter_points_image_rectified == NUM_POINTS)){

		/* Calculate the solution matrix */
		if (flag_resolved == false){
			solve_equation_system();
			flag_resolved = true;
		}
  
		/* Build the rectified image */
		build_rectified_image(mybuffer, mybuffer_rectified);

	}

	/* Draw selected points */
	drawSelectedPoints(counter_points_image, points_image, mybuffer);
	drawSelectedPoints(counter_points_image_rectified, points_image_rectified, mybuffer_rectified);

   
}
Example #2
0
    void drawImage(const colorspaces::Image& image, Gtk::DrawingArea* drawingArea){
      /*convert to RGB*/
      colorspaces::ImageRGB8 img_rgb8(image);
      Glib::RefPtr<Gdk::Pixbuf> imgBuff = 
	Gdk::Pixbuf::create_from_data((const guint8*)img_rgb8.data,
				      Gdk::COLORSPACE_RGB,
				      false,
				      8,
				      img_rgb8.width,
				      img_rgb8.height,
				      img_rgb8.step);
      
      Glib::RefPtr<Gdk::Window> window = drawingArea->get_window();
      const Glib::RefPtr< const Gdk::GC > gc;/*empty*/
      window->draw_pixbuf(gc,
			  imgBuff,
			  0,0,/*starting point from imgBuff*/
			  0,0,/*starting point into drawable*/
			  imgBuff->get_width(),
			  imgBuff->get_height(),
			  Gdk::RGB_DITHER_NONE, 0, 0);
      drawingArea->set_size_request(img_rgb8.width,
				    img_rgb8.height);
    }
Example #3
0
void Viewer::display( const colorspaces::Image& imageColor, const colorspaces::Image& imageDepth )
{


	// Draw optical center
	for (int i = -2; i<=2; i++)
			for (int j =-2; j<=2; j++)
			{
				int pixel = (imageColor.width*(imageColor.height/2+j)+(imageColor.width/2+i))*3;
				imageColor.data[pixel] = 255;
				imageColor.data[pixel+1] = 0;
				imageColor.data[pixel+2] = 0;
			}

	// Save depth map in map vector (just save 25 maps). Each map is saved each 2 iterations
	if (handlerDepth)
	{
		std::vector<colorspaces::Image>::iterator it = mDepthVector.begin();
		mDepthVector.insert(it, imageDepth);

		if (mDepthVector.size() > MAX_MAPS)
			mDepthVector.erase(mDepthVector.begin() + MAX_MAPS, mDepthVector.end());

		else if (mDepthVector.size() == MAX_MAPS -1)
			std::cout << "* Depth vector is already filled!" << std::endl;
	}
	else
		handlerDepth = !handlerDepth;


	colorspaces::ImageRGB8 img_rgb8(imageColor);//conversion will happen if needed
	Glib::RefPtr<Gdk::Pixbuf> imgBuffColor =
			Gdk::Pixbuf::create_from_data((const guint8*)img_rgb8.data,
					Gdk::COLORSPACE_RGB,
					false,
					8,
					img_rgb8.width,
					img_rgb8.height,
					img_rgb8.step);

	gtkimage_color->clear();
	gtkimage_color->set(imgBuffColor);



	gtkimage_color2->clear();
	gtkimage_color2->set(imgBuffColor);

	if (intrinsicsEnable)
		saveImage(imageColor);


	imgOrig.create(imageColor.size(), CV_8UC3);
	imageColor.copyTo(imgOrig);

	pthread_mutex_lock(&mutex);
	mImageDepth = imageDepth.clone();
	pthread_mutex_unlock(&mutex);

	// Show depth image in color
	// 3 RGB canals
	// 0: Image in gray scale
	// [1,2]: Real data of distance
	// 1: 8bit MSB
	// 2: 8bit LSB

	std::vector<cv::Mat> layers;
	cv::Mat colorDepth(imageDepth.size(),imageDepth.type());
	cv::split(imageDepth, layers);

	cv::cvtColor(layers[0],colorDepth,CV_GRAY2RGB);

	Glib::RefPtr<Gdk::Pixbuf> imgBuffDepth =
			Gdk::Pixbuf::create_from_data((const guint8*) colorDepth.data,
					Gdk::COLORSPACE_RGB,
					false,
					8,
					imageDepth.width,
					imageDepth.height,
					imageDepth.step);

	gtkimage_depth->clear();
	gtkimage_depth->set(imgBuffDepth);

	if (hsvFilter != NULL)
	{
		createImageHSV(imageDepth);

		// Show HSV image
		Glib::RefPtr<Gdk::Pixbuf> imgBuffHSV =
				Gdk::Pixbuf::create_from_data((const guint8*)imgHSV.data,
						Gdk::COLORSPACE_RGB,
						false,
						8,
						imgHSV.size().width,
						imgHSV.size().height,
						imgHSV.step);

		gtkimage_hsv->clear();
		gtkimage_hsv->set(imgBuffHSV);

		// Show Blob Image

		Glib::RefPtr<Gdk::Pixbuf> imgBuffBLOB =
				Gdk::Pixbuf::create_from_data(
						(guint8*)mFrameBlob->imageData,
						Gdk::COLORSPACE_RGB,
						false,
						mFrameBlob->depth,
						mFrameBlob->width,
						mFrameBlob->height,
						mFrameBlob->widthStep);

		gtkimage_blob->clear();
		gtkimage_blob->set(imgBuffBLOB);

		//cvReleaseImage(&mFrameBlob);

	}

	displayFrameRate();
	mainwindow->resize(1,1);
	while (gtkmain.events_pending())
		gtkmain.iteration();
}