1

I am dealing with the estimated distance of an object with the solvePnP method. I already did some measurements and my calculated distance is far above the actual distance. I also used a calibrated camera. For the distance calculation, I use the result distance in 3 axes from solvePnP and distance pattern in 3D:

tvec = cv2.solvePnP(
  objectPoints = model,
  imagePoints = key_points,
  cameraMatrix = camera_matrix, 
  distCoeffs = dist_coeffs,
  flags=cv2.SOLVEPNP_ITERATIVE
)[2]
pnp_distance = mt.sqrt(tvec[0]**2 + tvec[1]**2 + tvec[2]**2)

On the image below you can see that calculated measurement (dots) are above real values (line):

enter image description here

Are there some extra options to make solvePnP more precise, or maybe I did something wrong?

In the beginning I used the calculated camera matrix from image size. With that and plotted error distribution I decided to divide x axis distance by 2 and that actually helped. Calculated values were much closer than with the actual camera matrix.

enter image description here

How I can improve my distance estimation with solvePnP and camera matrix? Thanks in advance!

user7247147
  • 1,045
  • 1
  • 10
  • 24
PaaaV
  • 11
  • 1

0 Answers0