23 #include <cv_bridge/CvBridge.h> 27 #include <sensor_msgs/Image.h> 30 #include <opencv/cv.h> 31 #include <opencv/highgui.h> 61 : m_NodeHandle(node_handle),
62 image_transport_(node_handle),
64 xyz_mat_8U3_(cv::Mat()),
66 grey_mat_8U3_(cv::Mat()),
67 grey_image_counter_(0)
79 if(cvGetWindowHandle(
"z data"))cvDestroyWindow(
"z data");
80 if(cvGetWindowHandle(
"grey data"))cvDestroyWindow(
"grey data");
88 cvStartWindowThread();
89 cv::namedWindow(
"z data");
90 cv::namedWindow(
"grey data");
109 grey_image_32F1_ = cv_bridge_0_.imgMsgToCv(grey_image_msg,
"passthrough");
113 cv::imshow(
"grey data", grey_mat_8U3_);
114 int c = cvWaitKey(500);
115 std::cout << c << std::endl;
116 if (c==
's' || c==536871027)
118 std::stringstream ss;
119 char counterBuffer [50];
120 sprintf(counterBuffer,
"%04d", grey_image_counter_);
121 ss <<
"greyImage8U3_";
125 std::cout <<
"[tof_camera_viewer] Image " << grey_image_counter_ <<
" saved." << std::endl;
126 grey_image_counter_++;
129 catch (sensor_msgs::CvBridgeException& e)
131 ROS_ERROR(
"[tof_camera_viewer] Could not convert from '%s' to '32FC1'.", grey_image_msg->encoding.c_str());
146 xyz_image_32F3_ = cv_bridge_1_.imgMsgToCv(xyz_image_msg,
"passthrough");
150 cv::imshow(
"z data", xyz_mat_8U3_);
152 catch (sensor_msgs::CvBridgeException& e)
154 ROS_ERROR(
"[tof_camera_viewer] Could not convert from '%s' to '32FC1'.", xyz_image_msg->encoding.c_str());
162 int main(
int argc,
char** argv)
165 ros::init(argc, argv,
"tof_camera_viewer");
175 if (!camera_viewer_node.
init())
return 0;
Subscriber subscribe(const std::string &base_topic, uint32_t queue_size, const boost::function< void(const sensor_msgs::ImageConstPtr &)> &callback, const ros::VoidPtr &tracked_object=ros::VoidPtr(), const TransportHints &transport_hints=TransportHints())
void xyzImageCallback(const sensor_msgs::ImageConstPtr &xyz_image_msg)
unsigned long ConvertToShowImage(const cv::Mat &source, cv::Mat &dest, int channel=1, double min=-1, double max=-1)
ros::NodeHandle m_NodeHandle
Node handle.
IplImage * grey_image_32F1_
OpenCV image holding the transformed 8bit RGB point cloud.
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
sensor_msgs::CvBridge cv_bridge_1_
void greyImageCallback(const sensor_msgs::ImageConstPtr &grey_image_msg)
sensor_msgs::CvBridge cv_bridge_0_
ROSCPP_DECL void spin(Spinner &spinner)
cv::Mat xyz_mat_8U3_
OpenCV image holding the 32bit point cloud.
cv::Mat grey_mat_8U3_
OpenCV image holding the 32bit amplitude values.
~CobTofCameraViewerNode()
Destructor.
image_transport::Subscriber xyz_image_subscriber_
Subscribes to xyz image data.
int main(int argc, char **argv)
image_transport::Subscriber grey_image_subscriber_
Subscribes to gray image data.
int grey_image_counter_
OpenCV image holding the transformed 8bit RGB amplitude values.
CobTofCameraViewerNode(const ros::NodeHandle &node_handle)
IplImage * xyz_image_32F3_
image_transport::ImageTransport image_transport_
Image transport instance.