在该实验中主要通过opencv使用拍摄的棋盘格对相机进行calibration.求出相机的内参和外参.实验设备为basler工业相机.
注:opencv的sample中有标准示例程序,这里的程序是自己写的仅供练习.
#include#include #include #include #include #include #include #include #include #include #include #include #include using namespace cv; using namespace std; string imageList[]={string("./n1.JPG"),string("./n2.JPG"),string("./n3.JPG"),string("./n4.JPG"), string("./n5.JPG"),string("./n6.JPG"),string("./n7.JPG"),string("./n8.JPG"), string("./n9.JPG"),string("./n10.JPG"),string("./n11.JPG"),string("./n12.JPG") }; CvSize boardSize(5,7); int photo_size=12; float squareSize=50; int main(){ vector< Point3f > CornerPoints; vector > ObjectPoints; vector > imagePoints; vector save_view; bool have_set=false; CvSize ImageSize; for(int i=0;i ptvec; int corner_count=9; //the error for find==0:https://blog.csdn.net/u011651743/article/details/51099543 bool found = findChessboardCorners( view, boardSize, ptvec ,CALIB_CB_ADAPTIVE_THRESH ); //for more precise ,use cvFindCornerSubPix drawChessboardCorners(view,boardSize,ptvec,found); imshow("input", view); save_view.push_back(view); imagePoints.push_back(ptvec); if(have_set==false){ have_set=true; for(int j=0;j (0,0) = 1; Mat distCoeffs; distCoeffs=Mat::zeros(8, 1, CV_64F); int iFixedPoint = -1; vector rvecs;vector tvecs; double rms = calibrateCamera(ObjectPoints, imagePoints, ImageSize, cameraMatrix, distCoeffs, rvecs, tvecs, CALIB_FIX_ASPECT_RATIO | CALIB_USE_LU); cout< projectedPoints; cv::projectPoints(ObjectPoints[i], rvecs[i], tvecs[i],cameraMatrix, distCoeffs, projectedPoints); err = norm(imagePoints[i], projectedPoints, NORM_L2); cout<(3,1)<<); // } // } //cout<



