I am trying to measure object dimensions from opencv disparity maps. My progress so far is:
- I have my two cameras calibrated and I have their metrices.
- I create disparity map from two images (one from each camera) using StereoSGBM.
- I reproject disparity map to 3D space.
- Now I open any one image of those used to create disparity, I place a rectangle there, get its 2D coordinates back.
- I get the 3D coordinates of this rectangle from the reprojected image to 3D using the 2D coordinates as indices.
- For each relevant set of coordinates (e.g. top-left/top-right) I compute the distance based on the 3D coordinates as SQRT (dx^2 + dy^2 + dz^2)
Now my questions are: - Is this the correct way to measure dimension?
- This calculated dimension is for an object in 3D space, so obvious enough as the object gets deeper in the image, the dimension gets smaller, now how can I know the real object dimension? p.s. I don’t know how deep the object would be, and I don’t know any of its dimensions apriori. Also, there are no reference objects in the picture.
- I don’t seem to understand the 3D points generated from disparity as I don’t know what are the X,Y,Z coordinates of any pixel are referenced to (where is the origin), and what is the unit of measurement (is it in pixel, mm,…etc, or a factor related to focal length?)
Thanks