(npoints >= 4) || (npoints == 3 && flags == SOLVEPNP_ITERATIVE && useExtrinsicGuess) || (npoints >=

(npoints >= 4) || (npoints == 3 && flags == SOLVEPNP_ITERATIVE && useExtrinsicGuess) || (npoints >= 3 && flags == SOLVEPNP_SQPNP) 

##targetimagepoints
import numpy as np
import cv2
tPoints=np.zeros((4,2),dtype=np.float64)
tPoints[0,0]=384.3331
tPoints[0,1]=162.23618
tPoints[1,0]=385.27521
tPoints[1,1]=135.21503
tPoints[2,0]=409.36746
tPoints[2,1]=165.64435

tPoints=np.array([(-165.0,170.0,-115.0),#左目左端
(165.0,170.0,-115.0),#右目右端,#Lefteye

(0.0,0.0,0.0),#Nosetip
(-150.0,-150.0,-125.0),#口の左端
(150.0,-150.0,-125.0)],dtype=np.float64)#RightMouthcorner)

##actualmarkerpointset


mPoints=np.zeros((4,3),dtype=np.float64)
mPoints[0,0]=-88.0
mPoints[0,1]=88.0
mPoints[0,2]=0
mPoints[1,0]=-88.0
mPoints[1,1]=-88.0
mPoints[1,2]=0
mPoints[2,0]=88.0
mPoints[2,1]=-88.0
mPoints[2,2]=0
mPoints[3,0]=88.0
mPoints[3,1]=88.0
mPoints[3,2]=0

mPoints=np.array([[1033,528],
[1058,528],
[1045,541],
[1035,556],
[1057,556]],dtype=np.float64)


camMatrix=np.zeros((3,3),dtype=np.float64)
camMatrix[0][0]=519.0
camMatrix[0][2]=320.0
camMatrix[1][1]=522.0
camMatrix[1][2]=240.0
camMatrix[2][2]=1.0

dist_coeffs=np.array([7.0834633684407095e-002,6.9140193737175351e-002,0.0,0.0,-1.3073460323689292e+000],dtype="double")#Assumingnolensdistortion
#retval,rvec,tvec=cv2.solvePnP(objectPoints=mPoints,imagePoints=tPoints,cameraMatrix=camMatrix,distCoeffs=dist_coeffs,flags=cv2.SOLVEPNP_ITERATIVE)
retval,rvec,tvec=cv2.solvePnP(objectPoints=mPoints,imagePoints=tPoints,cameraMatrix=camMatrix,distCoeffs=None)


print(retval)
print(rvec)
print(tvec)

原因,参数给错了

retval,rvec,tvec=cv2.solvePnP(objectPoints=mPoints,imagePoints=tPoints,cameraMatrix=camMatrix,distCoeffs=None)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI算法网奇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值