-
大小: 14.52MB文件类型: .rar金币: 1下载: 0 次发布日期: 2023-08-04
- 语言: C/C++
- 标签:
资源简介
opencv 广角摄像头畸变标定校正,PC WINdow C++ 自动识别标板自动矫正
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
using namespace cv;
using namespace std;
int n_boards = 0;//图像数目 canshu
const int board_dt = 20;//等20帧每棋盘视图 xin
//int sn_board=0;//成功找到角点的图像数目
int board_w;//图像的角点行列数 canshu
int board_h; //canshu
//#pragma comment(lib “opencv_core220d.lib“)
//#pragma comment(lib “opencv_highgui220d.lib“)
//#pragma comment(lib “opencv_imgproc220d.lib“)
void PrintMat(CvMat*);
void FputMat(FILE * CvMat *);
int main(int argc char* argv[])
{
CvCapture*capture; //xin
board_w = 9;//atoi(argv[1]); //canshu
board_h = 6;//atoi(argv[2]); //canshu
n_boards =5;// atoi(argv[3]); //canshu
int board_n = board_h*board_w;//每幅图像的角点数
CvSize board_size = cvSize(board_w board_h);//每幅图像的角点数
capture = cvCreateCameraCapture(0);//xin
//assert(capture); //xin
if (!capture) { printf(“\nCouldn‘t open the camera\n“); return -1; }
cvNamedWindow(“MyCalib“);
cvNamedWindow(“Raw Video“);
//allocate storage
CvMat*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);
CvPoint2D32f*corners = new CvPoint2D32f[1000];//board_n];//一幅图像的角点数组
int corner_count;
int successes = 0; //xin// 本文 successes就是 sn_board
int step frame = 0; //xin
IplImage*image = cvQueryframe(capture); //图像的大小 // xin
if(image==NULL)
{
printf(“从摄像头获取图片失败\n“);
getchar();
return 0;
}
while (successes { //skip every board_dt frames to allow user to move chessboard
cvShowImage(“Calibration“ image);
if (frame++%board_dt == 0&& image!=NULL)
{
int found = cvFindChessboardCorners(image board_size corners &corner_count CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FILTER_QUADS);
if(found==0)
{
printf(“帧图片无法找到棋盘格所有角点! frame=%dsuccesses=%d\n“ frame successes);
}
else
{
IplImage *gray_image = cvCreateImage(cvGetSize(image) 8 1);//创建头并分配数据//tong SourceImgGray
//亚像素subpixel
//capture corner views loop until we‘ve got n_boards
//成功捕获(找到所有角点on the board)
cvCvtColor(image gray_image CV_BGR2GRAY); //xin
/*
const int MAX_CORNERS = 1000;
CvPoint2D32f* corners1 = new CvPoint2D32f[MAX_CORNERS];
int corner_count = MAX_CORNERS;
double quality_level = 0.1; //OR 0.01
double min_distance = 5;
IplImage* img_copy = cvCloneImage(image);//a copy of img
IplImage* img_gray = cvCreateImage(cvGetSize(image) IPL_DEPTH_8U 1);
IplImage* eig_image = cvCreateImage(cvGetSize(image) IPL_DEPTH_32F 1);
IplImage* temp_image = cvCloneImage(eig_image);
cvGoodFeaturesToTrack(
img_gray
eig_image
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 35328 2018-03-21 17:15 Calibration11\.vs\Calibration\v14\.suo
文件 5420 2018-03-21 14:17 Calibration11\Calibration\Calibration.vcxproj
文件 945 2018-03-21 14:17 Calibration11\Calibration\Calibration.vcxproj.filters
文件 394 2018-03-20 17:49 Calibration11\Calibration\Calibration.vcxproj.user
文件 92 2018-03-20 17:15 Calibration11\Calibration\camera_matrix.txt
文件 277 2018-03-20 17:15 Calibration11\Calibration\camera_matrix1111.xm
文件 1416 2018-03-21 14:17 Calibration11\Calibration\Debug\Calibration.Build.CppClean.log
文件 88 2018-03-21 16:47 Calibration11\Calibration\Debug\Calibration.log
文件 158 2018-03-21 16:47 Calibration11\Calibration\Debug\Calibration.tlog\Calibration.lastbuildstate
文件 796 2018-03-21 16:47 Calibration11\Calibration\Debug\Calibration.tlog\CL.command.1.tlog
文件 26522 2018-03-21 16:47 Calibration11\Calibration\Debug\Calibration.tlog\CL.read.1.tlog
文件 420 2018-03-21 16:47 Calibration11\Calibration\Debug\Calibration.tlog\CL.write.1.tlog
文件 2060 2018-03-21 16:47 Calibration11\Calibration\Debug\Calibration.tlog\li
文件 5196 2018-03-21 16:47 Calibration11\Calibration\Debug\Calibration.tlog\li
文件 398 2018-03-21 16:47 Calibration11\Calibration\Debug\Calibration.tlog\li
文件 379911 2018-03-21 16:47 Calibration11\Calibration\Debug\main.obj
文件 838656 2018-03-21 16:47 Calibration11\Calibration\Debug\vc140.idb
文件 1880064 2018-03-21 16:47 Calibration11\Calibration\Debug\vc140.pdb
文件 39 2018-03-20 17:15 Calibration11\Calibration\distortion_coeffs.txt
文件 259 2018-03-20 17:15 Calibration11\Calibration\distortion_coeffs.xm
文件 1084 2018-03-20 17:15 Calibration11\Calibration\err.txt
文件 1978 2018-03-20 17:15 Calibration11\Calibration\err.xm
文件 27908 2008-10-07 10:00 Calibration11\Calibration\images\1.jpg
文件 27004 2008-10-07 10:00 Calibration11\Calibration\images\10.jpg
文件 27749 2008-10-07 10:00 Calibration11\Calibration\images\11.jpg
文件 25603 2008-10-07 10:00 Calibration11\Calibration\images\12.jpg
文件 28129 2008-10-07 10:00 Calibration11\Calibration\images\13.jpg
文件 27875 2008-10-07 10:00 Calibration11\Calibration\images\14.jpg
文件 27072 2008-10-07 10:00 Calibration11\Calibration\images\15.jpg
文件 27263 2008-10-07 10:00 Calibration11\Calibration\images\16.jpg
............此处省略73个文件信息
评论
共有 条评论