# Camera displacement from homography

**URL:** https://forum.opencv.org/t/camera-displacement-from-homography/6531
**Category:** C++
**Tags:** calib3d, homography
**Created:** [December 2, 2021, 12:19pm UTC](https://forum.opencv.org/t/camera-displacement-from-homography/6531 "2021-12-02T12:19:43Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![L\_D](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/l_d/32/3920_2.png) [@L\_D](https://forum.opencv.org/u/L_D)
#### Post date: [December 2, 2021, 12:19pm UTC](https://forum.opencv.org/t/camera-displacement-from-homography/6531/1 "2021-12-02T12:19:44Z")

</div>

Suppose I have a pair of overlapping images of a scene containing (a) planar object(s). Thanks to feature detection and matching I am able to estimate the Homography H between the two images. Is it possible to retrieve the camera displacement using H ?

I used the code provided in OpenCV’s demo on homography and the results I obtain for the displacement are not consistent especially regarding the translations. I used the following formulas to go from the homography H to the rotation and translation matrices (provided in the demo at [OpenCV: Basic concepts of the homography explained with code](https://docs.opencv.org/4.x/d9/dab/tutorial_homography.html)) :

// Normalization to ensure that ||c1|| = 1

double norm = sqrt(H.at(0,0)\*H.at(0,0) + H.at(1,0)\*H.at(1,0) + H.at(2,0)\*H.at(2,0));

H /= norm;

Mat c1 = H.col(0);

Mat c2 = H.col(1);

Mat c3 = c1.cross(c2);

Mat tvec = H.col(2);

Mat R(3, 3, CV\_64F);

for (int i = 0; i \< 3; i++)

{

R.at(i,0) = c1.at(i,0);

R.at(i,1) = c2.at(i,0);

R.at(i,2) = c3.at(i,0);

}

I guess my problem has to do with scaling factor,however, I have no idea how to estimate it.

Regards.
