stereolabs / zed-opencv

ZED SDK interface sample for OpenCV
https://www.stereolabs.com/docs/opencv/
MIT License
139 stars 79 forks source link

calibration using cv2.calibrateCamera() #77

Closed amaanda closed 2 years ago

amaanda commented 4 years ago

I am calibrating a zed camera using openCV. Here's a snippet of my code:

(ret, cam_mtx, dist_coef, rvecs, tvecs) = cv2.calibrateCamera(
        objectPoints=all_points,
        imagePoints=all_corners,
        imageSize=(imsize[1],imsize[0]), cameraMatrix=None, distCoeffs=None,flags=flags,
        criteria=(cv2.TERM_CRITERIA_EPS & cv2.TERM_CRITERIA_COUNT, 100, 1e-9))

I am having a hard time figuring time how to convert rvecs and tvecs to the format I need, that is, to generate a .conf file for my camera. What I am getting is:

rvecs:

[array([[ 2.89418192],
       [-0.07683405],
       [-0.12218141]]), array([[ 2.89734916],
       [-0.05091014],
       [ 0.11568848]]), array([[ 2.97641468e+00],
       [-1.41443220e-03],
       [-8.76637882e-02]]), array([[ 3.02651864],
       [-0.01222717],
       [-0.11525255]]), array([[-2.86846819],
       [ 0.01228717],
       [-0.00926717]]), array([[-2.89646325],
       [ 0.00452772],
       [ 0.66105267]]), array([[-2.85456403],
       [-0.04735925],
       [ 0.97853948]]), array([[ 2.62186134],
       [-0.22973462],
       [-1.02042963]]), array([[ 2.51188296],
       [-0.20921853],
       [-1.0614529 ]]), array([[ 2.50607149],
       [-0.13086015],
       [-1.12610508]]), array([[2.63772821],
       [0.03622211],
       [0.43233866]]), array([[-2.74705839],
       [ 0.13906519],
       [-1.43743116]]), array([[-2.68948238],
       [ 0.27786059],
       [-1.27856456]]), array([[3.07236872e+00],
       [1.81297773e-03],
       [6.56419765e-02]]), array([[ 3.0360237 ],
       [ 0.03009842],
       [-0.39912302]]), array([[ 2.96263143],
       [ 0.10417411],
       [-0.30068941]]), array([[ 2.81188735],
       [-0.02963249],
       [-0.13459553]]), array([[ 2.54986634],
       [-0.09460476],
       [ 0.03856089]])]

tvecs:

[array([[-0.43812774],
       [ 0.35921839],
       [ 1.01603945]]), array([[-0.62533236],
       [ 0.35393496],
       [ 0.93391151]]), array([[-0.58765847],
       [ 0.39928036],
       [ 1.32408343]]), array([[-0.55725962],
       [ 0.30251848],
       [ 1.11605644]]), array([[-0.56962456],
       [ 0.42383521],
       [ 1.07411511]]), array([[-0.29136301],
       [ 0.3709198 ],
       [ 1.3676815 ]]), array([[-0.14543208],
       [ 0.37662865],
       [ 1.54455981]]), array([[-0.21365135],
       [ 0.54595927],
       [ 1.29207603]]), array([[-0.17572727],
       [ 0.59540708],
       [ 1.27956926]]), array([[-0.16127936],
       [ 0.53893064],
       [ 1.33448772]]), array([[-0.59867303],
       [ 0.41767143],
       [ 0.78117109]]), array([[-0.57941919],
       [ 0.53287311],
       [ 0.65353689]]), array([[-0.43599   ],
       [ 0.5008282 ],
       [ 0.73605343]]), array([[-0.56232051],
       [ 0.38536237],
       [ 0.83596279]]), array([[-0.25178157],
       [ 0.40341999],
       [ 0.95578624]]), array([[0.02695271],
       [0.67905127],
       [1.55404616]]), array([[-0.49717714],
       [ 0.19058732],
       [ 0.6681939 ]]), array([[-0.52244627],
       [ 0.29333498],
       [ 0.57787501]])]

What kind of transformation I have to do with these arrays? Thanks!

amaanda commented 4 years ago

PS I am calibrating for 720p videos

EnDroidCN commented 3 years ago

3x1 Rvec to 3x3 Rmat rot_mat = cv2.Rodrigues(rot_vec)

and Tvec just as it is, a 3x1 vector

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment otherwise it will be automatically closed in 5 days