Ask Your Question

Revision history [back]

Hi AgentCain,

I don't know if there is a function that implements this for you, but going back from 3D PointCloud to disparity is relatively easy knowing the reprojection matrix Q (one of the arguments to the function reprojectImageTo3D).

The matrix Q has the following structure:

Q =| 1 0 0 -Cx |
   | 0 1 0 -Cy |
   | 0 0 0  f  |
   | 0 0 a  b  |

So assuming that your 3D point has the coordinates (X', Y', Z') the disparity (d) and its position on the disparity image (Ix and Iy) can be calculated as follow:

d = (f - Z' * b ) / ( Z' * a)

Ix = X' * ( d * a + b ) + Cx

Iy = Y' * ( d * a + b ) + Cy

I attach a picture of the math, just in case you want to know the details. I hope this helps.

Hi AgentCain,

I don't know if there is a function that implements this for you, but going back from 3D PointCloud to disparity is relatively easy knowing the reprojection matrix Q (one of the arguments to the function reprojectImageTo3D).

The matrix Q has the following structure:

Q =| 1 0 0 -Cx |
   | 0 1 0 -Cy |
   | 0 0 0  f  |
   | 0 0 a  b  |

So assuming that your 3D point has the coordinates (X', Y', Z') Z'), the disparity (d) and its position on the disparity image (Ix and Iy) can be calculated as follow:

d = (f - Z' * b ) / ( Z' * a)

Ix = X' * ( d * a + b ) + Cx

Iy = Y' * ( d * a + b ) + Cy

I attach a picture of the math, just in case you want to know the details. I hope this helps.