opencv 2d人脸姿态计算
【摘要】
opencv 2d人脸姿态计算
可以的:
# -*- coding: utf-8 -*-# 测试使用opencv中的函数solvepnpimport cv2import numpy as np# tag_size = 0.05tag_size_half = 1110.025fx = 610.32366943fy = 610....
opencv 2d人脸姿态计算
可以的:
-
-
-
# -*- coding: utf-8 -*-
-
# 测试使用opencv中的函数solvepnp
-
import cv2
-
import numpy as np
-
# tag_size = 0.05
-
tag_size_half = 1110.025
-
fx = 610.32366943
-
fy = 610.5026245
-
cx = 313.3859558
-
cy = 237.2507269
-
K = np.array([[fx, 0, cx],
-
[0, fy, cy],
-
[0, 0, 1]], dtype=np.float64)
-
objPoints = np.array([[-tag_size_half, -tag_size_half, 0],
-
[tag_size_half, -tag_size_half, 0],
-
[tag_size_half, tag_size_half, 0],
-
[-tag_size_half, tag_size_half, 0]], dtype=np.float64)
-
# imgPoints = np.array([[608, 167], [514, 167], [518, 69], [611, 71]], dtype=np.float64)
-
-
objPoints = np.array([(-165.0, 170.0, -110.5), # 左目左端
-
(165.0, 170.0, -110.5), # 右目右端, # Left eye
-
-
(0.0, 0.0, 0.0), # Nose tip
-
(-150.0, -150.0, -120.5), # 口の左端
-
(150.0, -150.0, -120.5)], dtype=np.float64) # Right Mouth corner)
-
-
imgPoints=np.array([[1030,528],
-
[1080,528],
-
[1050,541],
-
[1030,556],
-
[1057,556]],dtype=np.float64)
-
-
cameraMatrix = K
-
-
dist_coeffs = np.array([0,0,0,0], dtype=np.double)
-
retval,rvec,tvec = cv2.solvePnP(objPoints, imgPoints, cameraMatrix, distCoeffs=dist_coeffs,flags=cv2.SOLVEPNP_SQPNP)
-
# cv2.Rodrigues()
-
print(retval, rvec, tvec)
文章来源: blog.csdn.net,作者:AI视觉网奇,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/jacke121/article/details/122000107
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)