I\'m trying to find the rotation and translation from Homography function. First I compute the corresponding feature points and using findHomography()
I compute
I used the function 'filterHomographyDecompByVisibleRefpoints' by Vaesper. You can check the code here.
You just need to input the Rotation matrix, normals obtained from decomposeHomographyMat and the point correspondences used to obtain the homograpy matrix. The above function will return 2 possible solutions. You can see more on this idea in the answer by Ebya here.
After getting the 2 possible solutions, you will have to somehow make some checks depending on your case in order to find the right solution. Since I used identity matrix for camera matrix, the translation values obtained are in pixels and will need to be scaled using some external sensor. In my case, the distance between the camera and planar object is fixed in the z-axis, therefore, I just calculated what 1 pixel represents in world units.