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

x33g5p2x  于2021-12-17 转载在 Go  
字(2.0k)|赞(0)|评价(0)|浏览(699)

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

  1. # -*- coding: utf-8 -*-
  2. # 测试使用opencv中的函数solvepnp
  3. import cv2
  4. import numpy as np
  5. # tag_size = 0.05
  6. tag_size_half = 1110.025
  7. fx = 610.32366943
  8. fy = 610.5026245
  9. cx = 313.3859558
  10. cy = 237.2507269
  11. K = np.array([[fx, 0, cx],
  12. [0, fy, cy],
  13. [0, 0, 1]], dtype=np.float64)
  14. objPoints = np.array([[-tag_size_half, -tag_size_half, 0],
  15. [tag_size_half, -tag_size_half, 0],
  16. [tag_size_half, tag_size_half, 0],
  17. [-tag_size_half, tag_size_half, 0]], dtype=np.float64)
  18. # imgPoints = np.array([[608, 167], [514, 167], [518, 69], [611, 71]], dtype=np.float64)
  19. objPoints = np.array([(-165.0, 170.0, -110.5), # 左目左端
  20. (165.0, 170.0, -110.5), # 右目右端, # Left eye
  21. (0.0, 0.0, 0.0), # Nose tip
  22. (-150.0, -150.0, -120.5), # 口の左端
  23. (150.0, -150.0, -120.5)], dtype=np.float64) # Right Mouth corner)
  24. imgPoints=np.array([[1030,528],
  25. [1080,528],
  26. [1050,541],
  27. [1030,556],
  28. [1057,556]],dtype=np.float64)
  29. cameraMatrix = K
  30. dist_coeffs = np.array([0,0,0,0], dtype=np.double)
  31. retval,rvec,tvec = cv2.solvePnP(objPoints, imgPoints, cameraMatrix, distCoeffs=dist_coeffs)#,flags=cv2.SOLVEPNP_SQPNP)
  32. # cv2.Rodrigues()
  33. print(retval, rvec, tvec)

没有找到解

换一个求解算法:

  1. # -*- coding: utf-8 -*-
  2. # 测试使用opencv中的函数solvepnp
  3. import cv2
  4. import numpy as np
  5. # tag_size = 0.05
  6. tag_size_half = 1110.025
  7. fx = 610.32366943
  8. fy = 610.5026245
  9. cx = 313.3859558
  10. cy = 237.2507269
  11. K = np.array([[fx, 0, cx],
  12. [0, fy, cy],
  13. [0, 0, 1]], dtype=np.float64)
  14. objPoints = np.array([[-tag_size_half, -tag_size_half, 0],
  15. [tag_size_half, -tag_size_half, 0],
  16. [tag_size_half, tag_size_half, 0],
  17. [-tag_size_half, tag_size_half, 0]], dtype=np.float64)
  18. # imgPoints = np.array([[608, 167], [514, 167], [518, 69], [611, 71]], dtype=np.float64)
  19. objPoints = np.array([(-165.0, 170.0, -110.5), # 左目左端
  20. (165.0, 170.0, -110.5), # 右目右端, # Left eye
  21. (0.0, 0.0, 0.0), # Nose tip
  22. (-150.0, -150.0, -120.5), # 口の左端
  23. (150.0, -150.0, -120.5)], dtype=np.float64) # Right Mouth corner)
  24. imgPoints=np.array([[1030,528],
  25. [1080,528],
  26. [1050,541],
  27. [1030,556],
  28. [1057,556]],dtype=np.float64)
  29. cameraMatrix = K
  30. dist_coeffs = np.array([0,0,0,0], dtype=np.double)
  31. retval,rvec,tvec = cv2.solvePnP(objPoints, imgPoints, cameraMatrix, distCoeffs=dist_coeffs,flags=cv2.SOLVEPNP_SQPNP)
  32. # cv2.Rodrigues()
  33. print(retval, rvec, tvec)

相关文章

最新文章

更多