pythonopencvcamera-calibrationstereoscopy

OpenCV Python : distCoeffs2 is not a numerical tuple


I am using the StereoVision framework provided by https://github.com/erget/StereoVision to reconstruct a 3D Point Cloud from a Stereo Pair.

All scripts run smooth but executing the calibrate_cameras.py script gives me the following error:

distCoeffs2 is not a numerical tuple 

More specifically the error happens in the cv2.stereoCalibrate function call in the following code snippet

    (calib.cam_mats["left"], calib.dist_coefs["left"],
     calib.cam_mats["right"], calib.dist_coefs["right"],
     calib.rot_mat, calib.trans_vec, calib.e_mat,
     calib.f_mat) = cv2.stereoCalibrate(self.object_points,
                                        self.image_points["left"],
                                        self.image_points["right"],
                                        calib.cam_mats["left"],
                                        calib.dist_coefs["left"],
                                        calib.cam_mats["right"],
                                        calib.dist_coefs["right"],
                                        self.image_size,
                                        calib.rot_mat,
                                        calib.trans_vec,
                                        calib.e_mat,
                                        calib.f_mat,
                                        criteria=criteria,
                                        flags=flags)[1:]

Any idea on what's causing the problem and how to solve it?

My system: Windows 7 + Python 2.7.14 + OpenCV 2.4.9

Any help will be highly appreciated

Thanks in advance


Solution

  • For anybody experiencing the same issue, there is a simple and quick fix: change the position of the argument self.image_size.

    I post it here hoping it will be helpful for other people having the same problem.

    into

        (calib.cam_mats["left"], calib.dist_coefs["left"],
         calib.cam_mats["right"], calib.dist_coefs["right"],
         calib.rot_mat, calib.trans_vec, calib.e_mat,
         calib.f_mat) = cv2.stereoCalibrate(self.object_points,
                                            self.image_points["left"],
                                            self.image_points["right"],
                                            self.image_size,
                                            calib.cam_mats["left"],
                                            calib.dist_coefs["left"],
                                            calib.cam_mats["right"],
                                            calib.dist_coefs["right"],
                                            calib.rot_mat,
                                            calib.trans_vec,
                                            calib.e_mat,
                                            calib.f_mat,
                                            criteria=criteria,
                                            flags=flags)[1:]
    

    And the problem is fixed!