资源简介
基于opencv平台编写的单目相机标定程序,使用的张正友的方法,只要准备十二张单目相机拍摄的棋盘格的图片就可以标定出单目相机的焦距等参数,建立单目相机坐标系。可以用于机器视觉测量中,也可以用于双面相机标定的前一步,精度很高。
代码片段和文件信息
//calib.cpp
//Calling convention:
//calib board_w board_h number_of_views
//
//Hit ‘p‘ to pause/unpause ESC to quit
#include
#include
#include
#include
#include
#include
#include
using namespace std;
int n_boards = 16;//Will be set by input list
const int board_dt = 30;//wait 30 frames per chessboard view
int board_w;
int board_h;
CvSize imageSize = {00};
int main ()
{
board_w = 6;
board_h = 8;
n_boards = 16;
int board_n = board_w * board_h;
CvSize board_sz = cvSize( board_wboard_h );
IplImage *image*gray_image;
char* imageList = “list.txt“;
FILE* f = fopen(imageList “rt“);
//CvCapture* capture = cvCreateCameraCapture(0);
//assert( capture );
cvNamedWindow(“Calibration“);
//ALLOCATE STORAGE
CvMat* image_points = cvCreateMat(n_boards*board_n2CV_32FC1);
CvMat* object_points = cvCreateMat(n_boards*board_n3CV_32FC1);
CvMat* point_counts = cvCreateMat(n_boards1CV_32SC1);
CvMat* intrinsic_matrix = cvCreateMat(33CV_32FC1);
CvMat* distortion_coeffs = cvCreateMat(51CV_32FC1);
CvPoint2D32f* corners = new CvPoint2D32f[ board_n ];
int corner_count;
int successes = 0;
int step frame = 0;
//CAPTURE CORNER VIEWS LOOP UNTIL WE‘VE GOT n_boards
//SUCCESSFUL CAPTURES(ALL CORNERS ON THE BOARD ARE FOUND)
//
while (successes < n_boards){
//Skip every board_dt frames to allow user to move chessboard
if(frame++ % board_dt == 0){
//Find chessboard corners:
char filename[100];
if( !fgets( filename sizeof(filename)-3 f ))
break;
size_t len = strlen(filename);
while( len > 0 && isspace(filename[len-1]))
filename[--len] = ‘\0‘;
if( filename[0] == ‘#‘)
continue;
IplImage* image = cvLoadImage( filename 0);
if( !image )
break;
imageSize = cvGetSize(image);
int found = cvFindChessboardCorners(
image board_sz&corners[0] &corner_count
CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FILTER_QUADS);
//Get Subpixel accuracy on those corners
if( found )
{
cvFindCornerSubPix(image&corners[0]corner_count
cvSize(55)cvSize(-1-1)cvTermCriteria(
CV_TERMCRIT_EPS+CV_TERMCRIT_ITER3000.001));
//Draw it
cvDrawChessboardCorners(imageboard_sz&corners[0]corner_countfound);
cvShowImage(“Calibration“image);
}
//If we got a good board add it to our data
if( corner_count == board_n ){
step = successes*board_n;
for( int i = stepj= 0;j CV_MAT_ELEM(*image_pointsfloati0) = corners[j].x;
CV_MAT_ELEM(*image_pointsfloati1) = corners[j].y;
CV_MAT_ELEM(*object_pointsfloati0) = j/board_w;
CV_MAT_ELEM(*object_pointsfloati1) = j%board_w;
CV_MAT_ELEM(*object_pointsfloati2) = 0.0f;
}
CV_MAT_ELEM(*point_counts int successes0) = board_n;
successes++;
}
}//end skip board_dt between chessboard capture
//Handle pause/u
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 27136 2020-01-30 13:38 danmu\.vs\danmu\v15\.suo
文件 3284992 2020-01-30 13:38 danmu\.vs\danmu\v15\Browse.VC.db
文件 21561344 2020-01-30 13:36 danmu\.vs\danmu\v15\ipch\AutoPCH\DANMU-d6674eff\DANMU-3784a836\DANMU.ipch
文件 6137 2016-08-15 15:14 danmu\danmu\danmu.cpp
文件 4766 2020-01-30 13:35 danmu\danmu\danmu.vcxproj
文件 943 2016-03-01 17:41 danmu\danmu\danmu.vcxproj.filters
文件 221 2020-01-30 13:35 danmu\danmu\danmu.vcxproj.user
文件 654 2016-08-15 15:14 danmu\danmu\Debug\cl.command.1.tlog
文件 20236 2016-08-15 15:14 danmu\danmu\Debug\CL.read.1.tlog
文件 340 2016-08-15 15:14 danmu\danmu\Debug\CL.write.1.tlog
文件 2424 2016-08-15 15:14 danmu\danmu\Debug\danmu.Build.CppClean.log
文件 406 2016-08-15 15:14 danmu\danmu\Debug\danmu.exe.em
文件 472 2016-08-15 15:14 danmu\danmu\Debug\danmu.exe.em
文件 381 2016-08-15 15:14 danmu\danmu\Debug\danmu.exe.intermediate.manifest
文件 76 2016-08-19 09:03 danmu\danmu\Debug\danmu.lastbuildstate
文件 885 2016-08-19 09:03 danmu\danmu\Debug\danmu.log
文件 114216 2016-08-15 15:14 danmu\danmu\Debug\danmu.obj
文件 707 2016-08-19 09:03 danmu\danmu\Debug\danmu.vcxprojResolveAssemblyReference.cache
文件 0 2016-08-15 15:14 danmu\danmu\Debug\danmu.write.1.tlog
文件 200 2016-08-15 15:14 danmu\danmu\Debug\danmu_manifest.rc
文件 2 2016-08-15 15:14 danmu\danmu\Debug\li
文件 2 2016-08-15 15:14 danmu\danmu\Debug\li
文件 2 2016-04-07 11:14 danmu\danmu\Debug\li
文件 2 2016-04-07 11:14 danmu\danmu\Debug\li
文件 2 2016-04-07 11:14 danmu\danmu\Debug\li
文件 2 2016-04-07 11:14 danmu\danmu\Debug\li
文件 2 2016-08-15 15:14 danmu\danmu\Debug\li
文件 2 2016-08-15 15:14 danmu\danmu\Debug\li
文件 2 2016-08-15 15:14 danmu\danmu\Debug\li
文件 2 2016-08-15 15:14 danmu\danmu\Debug\li
............此处省略54个文件信息
- 上一篇:Minecraft多功能压测-假人-motd-srv转发
- 下一篇:LOL防封
相关资源
- OpenCV边缘检测程序 by浅墨
- c++视频教程opencv视频图像处理机器视
- OpenCV单目视觉定位测量C++代码
- YUV数据转换成opencv的Mat的RGB<
- 一种多尺度检测的KCF的python实现代码
- c++二维码识别opencv+zbar
- 图像识别细胞检测与计数系统vc源码
- 通过封装的opencv函数进行yuv.nv12到jp
- OpenCV 中文API官方帮助文档.rar
-
Hob
ject与Mat相互转换C++源代码 比原 - 基于openCV的人体动作跟踪系统(C++)
- 视频转图片(opencv)
- ippicv_2017u3_win_intel64_general_20170822.zip
- opencv:视频图片相互转换程序
- 用opencv处理RTSP视频流,其中视频流的
- Opencv3中SIFT算法详解
- ksj转opencv(USB相机图像数据转OPENCV)
- C++OpenCV实现数字识别
- 3D测量 TCP通信
- 利用opencv,c++画网格代码
- opencv调入显示图片做高斯模糊
- opencv计算信息熵(c++代码)
- opencv2深度图滤波
- opencv harris角点检测
- 基于颜色车牌检测opencv
- opecv+qt 入门级源代码(适合新手)
- QT+opencv打开RTSP视频流多线程
- 基于单片机交流电参数测量仪(Prot
- OpenCV打开本地摄像头并显示
- 基于SVM与BoW的图片分类的OpenCV实现-
评论
共有 条评论