Opencv摄像头标定(参数+校正),但cvFindChessboardCorners不太稳定,必须标版
#include
#include
#include
#include
#include using namespace std;int n_boards=0;//图像数目 canshuconst int board_dt=20;//等20帧每棋盘视图 xin//int sn_board=0;//成功找到角点的图像数目int board_w;//图像的角点行列数 canshuint board_h; //canshu
int main(int argc ,char * argv[])
{/*读入图像*/CvCapture*capture; //xinif(argc!=4)//xin
{printf("ERROR:Wrong number of input parameters\n");//xinreturn -1; //xin
}
board_w=atoi(argv[1]); //canshu
board_h=atoi(argv[2]); //canshu
n_boards=atoi(argv[3]); //canshuint board_n=board_h*board_w;//每幅图像的角点数
CvSize board_size=cvSize(board_w,board_h);//每幅图像的角点数
capture=cvCreateCameraCapture(0);//xin
//assert(capture); //xinif(!capture) { printf("\nCouldn't open the camera\n"); return -1;}
cvNamedWindow("MyCalib");
cvNamedWindow("Raw Video");//allocate storageCvMat*object_points = cvCreateMat(board_n*n_boards,3,CV_32FC1);CvMat*image_points =cvCreateMat(board_n*n_boards,2,CV_32FC1);CvMat*point_counts =cvCreateMat(n_boards,1,CV_32SC1);CvMat * camera_matrix =cvCreateMat(3,3,CV_32FC1);//摄像机矩阵(内参数矩阵) 分配矩阵空间(行,列,类型)类型为矩阵元素类型CvMat * distortion_coeffs=cvCreateMat(4,1,CV_32FC1);//畸变系数CvPoint2D32f*corners=new CvPoint2D32f[board_n];//一幅图像的角点数组int corner_count;int successes=0; //xin// 本文 successes就是 sn_boardint step,frame=0; //xinIplImage*image=cvQueryFrame(capture); //图像的大小 // xinIplImage *gray_image=cvCreateImage(cvGetSize(image),8,1);//创建头并分配数据//tong SourceImgGray//亚像素subpixel//capture corner views loop until we've got n_boards//成功捕获(找到所有角点on the board)while (successes
转载于:https://www.cnblogs.com/sjxiaoe/p/5034421.html
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
