4,269
社区成员




int main()
{
ifstream fin("caliberation_pics.txt"); // 存放所有标定图片名称的文本
ofstream fout("caliberation_results.txt"); // 用于存放标定结果的文本
// 读取一副标定图像,提取其中的角点并进行亚像素精确化
cout << "开始提取角点" << endl << ">>>" << endl << ">>>" << endl << ">>>" << endl << endl;
int image_count = 0; // 图像的数量
Size image_size; // 图像的大小
Size board_size = Size(11, 8); // 标定板上,每行每列角点的个数
vector<Point2f> corners; // 缓存每幅图像上检测到的角点数据
vector<vector<Point2f>> corners_seq; // 缓存所有检测到的角点序列
string filename; // 用于接收图像的名称
int count = 0; // 存储角点的个数
while (getline(fin, filename)) // 获取文件中每一行的数据,即获取文件中的图像名字
{
cout << filename << endl;
image_count++;
Mat imageInput = imread(filename); // 读取图像
Mat gray_image;
cvtColor(imageInput, gray_image, CV_RGB2GRAY); // 灰度化
cout << "正在读取第" << image_count << "张图像的信息" << endl << ">>>" << endl;
if (image_count > 0)
{
image_size.width = imageInput.cols;
image_size.height = imageInput.rows;
cout << "图像的宽度为: " << image_size.width << endl;
cout << "图像的高度为: " << image_size.height << endl;
cout << "图像的通道数为:" << imageInput.channels() << endl;
}
cout << "正在提取第" << image_count << "张图像的角点" << endl << ">>>" << endl;
// 提取角点
int patternfound = findChessboardCorners(gray_image, board_size, corners, CV_CALIB_CB_ADAPTIVE_THRESH);
cout << corners.size() << endl;
cout << patternfound << endl;
将图像反色可以得到(11,8)的角点阵列