断言失败(!ssize.empty())在remapBilinear中

问题描述 投票:0回答:1

我的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_matrixdistortion_coefficientscamera.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. ]
c++ camera-calibration opencv4
1个回答
1
投票

您试图将图像重新映射应用于空图像。

参数是

remap(src, dst, mapx, mapy);

你的输入view是一个空垫子。

最相关的图像可能是您的输入图像,所以

remap(temp , rview, map1, map2, INTER_LINEAR);
© www.soinside.com 2019 - 2024. All rights reserved.