问题描述:如图
运行rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 calibrate depth
[INFO] [DepthCalibration::calibrate] frame: ./0000_depth.png
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.2.0) ../modules/calib3d/src/calibration.cpp:259: error: (-5:Bad argument) Input argument is not a valid matrix in function 'cvRodrigues2'
已放弃 (核心已转储)
原因:如果使用 OpenCV 4,kinect2_bridge/src/kinect2_calibration.cpp 中的第 1093-1096 行会被宏处理掉,因此需要为 OpenCV 4 添加一行(与 OpenCV 3 的调用签名相同)
解决方法:找到kinect2_calibration/src/kinect2_calibration.cpp文件,对其中代码进行调整
746行处:#elif CV_MAJOR_VERSION == 3
error = cv::stereoCalibrate(pointsBoard, pointsIr, pointsColor, cameraMatrixIr, distortionIr, cameraMatrixColor, distortionColor, sizeColor,
改为:#elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4
1094行处同理:#elif CV_MAJOR_VERSION == 3
cv::solvePnPRansac(board, points[index], cameraMatrix, distortion, rvec, translation, false, 300, 0.05, 0.99, cv::noArray(), cv::SOLVEPNP_ITERATIVE);
改为#elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4
再次运行rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 calibrate depth,问题解决。