Ask Your Question
1

How to read depth_registered image in callback ?

asked 2013-08-07 02:28:02 -0500

CHz gravatar image

updated 2016-10-24 08:59:03 -0500

ngrennan gravatar image

Hello,

I am trying to read depth_registered/image_rect image in my callback function as following

cv_bridge::CvImagePtr cv_ptr;
try
{
    cv_ptr     = cv_bridge::toCvCopy(msg, enc::TYPE_32FC1);
    depthImage = cv_ptr->image.clone();
}

I know the image consists of float values in meter. But what I get is really white-black image.

I need to get the depth of a pixel to find 3D position. Can you help me how to read depth or how to find 3d location from pixel directly ?

Thanks.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-08-07 04:14:04 -0500

updated 2013-08-07 04:20:56 -0500

If you use imshow() then values <= 0 are black and >= 1 white. Because of this a typical depth image should be black (distance unknown->0) and white (Distance > ca.1m).

To get the 3D position use: point.y=(y - centerY) / depthFocalLength; point.x=(x - centerX) / depthFocalLength; point.z=depthvalue_at(y,x);

where (x,y) are the coordinates from the depth image and the rest should be calibrated. I think the default parameter for the kinect camera are: centerX = 319.5, centerY = 239.5, depthFocalLength = 525.

edit flag offensive delete link more

Comments

Thank you very much ! I have read the image as; cv_ptr = cv_bridge::toCvCopy(msg,enc::TYPE_32FC1); depthImage = cv_ptr->image.clone(); And read the values as float; depthImage.at<float>(p2D.y, p2D.x) ;

CHz gravatar imageCHz ( 2013-08-07 21:29:42 -0500 )edit

Is that working? Usually those depth-images are 16bit unsigned integers (cv_16uc1?), not floating point. The value is the distance in mm.

stfn gravatar imagestfn ( 2014-01-01 00:27:30 -0500 )edit

Yes, it is working well.

CHz gravatar imageCHz ( 2014-01-01 00:31:37 -0500 )edit

@stfn: Just /camera/depth/image_raw is uint16

MichaelKorn gravatar imageMichaelKorn ( 2014-03-25 22:44:48 -0500 )edit

can you send me your callback function please ?

ROSkinect gravatar imageROSkinect ( 2014-07-17 04:01:27 -0500 )edit

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: 2013-08-07 02:28:02 -0500

Seen: 856 times

Last updated: Aug 07 '13