ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

I'm not sure why it's failing and whether this would make a difference, but have you tried using the C++ API for OpenCV?

image_transport::Publisher publisher_depth = it.advertise("kinectcamera/depth", 1);

// create image
cv::Mat kinectDepthImage = cv::Mat(480, 640, CV_16UC1);

// fill out image - for example
for (int u = 0; u < 640; ++u)
for (int v = 0; v < 480; ++v)
  kinectDepthImage.at<uint16_t>(v,u) = some value here;

sensor_msgs::ImagePtr depth_msg = sensor_msgs::CvBridge::cvToImgMsg(kinectDepthImage);