How to get accurate depth value from openni_camera?
Hi all, i'm using openni_camera to get depth value between a book and the ASUS Xtion pro camera. Let's say the depth value in the image center(240,320).
I followed the solution here, and i get the output depth as integer,such as 1 meter or 2 meters, but how to get the result more accurate? I mean how to get it as float or double.
I try to change the code into: double depth = cv_ptr->image.at<double>(240, 320), i get the output 0 or 65537 or 131074. What's the meaning here?
According to the openni_camera doc, published depth images contain uint16 depth in millimetres. Also, this question is a possible duplicate of this.
Yes, i also see and follow that solution, as i said, i can get the depth value as integer but not float. It is 0, 1, 2 or 3 meter and so on. My question is, how to get the accurate value in float?
This is my code:
void imageCallback(const sensor_msgs::ImageConstPtr& msg) {
}
Do you mean that, when you read the depth value as integer, you only get values such as 0, 1000, 2000, 3000, and nothing in between those values? In your code,
depth
will be in millimetres and hence converting to float (in metres) is just a matter offloat depth_f = float(depth) / 1000.0;
.No, i mean i only get 0, 1, 2, 3, 4.......and nothing like 0.1, 0.2 and so on, i think it's in meters. But i want to get accurate values such as 0.1, 0.2, 0.3......1.0,1.1, 1.2...
You will not get floating point values from the depth image, it stores the values as integers, in millimetres. Suppose you know the depth of a given pixel should be 0.5 metres, then you should get a depth = 500 (you must convert to floating point metres yourself).