3

H = K[R|t] where H (3*3) is homographic matrix, R is Rotation matrix, K is matrix of camera's intrinsic parameters and t is translation vector.

I have calculated K using chess board pattern as follows

ret, K, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, chess_gray.shape[::-1],None,None)

Homograpy matrix H is calculated as

pts_src = np.float32(pts_src)
pts_dst = np.float32(pts_dst)
H, status = cv2.findHomography(pts_src, pts_dst)

How to decompose R and t from H and K using

cv2.decomposeHomograpyMat(H,K,....)

How to write other inputs and outputs of above functions?

Avi
  • 310
  • 2
  • 4
  • 16
  • Is this different from the Kabsch Algorithm (https://en.wikipedia.org/wiki/Kabsch_algorithm)? –  Jan 07 '17 at 21:01
  • Thank you for ur comment. I have seen this , It calculates R from multiple 3D points, but I want to estimate R from H. I have seen one Homograpy decomposition method for finding R. But I want opencv python implementation. – Avi Jan 08 '17 at 04:44
  • I don't know if this is what you are looking out for but [THIS POST](http://www.learnopencv.com/homography-examples-using-opencv-python-c/) might give a little insight – Jeru Luke Jan 08 '17 at 06:56
  • Actually, I want one step ahead of post u mentioned . – Avi Jan 08 '17 at 16:34

1 Answers1

1

Assuming H as homography matrix and K as camera matrix the Python code is:

num, Rs, Ts, Ns  = cv2.decomposeHomographyMat(H, K)

num possible solutions will be returned.

Rs contains a list of the rotation matrix.
Ts contains a list of the translation vector.
Ns contains a list of the normal vector of the plane.

For further informations take a look into the official documentation:
OpenCV 3.4 - decomposeHomographyMat()

Nils
  • 2,665
  • 15
  • 30