网上全是opencv2的 用也用不了
而且路径什么的很重要 要改成自己的哈!!
读了两次图片calibdata.txt 用的都是jpg 不是bmp
#include <iostream>
#include <fstream>
#include "opencv2/opencv.hpp"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/calib3d/calib3d.hpp>
using namespace std;
int main()
{
ifstream fin("calibdata.txt"); /* 标定所用图像文件的路径 */
ofstream fout("caliberation_result.txt"); /* 保存标定结果的文件 */
if (!fin){
std::cout << "Calibration image txt read failed" << endl;
return 0;
}
//读取每一幅图像,从中提取出角点,然后对角点进行亚像素精确化
std::cout << "开始提取角点………………";
int image_count = 0; /* 图像数量 */
cv::Size image_size; /* 图像的尺寸 */
cv::Size board_size = cv::Size(5,7); /* 标定板上每行、列的角点数 */
vector<cv::Point2f> image_points_buf; /* 缓存每幅图像上检测到的角点 */
vector<vector<cv::Point2f> > image_points_seq; /* 保存检测到的所有角点 */
string filename;
int count = -1;//用于存储角点个数。
while (getline(fin, filename))
{
image_count++;
// 用于观察检验输出
std::cout << "image_count = " << image_count << endl;
/* 输出检验*/
std::cout << "-->count = " << count;
cv::Mat dst = cv::imread(filename);
//cv::Mat imageInput;
//cv::Size dsize = cv::Size(round(0.3 * dst.cols), round(0.3 * dst.rows));
//cv::resize(dst,imageInput,dsize,0,0,CV_INTER_AREA);
if (image_count == 1) //读入第一张图片时获取图像宽高信息
{
image_size.width = dst.cols;
image_size.height = dst.rows;
std::cout << "image_size.width = " << image_size.width << endl;
std::cout << "image_size.height = " << image_size.height << endl;
}
/* 提取角点 */
if (0 == cv::findChessboardCorners(dst, board_size, i