mirror of
https://github.com/introlab/rtabmap_ros.git
synced 2026-10-06 01:37:46 +08:00
switch rtabmap_lib svn co from the 0.3 branch to trunk
git-svn-id: http://rtabmap.googlecode.com/svn/trunk/ros-pkg@110 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* CameraNodeReceiver.cpp
|
||||
*
|
||||
* Created on: 2 févr. 2010
|
||||
* Author: labm2414
|
||||
*/
|
||||
|
||||
#include <ros/ros.h>
|
||||
//#include <sensor_msgs/CompressedImage.h>
|
||||
#include <cv_bridge/CvBridge.h>
|
||||
#include <highgui.h>
|
||||
|
||||
void imgReceivedCallback(const sensor_msgs::ImageConstPtr & msg)
|
||||
{
|
||||
// Decompress
|
||||
//const CvMat compressed = cvMat(1, image->data.size(), CV_8UC1, const_cast<unsigned char*>(&image->data[0]));
|
||||
//IplImage * decompressed = cvDecodeImage(&compressed, CV_LOAD_IMAGE_ANYCOLOR);
|
||||
|
||||
//ROS_INFO("Received an image size=(%d,%d)", decompressed->width, decompressed->height);
|
||||
//cvShowImage( "ImageReceived", decompressed );
|
||||
//cvReleaseImage(&decompressed);
|
||||
|
||||
IplImage * image = 0;
|
||||
sensor_msgs::CvBridge bridge;
|
||||
if(msg->data.size())
|
||||
{
|
||||
image = bridge.imgMsgToCv(msg);
|
||||
}
|
||||
|
||||
if(image)
|
||||
{
|
||||
ROS_INFO("Received an image size=(%d,%d)", image->width, image->height);
|
||||
cvShowImage( "ImageReceived", image);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
cvStartWindowThread();
|
||||
cvNamedWindow("ImageReceived", CV_WINDOW_AUTOSIZE);
|
||||
cvMoveWindow("ImageReceived", 100, 100); // offset from the UL corner of the screen
|
||||
|
||||
ros::init(argc, argv, "camera_node_receiver");
|
||||
ros::NodeHandle n;
|
||||
ros::Subscriber image_sub = n.subscribe("image", 1, imgReceivedCallback);
|
||||
|
||||
ROS_INFO("Waiting for images...");
|
||||
|
||||
ros::spin();
|
||||
|
||||
cvDestroyWindow("ImageReceived");
|
||||
}
|
||||
Reference in New Issue
Block a user