Read disparity value
Hello,
I'm doing face detection with a stereo vision system. So far I'm able to obtain a not that bad disparity map. Therefore, I want to read the disparity value of the coordinate (u,v) when the face is detected.
The issue is that I get the right width and height of the disparity image (same as the original and rectified images): Disparity width: 1280 - Disparity height: 1024. With those values I would think that the buffer which contains the disparity image is 1280x1024 = 1310720, right?. When I read the length of that buffer I get Disparity length: 5242880 so I cannot read the correct value. Disparity image is an 8bit buffer with widthXheight values, right?
Thanks for the help.
EDIT1: I've just realized that the length is actually 1280*1024 * 4 as it is encoded in 32FC1....but still, how do I read the disparity value for a set of (u, v) coordinate? Another thing is the step, which is 5120. What is it for?
EDIT2: In the documentation of stereo_msgs/DisparityImage is the answer. Z = fT/d where f is the Focal length, pixels. T is Baseline, world units and d = x_l - x_r - (cx_l - cx_r). So, once I have (u, v) they would be x_l and x_r? and cx_l and cx_r are the values from the Projection matrix P, right? If this is correct, I would never be reading the actual value of the disparity image...I would be basing Z on the calibration values from P and the 2d coordinates from the rectified images which is where I do the face detection......
Were you able to figure out the disparity value of the individual pixel?
I am sorry. It has been over 4 years so I do not remember what happened with that.