资源描述:
《摄像机定标opencv程序》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#include"cvut.h"#include#include#includeusingnamespacecvut;usingnamespacestd;#pragmacomment(lib,"cxcore.lib")#pragmacomment(lib,"cv.lib")#pragmacomment(lib,"highgui.lib")voidmain(){ifstreamfin("calibdata.txt");/*定标所用图像文件的路径*/ofstreamfout("ca
2、liberation_result.txt");/*保存定标结果的文件*//************************************************************************读取每一幅图像,从中提取出角点,然后对角点进行亚像素精确化*************************************************************************/cout<<"开始提取角点………………";intimage_count=0;/*图像数量*/CvSizeima
3、ge_size;/*图像的尺寸*/CvSizeboard_size=cvSize(5,7);/*定标板上每行、列的角点数*/CvPoint2D32f*image_points_buf=newCvPoint2D32f[board_size.width*board_size.height];/*缓存每幅图像上检测到的角点*/Seqimage_points_seq;/*保存检测到的所有角点*/stringfilename;while(getline(fin,filename)){image_count++;i
4、ntcount;Imageview(filename);if(image_count==1){image_size.width=view.size().width;image_size.height=view.size().height;}/*提取角点*/if(0==cvFindChessboardCorners(view.cvimage,board_size,image_points_buf,&count,CV_CALIB_CB_ADAPTIVE_THRESH)){cout<<"cannotfindchessboa
5、rdcorners!";exit(1);}else{otherstaffoftheCentre.Duringthewar,ZhuwastransferredbacktoJiangxi,andDirectorofthenewOfficeinJingdezhen,JiangxiCommitteeSecretary.Startingin1939servedasrecorderoftheWestNorthOrganization,SecretaryoftheSpecialCommitteeAfterthevictoryofthelon
6、gMarch,hehasbeentheNorthwestOfficeoftheFederationofStateenterprisesMinister,ShenmufuguSARmissions,DirectorofNingxiaCountypartyCommitteeSecretaryandrecorderoftheCountypartyCommitteeSecretary,MinistersandImageview_gray(view.size(),8,1);rgb2gray(view,view_gray);/*
7、亚像素精确化*/cvFindCornerSubPix(view_gray.cvimage,image_points_buf,count,cvSize(11,11),cvSize(-1,-1),cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,0.1));image_points_seq.push_back(image_points_buf,count);/*在图像上显示角点位置*/cvDrawChessboardCorners(view.cvimage,board_size,im
8、age_points_buf,count,1);view.show("calib");cvWaitKey();view.close();}}delete[]image_points_buf;cout<<"角点提取完成!";/**********