# include
# include
# include
# include
Using the namespace CV;
using namespace std;
Const int imageWidth=2592;
Const int imageHeight=1944;//the size of the image
The Size imageSize=Size (imageWidth, imageHeight);
Mat image;
Mat DST.
Mat cameraMatrix;
Mat distCoeffs;
Mat new_Matrix;
Mat view, rview, map1, map2;
Double fx=3.711083918716881 e+03, fy=3.746783973239024 e+03, cx=1.277862448956563 e+03, cy e+03=1.074499653803534;
Double k1k2Distortion [2]={0.137182602576044, 0.373025683414344};
Double p1p2p3Distortion [3]={0.005182048337687, 0.001036776592359, 0};
Void paramterslnit ();//converts parameter coefficient matrix
Void paramterslnit () {
Mat cameraMatrix=Mat: : eye (3, 3, CV_64F);//camera parameter matrix, not vertical factor of 0;
CameraMatrix. At
CameraMatrix. At
CameraMatrix. At
CameraMatrix. At
CameraMatrix. At
CameraMatrix. At
CameraMatrix. At
CameraMatrix. At
CameraMatrix. At
Mat distCoeffs=Mat: : zeros (1, 5, CV_64F);
DistCoeffs. At
DistCoeffs. At
DistCoeffs. At
DistCoeffs. At
DistCoeffs. At
}
Int main () {
Paramterslnit ();
Image=imread (" 1. PNG ");
The Size imageSize;
ImageSize=image. The size ();
Undistort (image, DST, cameraMatrix distCoeffs, new_Matrix);
Distort namedWindow (" image ", 0);
Imshow (" distort the image ", image);
Undistort namedWindow (" image ", 0);
Imshow (undistort "image", DST);
Undistort imwrite (" image ", DST);
WaitKey (0);
system("pause");
return 0;
}
As shown above, this is my code, image distortion correction is what I use is undistort function, a running "without exception processing problems, game consoles appeared the following OpenCV (4.1.0) Error: an Assertion failed (data) in CV: : Mat_ & lt; Double> : : operator (), the file c: \ build \ master_winpack - build - win64 - vc15 \ opencv \ modules \ core \ include \ opencv2 \ core \ mat inl. HPP, line 1889, after the call stack window below , don't know is what reason, the great god grant instruction!