1 #include <opencv2/highgui/highgui.hpp>
3 #include <ros/console.h>
4 #include <ros/duration.h>
6 #include <ros/master.h>
8 #include <ros/node_handle.h>
15 int main(
int argc,
char **argv)
17 ros::init(argc, argv,
"rgbd_viewer");
18 ros::NodeHandle nh_private(
"~");
21 nh_private.getParam(
"rate", rate);
24 client.
initialize(ros::names::resolve(
"rgbd"));
28 ros::WallTime last_master_check = ros::WallTime::now();
33 if (ros::WallTime::now() >= last_master_check + ros::WallDuration(1))
35 last_master_check = ros::WallTime::now();
36 if (!ros::master::check())
38 ROS_FATAL(
"Lost connection to master");
56 cv::cvtColor(image.
getRGBImage(), image_hsv, cv::COLOR_BGR2HSV);
60 cv::Mat canvas_hsv(view.
getHeight(), view.
getWidth(), CV_8UC3, cv::Scalar(0, 0, 0));
64 for(
int x = 0; x < view.
getWidth(); ++x)
69 cv::Vec3b hsv = image_hsv.at<cv::Vec3b>(y, x);
70 hsv[2] = 255 -
static_cast<unsigned char>(d / 8 * 255);
71 canvas_hsv.at<cv::Vec3b>(y, x) = hsv;
77 cv::cvtColor(canvas_hsv, canvas_bgr, cv::COLOR_HSV2BGR);
78 cv::imshow(
"image + depth", canvas_bgr);