在opencv python中分解同构矩阵 [英] Decompose Homography matrix in opencv python
问题描述
H = K [R | t] 其中H(3 * 3)是单应矩阵,R是旋转矩阵,K是摄像机固有参数矩阵,t是平移矢量.
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.
我已经使用国际象棋棋盘图案计算了K,如下所示:
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矩阵H的计算方式为
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)
如何使用分解H和K中的R和t
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?
推荐答案
假设H为单应矩阵,K为摄像机矩阵,则Python代码为:
Assuming H as homography matrix and K as camera matrix the Python code is:
num, Rs, Ts, Ns = cv2.decomposeHomographyMat(H, K)
num 个可能的解决方案将被返回.
num possible solutions will be returned.
Rs包含旋转矩阵的列表.
Ts包含翻译向量的列表.
Ns包含平面法线向量的列表.
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.
有关更多信息,请查看官方文档:
OpenCV 3.4-decomposeHomographyMat()
For further informations take a look into the official documentation:
OpenCV 3.4 - decomposeHomographyMat()
这篇关于在opencv python中分解同构矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!