[ create a new paste ] login | about

Link: http://codepad.org/1xCVax9f    [ raw code | output | fork ]

C++, pasted on Jul 23:
#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>

using namespace cv;

cv_bridge::CvImagePtr cv_ptr_kinect_rgb;


void imageCallbackdepth(const sensor_msgs::ImageConstPtr& msg)
{

	cv_bridge::CvImagePtr cv_ptr;

	try
	{
		cv_ptr = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::TYPE_16UC1);

	}

	catch (cv_bridge::Exception& e)
	{
		ROS_ERROR("cv_bridge exception: %s", e.what());
		return;
	}
	

//*******************************blending two images*************************************
	double a = 0.5; double b; 
	Mat blend;
	a = ( 1.0 - b );    
	addWeighted( cv_ptr_kinect_rgb->image, alpha, cv_ptr_kinect_depth->image, 0.5, 0.5, blend);
	cv::imshow( "Linear Blend", blend);
//***************************************************************************************
	cvWaitKey(3);
}

void imageCallbackrgb(const sensor_msgs::ImageConstPtr& msg1)
{

	//cv_bridge::CvImagePtr cv_ptr_kinect_rgb; //Global

	try
	{
		cv_ptr_kinect_rgb = cv_bridge::toCvCopy(msg1, sensor_msgs::image_encodings::MONO8);
	}

	catch (cv_bridge::Exception& e)
	{
		ROS_ERROR("cv_bridge exception: %s", e.what());
		return;
	}


	cv::imshow("OpenCV viewer Kinect RGB", cv_ptr_kinect_rgb->image);

	cvWaitKey(3);

}
int main(int argc, char **argv)

{
	ros::init(argc, argv, "listenerKinectuEye");
	ros::NodeHandle nh;

	image_transport::ImageTransport it(nh);
	
	image_transport::Subscriber subkidepth = it.subscribe("/camera/depth_registered/image_raw", 1,imageCallbackdepth);
	image_transport::Subscriber subkirgb = it.subscribe("/camera/rgb/image_color", 1, imageCallbackrgb);
	
	ROS_INFO("subscribed to Kinect ");

	ros::spin();
}


Output:
1
2
3
4
5
6
7
8
Line 20: error: ros/ros.h: No such file or directory
Line 44: error: image_transport/image_transport.h: No such file or directory
Line 22: error: opencv/cv.h: No such file or directory
Line 27: error: opencv/highgui.h: No such file or directory
Line 32: error: cv_bridge/cv_bridge.h: No such file or directory
Line 40: error: sensor_msgs/image_encodings.h: No such file or directory
Line 8: error: 'cv' is not a namespace-name
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: