1 程序环境
系统环境:Windows 10;
编译器:Visual Studio 2015;
Opencv版本:Opencv4.1.2版本;
2 原理
主要为张正友标定法,利用棋盘格进行标定,原理参考:https://www.cnblogs.com/zyly/p/9366080.html.
3 程序源码
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
#include <fstream>
using namespace cv;
using namespace std;
/*计算标定板上模块的实际物理坐标*/
void calobjectPoints(vector<Point3f>& obj, Size &boardSize, int squareSize)
{
for (int i = 0; i < boardSize.height; ++i)
for (int j = 0; j < boardSize.width; ++j)
obj.push_back(Point3f((float)(j*squareSize), (float)(i*squareSize), 0.f));
}
void main()
{
Size boardSize = Size(8, 6); // 标定棋盘格的内角点尺寸(如7x7)
float squareSize = 30.0; // 标定板上黑白格子的实际边长(mm)
int nrFrames = 18; // 用于标定的图像数目
string outputFileName; // 输出文件的名称
vector<string> imageList;
Size imageSize;
/****************将存放标定图像的路径读入到imageList(1/2)向量中*********