This forum is disabled, please visit https://forum.opencv.org

1 | initial version |

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.

2 | No.2 Revision |

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.

Copyright OpenCV foundation, 2012-2018. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.