DLT algorithm needs at least 6 points for pose estimation from 3D-2D point correspondences. (expecte

DLT algorithm needs at least 6 points for pose estimation from 3D-2D point correspondences. (expected: 'count >= 6')



# -*- 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)

没有找到解

换一个求解算法:



# -*- 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)

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

AI算法网奇

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

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

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

打赏作者

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

抵扣说明:

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

余额充值