Home > other >  Why my image distortion correction error, a great god give advice or comments
Why my image distortion correction error, a great god give advice or comments

Time:02-04

# include
# 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 (0, 0)=3.711083918716881 e+03;//fx
CameraMatrix. At (0, 1)=0;
CameraMatrix. At (0, 2)=1.277862448956563 e+03;//cx.
CameraMatrix. At (1, 0)=0.
CameraMatrix. At (1, 1)=3.746783973239024 e+03;//fy;
CameraMatrix. At (1, 2)=1.074499653803534 e+03;//cy.
CameraMatrix. At (2, 0)=0;
CameraMatrix. At (2, 1)=0.
CameraMatrix. At (2, 2)=1;
Mat distCoeffs=Mat: : zeros (1, 5, CV_64F);
DistCoeffs. At (0, 0)=k1k2Distortion [0].//k1;
DistCoeffs. At (0, 1)=k1k2Distortion [1].//k2.
DistCoeffs. At (0, 2)=p1p2p3Distortion [0].//p1.
DistCoeffs. At (0, 3)=p1p2p3Distortion [1].//p2.
DistCoeffs. At (0, 4)=p1p2p3Distortion [2].//k3;
}
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!
  • Related