简体   繁体   中英

projectPoints returns huge numbers

I am trying to project some 3d points on my image. To do so, I use OpenCV's projectPoints method. The uv-coordinates returned by this function are way to high (±e12).

This is the function call

image_points = cv2.projectPoints(objectPoints=object_points, rvec=rvec, tvec=tvec, cameraMatrix=K, distCoeffs=distortionCoefficients)

Here I've pprinted all the parameters and the resulting numbers:

------------------ project points parameters ------------------
object_points
array([[ 46.22355289, -16.91716111,  -2.82987621],
       [ 43.78832261, -13.05850379,  -2.82991462],
       [ 37.07163144,  -2.41386808,  -2.83002055],
       [ 37.0715428 ,  -2.4138769 ,   1.90501117],
       [ 43.78815898, -13.05852006,   5.91114394],
       [ 46.22341644, -16.91717469,   4.45917262],
       [ 46.22355289, -16.91716111,  -2.82987621]])
rvec
array([0., 0., 0.])
tvec
array([0., 0., 0.])
camera matrix
array([[3.31448768e+03, 0.00000000e+00, 2.11145044e+03],
       [0.00000000e+00, 3.32249862e+03, 1.49983176e+03],
       [0.00000000e+00, 0.00000000e+00, 1.00000000e+00]])
dist coeff
array([ 0.2259219 , -0.9247832 , -0.00545379,  0.00127311,  1.078296  ])
------------------ project points results ------------------
array([[[-1.61201971e+12,  5.91402161e+11]],
       [[-9.76843272e+11,  2.92017176e+11]],
       [[-2.38378863e+11,  1.55592241e+10]],
       [[ 3.81670677e+12, -2.49121760e+11]],
       [[ 5.56809216e+09, -1.66453065e+09]],
       [[ 6.65464992e+10, -2.44140259e+10]],
       [[-1.61201971e+12,  5.91402161e+11]]])

The image size is 4160x3120. The undistorted image (using OpenCV's undistort method) looks perfect.

I've assumed a wrong coordinate system. The function uses this coordinate system: https://www.researchgate.net/figure/Pinhole-camera-model_fig1_265107440 So some axes were switched...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM