好像我有两个摄像头,标记为cam1,cam2.And,我想校准它们以得到它们之间的转换。
我用cv::stereoCalibrate()校准。
从cam1转换到cam2,标记为R后,T.I要检查校准结果的准确性。
所以我用cam1和cam2拍了一张棋盘的照片,马克作为pic1,pic2.I用cv::solvePnP().And得到了cam1的外部参数,我用pic1中的cv::projectPoints()绘制了cam1的世界坐标系。
然后,我认为cam2's旋转matrix=cam1的旋转矩阵* R.And cam2的平移matrix=cam1的平移矩阵+ T。
利用上述cam2计算了thought.And的外部参数,并在pic2中用cv::projectPoints()绘制了cam2的世界坐标系。
但pic2的起源并不正确。
下面是我使用的代码的一部分。
void check_res(const vector<string> &imgs_nm,const Mat &R,const Mat &T,const Mat &cam_c,const Mat &cam_h,const Mat &dist_c,const Mat &dist_h)
{
int imgs_cnt=imgs_nm.size()/2;
vector<Point3f> obj_pts;
for(int i=0;i<boardDimensions.height;i++)
for(int j=0;j<boardDimensions.width;j++)
obj_pts.push_back(Point3f(i*CHESS_LEN,j*CHESS_LEN,0.f));
for(int i=0;i<imgs_cnt;i++)
{
vector<Point2f> c_cners,h_cners;
Mat imgc_gray,imgh_gray;
Mat imgc=imread(imgs_nm[i*2],1);
Mat imgc_rz=imgc.clone();
bool c_found,h_found;
c_found=HasChessBoard(imgc_rz,imgc_gray,c_cners);
if(c_found)
cv::cornerSubPix(imgc_gray, c_cners, cv::Size(11, 11), cv::Size(-1, -1),cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
Mat imgh=imread(imgs_nm[i*2+1],1);
h_found=HasChessBoard(imgh,imgh_gray,h_cners);
if(h_found)
cv::cornerSubPix(imgh_gray, h_cners, cv::Size(11, 11), cv::Size(-1, -1),cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
Mat rvec_c,rvec_h,tvec_c,tvec_h;
cv::solvePnP(obj_pts,c_cners,cam_c,dist_c,rvec_c,tvec_c);
cv::solvePnP(obj_pts,h_cners,cam_h,dist_h,rvec_h,tvec_h);
Mat rrvec_c,rrvec_h;
cv::Rodrigues(rvec_c,rrvec_c);
cv::Rodrigues(rvec_h,rrvec_h);
Mat r1=rrvec_c*R;
Mat t1=tvec_c+T;
Mat img1=imgh.clone();
draw_chess(imgh,rrvec_h,tvec_h,cam_h,dist_h);
imshow("pic1",imgh);
draw_chess(img1,r1,t1,cam_h,dist_h);
imshow("pic2",img1);
char resc=waitKey(0);
if(resc=='q')
exit(1);
}
}下面是我使用opencv中的示例测试的结果。

我不认为这是低的校准精度,因为我使用opencv的样本和cv::stereoCalibrate()返回均方根小于1个像素。
如有任何建议,敬请见谅。谢谢!
发布于 2017-05-18 12:19:38
这些公式是:



发布于 2017-05-18 14:59:04
为了检查立体声校准的准确性,我会考虑另一种方法:
stereoRectify函数对摄像机进行校正变换。使用从stereoCalibrate获得的平移矩阵和旋转矩阵。initUndistortRectifyMap。使用remap从两个相机的图像。如果您的校准进行良好,输出图像应纠正和不失真。
https://stackoverflow.com/questions/44045144
复制相似问题