我opencv_version
的是:4.1.0-pre
我有以下代码:
FileStorage fs("camera.yml", FileStorage::READ);
Mat cameraMatrix;
Mat distCoeffs;
fs["camera_matrix"] >> cameraMatrix;
fs["distortion_coefficients"] >> distCoeffs;
fs.release();
Mat image;
string fileName = "view000.bmp";
image = imread(fileName, IMREAD_COLOR); // Read the file
Mat temp = image.clone();
undistort(temp, image, cameraMatrix, distCoeffs);
Size imageSize = image.size();
Mat view, rview, map1, map2;
initUndistortRectifyMap(cameraMatrix, distCoeffs, Mat(),
getOptimalNewCameraMatrix(cameraMatrix, distCoeffs, imageSize, 1, imageSize, 0),
imageSize, CV_16SC2, map1, map2);
remap(view, rview, map1, map2, INTER_LINEAR);
undistort
函数正常工作,如何第一次调用remap
产生异常:
OpenCV(4.1.0-pre) 错误:remapBilinear 中的断言失败 (!ssize.empty()),文件 /home/olga/opencv/modules/imgproc/src/imgwarp.cpp,第 666 行
这是calibration_matrix
和distortion_coefficients
来自camera.yml
:
camera_matrix: !!opencv-matrix
rows: 3
cols: 3
dt: d
data: [ 6.6979083645491733e+02, 0., 3.5720142378760517e+02, 0.,
6.6818397497437070e+02, 2.2958328379477018e+02, 0., 0., 1. ]
distortion_coefficients: !!opencv-matrix
rows: 5
cols: 1
dt: d
data: [ -9.1630887760709781e-02, 6.3870694676062587e-02,
-2.9224237615839681e-04, 8.0315318960669040e-04, 0. ]