0
$\begingroup$

Rosanswers logo

Hi! I'm having some troubles using the amcl_demo.launch, because i need to get the depth information from the camera/depth/image which the openni.launch initializes (and is initialized by amcl_demo.launch). But using the amcl_demo.launch the only topic i can acess to get this depth data is camera/depth/image_raw, but nothing happens in it apparently (i checked using image_view).

I've checked at this question and followed the instructions by changing that parameters in amcl_demo.launch but i still can't make this work.

Using the openni.launch, it's possible to get the depth information perfectly from the topic /camera/depth/image. To get the depth data as well as i did from /camera/depth/image (from another topic like /camera/depth_registered/image_raw), do i need to convert the image before using ?

My code calculates the distance from an object, and with the /camera/depth/image launched by openni.launch it's possible to calculate as follow (not exactly this, i just copied the important parts):

cv_bridge::CvImagePtr Dest;
Dest = cv_bridge::toCvCopy(img);
ROI = Dest->image(cv::Rect(rect));
cv::Scalar average = cv::mean(ROI.at<float>());

I'd like to know how can i calculate the distance from the topic /camera/depth/image_raw, or another one that provides the depth information. (changing as less as possible this code)

EDIT: With depth_registration activated in amcl_demo.launch, the topics /camera/depth_registered/image_raw and /camera/depth_registered/image doesn't publish data, the only one publishing is /camera/depth/image_raw but its type does not follow the one i'm using, i've tried to convert using this: Dest = cv_bridge::toCvCopy(img,sensor_msgs::image_encodings::TYPE_16UC1); but i got 0 meters distance. What am i doing wrong?

Thanks in advance!


Originally posted by Phelipe on ROS Answers with karma: 74 on 2015-04-22

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I guess i found the solution:

Using the /camera/depth_registered/image_raw and setting depth_registration true in amcl_demo.launch, my CallBack function is converting the image to a 32-bit float type as follow: Dest = cv_bridge::toCvCopy(img,sensor_msgs::image_encodings::TYPE_32FC1); .

The difference between this topic and that /camera/depth/image is that this one gives me the distance in mm, and the other one provides the distance in m.


Originally posted by Phelipe with karma: 74 on 2015-04-22

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.