# Disparity calculations and camera centers

**URL:** <https://forum.opencv.org/t/disparity-calculations-and-camera-centers/2881>\
**Category:** C++\
**Tags:** disparity\
**Created:** [April 20, 2021, 9:26pm UTC](https://forum.opencv.org/t/disparity-calculations-and-camera-centers/2881 "2021-04-20T21:26:38Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![lpea](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/lpea/32/1974_2.png) [@lpea](https://forum.opencv.org/u/lpea)\
**Post date:** [May 1, 2021, 1:15pm UTC](https://forum.opencv.org/t/disparity-calculations-and-camera-centers/2881/2 "2021-05-01T13:15:06Z")

</div>

Hello @alpi,

In the general case where the principal points don’t have the same image coordinates in the left and right images, the distance Z is calculated as follows: Z = B \cdot f / ((x - c\_x) - (x' - c\_x')) where c\_x and c\_x' are the position of the principal point along the x-axis in the left and right images respectively.

---

_[View the full topic](https://forum.opencv.org/t/disparity-calculations-and-camera-centers/2881)._
