资源简介
参照opencv及网上资料基于opencv3.0编写,标定结果与matlab2015一致,欢迎交流!
代码片段和文件信息
//仅限技术研究,有问题交流436099132@qq.com,请发邮件,勿加qq。以下内容参照《学习opencv》及http://blog.csdn.net/u010784534/article/details/50474371
//感谢以上作者无私奉献,如认为涉嫌侵害您的权益,请联系邮箱,立即改正
//本代码意在技术交流,请勿用做其他目的,转载请保留此文段,谢谢!
#include
#include
#include
#include
#include
#include
#include
#include
using namespace cv;
using namespace std;
int n_boards = 0; //Will be set by input list
const int board_dt = 10;
int board_w;//横角点数
int board_h;//竖焦点数
double count0;
int successImageNum;
vector>corners_Seq;
vectorimage_Seq;
//输入参数 横角点数 竖焦点数 照片目录(txt格式,内容类似./1/1.jpg./1/2.jpg)
int main(int argc char* argv[]) {
if (argc != 4) {
return -1;
}
Size square_size;
square_size.height=square_size.width = 26;//方格有多少mm
board_w = atoi(argv[1]);
board_h = atoi(argv[2]);
int board_n = board_w * board_h;
CvSize board_sz = cvSize(board_w board_h);
cout << board_sz.height<<“ “<< board_sz.width << endl;
FILE *fptr = fopen(argv[3] “r“);
char names[2048];
//COUNT THE NUMBER OF IMAGES:
while (fscanf(fptr “%s “ names) == 1) {
n_boards++;
}
rewind(fptr);
cvNamedWindow(“Calibration“);
//CvMat* image_points = cvCreateMat(n_boards*board_n 2 CV_32FC1);
//CvMat* object_points = cvCreateMat(n_boards*board_n 3 CV_32FC1);
//CvMat* point_counts = cvCreateMat(n_boards 1 CV_32SC1);
/// CvMat * image_points = cvCreateMat(1 n_boards*board_n CV_32FC2);
/// CvMat * object_points = cvCreateMat(1 n_boards*board_n CV_32FC3);
/// CvMat * point_counts = cvCreateMat(1 n_boards CV_32SC1);
//CvMat* intrinsic_matrix = cvCreateMat(3 3 CV_32FC1);
//CvMat* distortion_coeffs = cvCreateMat(4 1 CV_32FC1);
IplImage* image = 0;// = cvQueryframe( capture );
IplImage* gray_image = 0; //for subpixel
CvPoint2D32f* corners = new CvPoint2D32f[board_n];
int corner_count;
int successes = 0;
int step;
cout << n_boards << endl;
for (int i = 0; i != n_boards; i++)
{
fscanf(fptr “%s “ names);
cv::Mat image = imread(names);
Mat image_gray;
cvtColor(image image_gray CV_RGB2GRAY);
vector corners;
bool patternFound = findChessboardCorners(image_gray board_sz
评论
共有 条评论