Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "mrpt_bridge/stereo_image.h"
00017
00018
00019
00020 #include "ros/ros.h"
00021 #include "mrpt_bridge/image.h"
00022 #include <mrpt/utils.h>
00023 #include <opencv/highgui.h>
00024 #include <cv_bridge/cv_bridge.h>
00025
00026 #include <sensor_msgs/Image.h>
00027 #include <sensor_msgs/image_encodings.h>
00028
00029 using namespace ros;
00030 using namespace sensor_msgs;
00031 using namespace cv;
00032 using namespace mrpt::utils;
00033 using namespace cv_bridge;
00034
00035
00036 namespace mrpt_bridge
00037 {
00038 namespace stereo_image
00039 {
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 bool mrpt2ros(const CObservationStereoImages &obj,const std_msgs::Header &msg_header,
00050 sensor_msgs::Image &left, sensor_msgs::Image &right,
00051 stereo_msgs::DisparityImage &disparity)
00052 {
00053
00055 CImage temp_img = obj.imageLeft;
00056 Mat cvImg = cv::cvarrToMat(temp_img.getAs<IplImage>());
00057 cv_bridge::CvImage img_bridge;
00058 img_bridge = CvImage(left.header, sensor_msgs::image_encodings::BGR8, cvImg);
00059 img_bridge.toImageMsg(left);
00060 left.encoding = "bgr8";
00061 left.header = msg_header;
00062 left.height = (int) obj.imageLeft.getHeight();
00063 left.width = (int) obj.imageRight.getWidth();
00064
00066 CImage temp_img2 = obj.imageRight;
00067 Mat cvImg2 = cv::cvarrToMat(temp_img2.getAs<IplImage>());
00068 cv_bridge::CvImage img_bridge2;
00069 img_bridge2 = CvImage(right.header, sensor_msgs::image_encodings::BGR8, cvImg2);
00070 img_bridge2.toImageMsg(right);
00071 right.encoding = "bgr8";
00072 right.header = msg_header;
00073 right.height = (int) obj.imageLeft.getHeight();
00074 right.width = (int) obj.imageRight.getWidth();
00075
00076 if(obj.hasImageDisparity)
00077 {
00078 CImage temp_disp = obj.imageDisparity;
00079 Mat cvImg3 = cv::cvarrToMat(temp_disp.getAs<IplImage>());
00080 cv_bridge::CvImage img_bridge3;
00081 img_bridge3 = CvImage(disparity.header, sensor_msgs::image_encodings::BGR8, cvImg3);
00082 img_bridge3.toImageMsg(disparity.image);
00083 disparity.image.encoding = "bgr8";
00084 disparity.image.header = msg_header;
00085 disparity.image.height = (int) obj.imageDisparity.getHeight();
00086 disparity.image.width = (int) obj.imageDisparity.getWidth();
00087 }
00088 return true;
00089 }
00090 }
00091 }
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102