Ask Your Question
0

Regarding Publishing Kinect Depth Image

asked 2012-12-06 23:42:21 -0600

Subhasis gravatar image

updated 2014-04-20 14:09:26 -0600

ngrennan gravatar image

Hi All,

I have kinect Depth image as mentioned below. I am trying to publish this from my node. I am having problem in converting my image to buffer which is needed to send it as a message. Please find below my code. I would be glad if somecan guide where I am doing a mistake.

///////////////////////////---code--////////////////////////////////////////////////

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

kinectDepthImage = cvCreateImage( cvSize(640,480),IPL_DEPTH_16U,1);
/*
here I store the image from Kinect
*/
cvShowImage("Depth", kinectDepthImage); // This shows me fine the image. I have no issue.

//Now I try to publish it i any of the two ways And this is where It fails.

 cv::WImageBuffer_16u depthBufer(kinectDepthImage); 
or 
 cv::WImageBuffer1_16u depthBufer(kinectDepthImage);


sensor_msgs::ImagePtr depth_msg = sensor_msgs::CvBridge::cvToImgMsg(depthBufer.Ipl(), "mono16");

publisher_depth.publish(depth_msg);


my error is " /opt/ros/fuerte/include/opencv2/core/wimage.hpp:243: cv::WImage<T>::WImage(IplImage*) [with T = short unsigned int, IplImage = _IplImage]: Assertion `!img || img->depth == Depth()' failed.
pass1Aborted (core dumped) "

Please help me with this.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
0

answered 2012-12-07 12:56:54 -0600

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);
edit flag offensive delete link more
0

answered 2012-12-12 09:34:19 -0600

Subhasis gravatar image

Hi Martin,

Thanks for replying. But, I already verified the depth. it says 16. which refers to the correct depth and should point to mono16. Can you provide any other solution to this problem ?

edit flag offensive delete link more
0

answered 2012-12-07 18:35:20 -0600

Well, according to the error message it is either:

depthBufer.Ipl() is returning null

or

depthBufer.Ipl()->depth != "mono16"

Could you check those values? Although at first glance I see nothing wrong with your code.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2012-12-06 23:42:21 -0600

Seen: 905 times

Last updated: Dec 12 '12