Decompose Homography matrix in opencv python

风流意气都作罢 提交于 2020-03-21 06:01:36

问题


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?


回答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()



来源:https://stackoverflow.com/questions/41526335/decompose-homography-matrix-in-opencv-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!