code-iai / iai_kinect2

Tools for using the Kinect One (Kinect v2) in ROS
Apache License 2.0
879 stars 519 forks source link

Get an error when calibrating the extrinsics #346

Closed YeZhao closed 7 years ago

YeZhao commented 7 years ago

When I calibrate the extrinsics (run rosrun kinect2_calibration kinect2_calibration chess7x9x0.025 calibrate sync), I got the following error. (I searched online and went through closed issues of this repo, but didn't find anyone has similar problems.)

[ERROR] [CameraCalibration::loadCalibration] couldn't load color calibration data!

This is caused by the following code in kinect2_calibration.cpp

cv::FileStorage fs;
if(fs.open(path + K2_CALIB_COLOR, cv::FileStorage::READ))
{
  fs[K2_CALIB_CAMERA_MATRIX] >> cameraMatrixColor;
  fs[K2_CALIB_DISTORTION] >> distortionColor;
  fs[K2_CALIB_ROTATION] >> rotationColor;
  fs[K2_CALIB_PROJECTION] >> projectionColor;
  fs.release();
}
else
{
  OUT_ERROR("couldn't load color calibration data!");
  return false;
}

Does any one has a quick idea of what happens? I will appreciate your help a lot.

To explore what causes this issue, I even tried to just use one image, but still get the same error.

The calib_pose.yaml can be generated and seems to have reasonable values. Here I attach how the result looks like.

[ INFO] [main] restoring files... [ INFO] [CameraCalibration::readFiles] restoring file: 0000_sync_color_points.yaml [ INFO] [CameraCalibration::readFiles] restoring file: 0004_sync_color_points.yaml [ INFO] [CameraCalibration::readFiles] restoring file: 0007_sync_color_points.yaml [ INFO] [CameraCalibration::readFiles] restoring file: 0010_sync_color_points.yaml [ INFO] [CameraCalibration::readFiles] restoring file: 0008_sync_color_points.yaml [ INFO] [CameraCalibration::readFiles] restoring file: 0001_sync_color_points.yaml [ INFO] [CameraCalibration::readFiles] restoring file: 0002_sync_color_points.yaml [ INFO] [CameraCalibration::readFiles] restoring file: 0003_sync_color_points.yaml [ INFO] [CameraCalibration::readFiles] restoring file: 0009_sync_color_points.yaml [ INFO] [CameraCalibration::readFiles] restoring file: 0005_sync_color_points.yaml [ INFO] [CameraCalibration::readFiles] restoring file: 0006_sync_color_points.yaml [ INFO] [CameraCalibration::readFiles] restoring file: 0000_sync_ir_points.yaml [ INFO] [CameraCalibration::readFiles] restoring file: 0008_sync_ir_points.yaml [ INFO] [CameraCalibration::readFiles] restoring file: 0001_sync_ir_points.yaml [ INFO] [CameraCalibration::readFiles] restoring file: 0010_sync_ir_points.yaml [ INFO] [CameraCalibration::readFiles] restoring file: 0006_sync_ir_points.yaml [ INFO] [CameraCalibration::readFiles] restoring file: 0007_sync_ir_points.yaml [ INFO] [CameraCalibration::readFiles] restoring file: 0009_sync_ir_points.yaml [ INFO] [CameraCalibration::readFiles] restoring file: 0002_sync_ir_points.yaml [ INFO] [CameraCalibration::readFiles] restoring file: 0003_sync_ir_points.yaml [ INFO] [CameraCalibration::readFiles] restoring file: 0004_sync_ir_points.yaml [ INFO] [CameraCalibration::readFiles] restoring file: 0005_sync_ir_points.yaml [ERROR] [CameraCalibration::loadCalibration] couldn't load color calibration data! [ INFO] [main] starting calibration... [ INFO] [CameraCalibration::calibrateExtrinsics] Camera Matrix Color: [] [ INFO] [CameraCalibration::calibrateExtrinsics] Distortion Coeeficients Color: []

[ INFO] [CameraCalibration::calibrateExtrinsics] Camera Matrix Ir: [] [ INFO] [CameraCalibration::calibrateExtrinsics] Distortion Coeeficients Ir: []

[ INFO] [CameraCalibration::calibrateExtrinsics] calibrating Color and Ir extrinsics... [ INFO] [CameraCalibration::calibrateExtrinsics] re-projection error: 7.68866

[ INFO] [CameraCalibration::calibrateExtrinsics] Rotation: [0.9997819356378739, -0.0208824112633361, -7.792313632796729e-05; 0.02088240067330795, 0.9997819298716811, -0.0001343286130677481; 8.071124896214297e-05, 0.0001326720986299031, 0.9999999879419041] [ INFO] [CameraCalibration::calibrateExtrinsics] Translation: [0.07932239111244913; -0.04475063949214365; -0.001269125038200274] [ INFO] [CameraCalibration::calibrateExtrinsics] Essential: [2.289049754695986e-05, 0.001262911118683888, -0.04475080943234234; -0.001275250496515709, 1.597852289506465e-05, -0.07932229126176876; 0.04639732292606307, 0.07837059201026844, -1.414237696526279e-05] [ INFO] [CameraCalibration::calibrateExtrinsics] Fundamental: [-1.618574982351598, -89.29977766721345, 3164.306081096659; 90.17228855149622, -1.129832908167552, 5608.837287862157; -3280.730179942629, -5541.543136826731, 1]