私は OpenCV プロジェクトに取り組んでおり、キャリブレーションを行っています。コードを正しく実装したと思います。ただし、カメラマトリックスの値が異なる場合があり、大きく異なる場合があります。キャリブレーションパターンを10回表示することを6回繰り返した後、次のようになります(わかりやすくするために小数点以下は切り捨てられます):
[573, 0, 386;
0, 573, 312;
0, 0, 1]
[642, 0, 404;
0, 644, 288;
0, 0, 1]
[664, 0, 395;
0, 665, 272;
0, 0, 1]
[629, 0, 403;
0, 630, 288;
0, 0, 1]
[484, 0, 377;
0, 486, 307;
0, 0, 1]
[644, 0, 393;
0, 643, 289;
0, 0, 1]
これらの値は、許容できないほど異なります。与えられたパラメータが何であるかをかなりの精度で知る必要があります。通常、これらの大きな不正確さの原因は何ですか?また、特定のマトリックスの正確性を評価するにはどうすればよいですか? パターンを表示するさまざまな距離と方向に依存しているようですが、パターンの意味がわかりません。
コード:
using namespace cv;
using namespace std;
int main(int, char**)
{
VideoCapture cap(1);
if(!cap.isOpened())
return -1;
cap.set(CV_CAP_PROP_FRAME_WIDTH,800);
cap.set(CV_CAP_PROP_FRAME_HEIGHT,600);
Mat edges;
Size size(9,17);
int counter = 10;
vector<Point2f> corners;
bool found;
vector<Point3f> chess = fr::ChessGen::getBoard(size,1,true);
vector<vector<Point3f> > objectPoints;
vector<vector<Point2f> > imagePoints;
Mat camera = Mat::eye(3,3,CV_64F);
Mat distortion = Mat::zeros(8, 1, CV_64F);
vector<Mat > rvecs;
vector<Mat > tvecs;
namedWindow("edges",1);
for(;;)
{
Mat frame;
cap >> frame;
cvtColor(frame, edges, CV_BGR2GRAY);
found = findCirclesGrid(edges,size,corners
,CALIB_CB_ASYMMETRIC_GRID
);
if(found) frame.convertTo(edges,-1,0.2);
drawChessboardCorners(edges,size,corners,found);
imshow("edges", edges);
if(found){
if(waitKey(200)>=0){
objectPoints.push_back(chess);
imagePoints.push_back(corners);
if(--counter<= 0)
break;
}
}
else waitKey(30);
}
calibrateCamera(objectPoints,imagePoints,Size(800,600),camera,distortion,rvecs,tvecs,0);
if(found) imwrite("/home/ryan/snapshot.png",edges);
cout << camera << endl;
return 0;
}