After some earlier advice we've managed to create a high quality disparity map! However, we're having a lot of trouble getting the actual distance from our disparity map.
Here are two frames from our video of a tissue box:
Here is our disparity map: To get the distance, we've followed the procedure in 7_2d_map.py; using
and the Q matrix obtained in calibration. This returns a three dimensional matrix. We take a pixel from the center/box and it looks like
Code: Select all
The tissue box is 200mm away. We're guessing that the third value is (Z/W) is what we need but we aren't sure of the units. We read somewhere that the disparity map returned by opencv is scaled by 16, and we've made the assumption that the returned units are cm. This gives us 1.1743402 * 16 * 10 = about 192mm, which is our best result thus far.array([-0.25788638, 0.1133885 , 1.1743402 ], dtype=float32)
We aren't sure if this is the correct approach. We've struggled to find documentation or the correct way to do this. We'd appreciate any input on how to correctly calculate distance, or any other feedback on our approach thus far.
I'd be happy to provide our disparity map, Q matrix, our code, or anything else that's needed. Let me know! We'd very much appreciate some input on this!