OpenCV样例calibration

2023-11-06

1. 将图片地址写入到xml

创建工程,运行一下文件:

C:\Program Files\opencv\sources\samples\cpp\imagelist_creator.cpp

cmd运行:cd至\工程目录\x64\Debug>,命令:

 .\工程名.exe imagelist.yaml .rgb1.png rgb2.png rgb3.png rgb4.png rgb5.png rgb6.png rgb7.png rgb8.png rgb9.png rgb10.png rgb11.png rgb12.png

在\工程目录\x64\Debug\目录下有 imagelist.yaml

%YAML:1.0
---
images:
   - "rgb1.png"
   - "rgb2.png"
   - "rgb3.png"
   - "rgb4.png"
   - "rgb5.png"
   - "rgb6.png"
   - "rgb7.png"
   - "rgb8.png"
   - "rgb9.png"
   - "rgb10.png"
   - "rgb11.png"
   - "rgb12.png"

 

2. calibration.cpp

创建工程,运行一下文件:

C:\Program Files\opencv\sources\samples\cpp\imagelist_creator.cpp,有一些兼容的地方进行了修改,其中有  

 cv::CommandLineParser parser(argc, argv,
        "{help ||}{w||}{h||}{pt|chessboard|}{n|10|}{d|1000|}{s|0.025|}{o|out_camera_data.yml|}"
        "{op||}{oe||}{zt||}{a||}{p||}{v||}{V||}{su||}"
        "{oo||}{ws|11|}{dt||}"
        "{@input_data|0|}");:

从运行说明中可知,squaresize的单位是m,该变量不影响内参大小,影响外参。

" \nexample command line for calibration from a live feed.\n"
"   calibration  -w=4 -h=5 -s=0.025 -o=camera.yml -op -oe\n"
" \n"
" example command line for calibration from a list of stored images:\n"
"   imagelist_creator image_list.xml *.png\n"
"   calibration -w=4 -h=5 -s=0.025 -o=camera.yml -op -oe image_list.xml\n"
" where image_list.xml is the standard OpenCV XML/YAML\n"
" use imagelist_creator to create the xml or yaml list\n"

 

cd至\工程目录\x64\Debug>,图像文件也放至该文件夹下,因为imageList.yml文件中没有说明详细地址,默认。

命令:

 .\工程名.exe -w=7 -h=7 -pt=circles  -nframes=12 -su -op -oe imagelist.yaml

#include "opencv2/core.hpp"
#include <opencv2/core/utility.hpp>
#include "opencv2/imgproc.hpp"
#include "opencv2/calib3d.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/videoio.hpp"
#include "opencv2/highgui.hpp"

#include <cctype>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <iostream>

using namespace cv;
using namespace std;

const char* usage =
" \nexample command line for calibration from a live feed.\n"
"   calibration  -w=4 -h=5 -s=0.025 -o=camera.yml -op -oe\n"
" \n"
" example command line for calibration from a list of stored images:\n"
"   imagelist_creator image_list.xml *.png\n"
"   calibration -w=4 -h=5 -s=0.025 -o=camera.yml -op -oe image_list.xml\n"
" where image_list.xml is the standard OpenCV XML/YAML\n"
" use imagelist_creator to create the xml or yaml list\n"
" file consisting of the list of strings, e.g.:\n"
" \n"
"<?xml version=\"1.0\"?>\n"
"<opencv_storage>\n"
"<images>\n"
"view000.png\n"
"view001.png\n"
"<!-- view002.png -->\n"
"view003.png\n"
"view010.png\n"
"one_extra_view.jpg\n"
"</images>\n"
"</opencv_storage>\n";




const char* liveCaptureHelp =
"When the live video from camera is used as input, the following hot-keys may be used:\n"
"  <ESC>, 'q' - quit the program\n"
"  'g' - start capturing images\n"
"  'u' - switch undistortion on/off\n";

static void help()
{
	printf("This is a camera calibration sample.\n"
		"Usage: calibration\n"
		"     -w=<board_width>         # the number of inner corners per one of board dimension\n"
		"     -h=<board_height>        # the number of inner corners per another board dimension\n"
		"     [-pt=<pattern>]          # the type of pattern: chessboard or circles' grid\n"
		"     [-n=<number_of_frames>]  # the number of frames to use for calibration\n"
		"                              # (if not specified, it will be set to the number\n"
		"                              #  of board views actually available)\n"
		"     [-d=<delay>]             # a minimum delay in ms between subsequent attempts to capture a next view\n"
		"                              # (used only for video capturing)\n"
		"     [-s=<squareSize>]       # square size in some user-defined units (1 by default)\n"
		"     [-o=<out_camera_params>] # the output filename for intrinsic [and extrinsic] parameters\n"
		"     [-op]                    # write detected feature points\n"
		"     [-oe]                    # write extrinsic parameters\n"
		"     [-oo]                    # write refined 3D object points\n"
		"     [-zt]                    # assume zero tangential distortion\n"
		"     [-a=<aspectRatio>]      # fix aspect ratio (fx/fy)\n"
		"     [-p]                     # fix the principal point at the center\n"
		"     [-v]                     # flip the captured images around the horizontal axis\n"
		"     [-V]                     # use a video file, and not an image list, uses\n"
		"                              # [input_data] string for the video file name\n"
		"     [-su]                    # show undistorted images after calibration\n"
		"     [-ws=<number_of_pixel>]  # Half of search window for cornerSubPix (11 by default)\n"
		"     [-dt=<distance>]         # actual distance between top-left and top-right corners of\n"
		"                              # the calibration grid. If this parameter is specified, a more\n"
		"                              # accurate calibration method will be used which may be better\n"
		"                              # with inaccurate, roughly planar target.\n"
		"     [input_data]             # input data, one of the following:\n"
		"                              #  - text file with a list of the images of the board\n"
		"                              #    the text file can be generated with imagelist_creator\n"
		"                              #  - name of video file with a video of the board\n"
		"                              # if input_data not specified, a live view from the camera is used\n"
		"\n");
	printf("\n%s", usage);
	printf("\n%s", liveCaptureHelp);
}

enum { DETECTION = 0, CAPTURING = 1, CALIBRATED = 2 };
enum Pattern { CHESSBOARD, CIRCLES_GRID, ASYMMETRIC_CIRCLES_GRID };

static double computeReprojectionErrors(
	const vector<vector<Point3f> >& objectPoints,
	const vector<vector<Point2f> >& imagePoints,
	const vector<Mat>& rvecs, const vector<Mat>& tvecs,
	const Mat& cameraMatrix, const Mat& distCoeffs,
	vector<float>& perViewErrors)
{
	vector<Point2f> imagePoints2;
	int i, totalPoints = 0;
	double totalErr = 0, err;
	perViewErrors.resize(objectPoints.size());

	for (i = 0; i < (int)objectPoints.size(); i++)
	{
		projectPoints(Mat(objectPoints[i]), rvecs[i], tvecs[i],
			cameraMatrix, distCoeffs, imagePoints2);
		err = norm(Mat(imagePoints[i]), Mat(imagePoints2), NORM_L2);
		int n = (int)objectPoints[i].size();
		perViewErrors[i] = (float)std::sqrt(err * err / n);
		totalErr += err * err;
		totalPoints += n;
	}

	return std::sqrt(totalErr / totalPoints);
}

static void calcChessboardCorners(Size boardSize, float squareSize, vector<Point3f>& corners, Pattern patternType = CHESSBOARD)
{
	corners.resize(0);

	switch (patternType)
	{
	case CHESSBOARD:
	case CIRCLES_GRID:
		for (int i = 0; i < boardSize.height; i++)
			for (int j = 0; j < boardSize.width; j++)
				corners.push_back(Point3f(float(j * squareSize),
					float(i * squareSize), 0));
		break;

	case ASYMMETRIC_CIRCLES_GRID:
		for (int i = 0; i < boardSize.height; i++)
			for (int j = 0; j < boardSize.width; j++)
				corners.push_back(Point3f(float((2 * j + i % 2) * squareSize),
					float(i * squareSize), 0));
		break;

	default:
		CV_Error(Error::StsBadArg, "Unknown pattern type\n");
	}
}

static bool runCalibration(vector<vector<Point2f> > imagePoints,
	Size imageSize, Size boardSize, Pattern patternType,
	float squareSize, float aspectRatio,
	float grid_width, bool release_object,
	int flags, Mat& cameraMatrix, Mat& distCoeffs,
	vector<Mat>& rvecs, vector<Mat>& tvecs,
	vector<float>& reprojErrs,
	vector<Point3f>& newObjPoints,
	double& totalAvgErr)
{
	cameraMatrix = Mat::eye(3, 3, CV_64F);
	if (flags & CALIB_FIX_ASPECT_RATIO)
		cameraMatrix.at<double>(0, 0) = aspectRatio;

	distCoeffs = Mat::zeros(8, 1, CV_64F);

	vector<vector<Point3f> > objectPoints(1);
	calcChessboardCorners(boardSize, squareSize, objectPoints[0], patternType);
	objectPoints[0][boardSize.width - 1].x = objectPoints[0][0].x + grid_width;
	newObjPoints = objectPoints[0];

	objectPoints.resize(imagePoints.size(), objectPoints[0]);

	double rms;
	int iFixedPoint = -1;
	if (release_object)
		iFixedPoint = boardSize.width - 1;
	rms = calibrateCameraRO(objectPoints, imagePoints, imageSize, iFixedPoint,
		cameraMatrix, distCoeffs, rvecs, tvecs, newObjPoints,
		flags | CALIB_FIX_K3 | CALIB_USE_LU);
	printf("RMS error reported by calibrateCamera: %g\n", rms);

	bool ok = checkRange(cameraMatrix) && checkRange(distCoeffs);

	if (release_object) {
		cout << "New board corners: " << endl;
		cout << newObjPoints[0] << endl;
		cout << newObjPoints[boardSize.width - 1] << endl;
		cout << newObjPoints[boardSize.width * (boardSize.height - 1)] << endl;
		cout << newObjPoints.back() << endl;
	}

	objectPoints.clear();
	objectPoints.resize(imagePoints.size(), newObjPoints);
	totalAvgErr = computeReprojectionErrors(objectPoints, imagePoints,
		rvecs, tvecs, cameraMatrix, distCoeffs, reprojErrs);

	return ok;
}


static void saveCameraParams(const string& filename,
	Size imageSize, Size boardSize,
	float squareSize, float aspectRatio, int flags,
	const Mat& cameraMatrix, const Mat& distCoeffs,
	const vector<Mat>& rvecs, const vector<Mat>& tvecs,
	const vector<float>& reprojErrs,
	const vector<vector<Point2f> >& imagePoints,
	const vector<Point3f>& newObjPoints,
	double totalAvgErr)
{
	FileStorage fs(filename, FileStorage::WRITE);

	time_t tt;
	time(&tt);
	//struct tm* t2 = localtime(&tt);
	struct tm t2;
	localtime_s(&t2, &tt);
	char buf[1024];
	strftime(buf, sizeof(buf) - 1, "%c", &t2);

	fs << "calibration_time" << buf;

	if (!rvecs.empty() || !reprojErrs.empty())
		fs << "nframes" << (int)std::max(rvecs.size(), reprojErrs.size());
	fs << "image_width" << imageSize.width;
	fs << "image_height" << imageSize.height;
	fs << "board_width" << boardSize.width;
	fs << "board_height" << boardSize.height;
	fs << "square_size" << squareSize;

	if (flags & CALIB_FIX_ASPECT_RATIO)
		fs << "aspectRatio" << aspectRatio;

	if (flags != 0)
	{
		sprintf_s(buf, "flags: %s%s%s%s",
			flags & CALIB_USE_INTRINSIC_GUESS ? "+use_intrinsic_guess" : "",
			flags & CALIB_FIX_ASPECT_RATIO ? "+fix_aspectRatio" : "",
			flags & CALIB_FIX_PRINCIPAL_POINT ? "+fix_principal_point" : "",
			flags & CALIB_ZERO_TANGENT_DIST ? "+zero_tangent_dist" : "");
		//cvWriteComment( *fs, buf, 0 );
	}

	fs << "flags" << flags;

	fs << "camera_matrix" << cameraMatrix;
	fs << "distortion_coefficients" << distCoeffs;

	fs << "avg_reprojection_error" << totalAvgErr;
	if (!reprojErrs.empty())
		fs << "per_view_reprojection_errors" << Mat(reprojErrs);

	if (!rvecs.empty() && !tvecs.empty())
	{
		CV_Assert(rvecs[0].type() == tvecs[0].type());
		Mat bigmat((int)rvecs.size(), 6, rvecs[0].type());
		Mat rotation_matrix = Mat(3, 3, CV_32FC1, Scalar::all(0)); /* 保存每幅图像的旋转矩阵 */
		for (int i = 0; i < (int)rvecs.size(); i++)
		{
			Mat r = bigmat(Range(i, i + 1), Range(0, 3));
			Mat t = bigmat(Range(i, i + 1), Range(3, 6));

			CV_Assert(rvecs[i].rows == 3 && rvecs[i].cols == 1);
			CV_Assert(tvecs[i].rows == 3 && tvecs[i].cols == 1);
			//*.t() is MatExpr (not Mat) so we can use assignment operator
			r = rvecs[i].t();
			t = tvecs[i].t();
			//旋转向量转为旋转矩阵
			Rodrigues(rvecs[i], rotation_matrix);
			fs <<"rotation_matrix"<< rotation_matrix;
		}
		//cvWriteComment( *fs, "a set of 6-tuples (rotation vector + translation vector) for each view", 0 );
		fs << "extrinsic_parameters" << bigmat;
	}

	if (!imagePoints.empty())
	{
		Mat imagePtMat((int)imagePoints.size(), (int)imagePoints[0].size(), CV_32FC2);
		for (int i = 0; i < (int)imagePoints.size(); i++)
		{
			Mat r = imagePtMat.row(i).reshape(2, imagePtMat.cols);
			Mat imgpti(imagePoints[i]);
			imgpti.copyTo(r);
		}
		fs << "image_points" << imagePtMat;
	}

	if (!newObjPoints.empty())
	{
		fs << "grid_points" << newObjPoints;
	}
}

static bool readStringList(const string& filename, vector<string>& l)
{
	l.resize(0);
	FileStorage fs(filename, FileStorage::READ);
	if (!fs.isOpened())
		return false;
	size_t dir_pos = filename.rfind('/');
	if (dir_pos == string::npos)
		dir_pos = filename.rfind('\\');
	FileNode n = fs.getFirstTopLevelNode();
	if (n.type() != FileNode::SEQ)
		return false;
	FileNodeIterator it = n.begin(), it_end = n.end();
	for (; it != it_end; ++it)
	{
		string fname = (string)* it;
		if (dir_pos != string::npos)
		{
			string fpath = samples::findFile(filename.substr(0, dir_pos + 1) + fname, false);
			if (fpath.empty())
			{
				fpath = samples::findFile(fname);
			}
			fname = fpath;
		}
		else
		{
			fname = samples::findFile(fname);
		}
		l.push_back(fname);
	}
	return true;
}


static bool runAndSave(const string& outputFilename,
	const vector<vector<Point2f> >& imagePoints,
	Size imageSize, Size boardSize, Pattern patternType, float squareSize,
	float grid_width, bool release_object,
	float aspectRatio, int flags, Mat& cameraMatrix,
	Mat& distCoeffs, bool writeExtrinsics, bool writePoints, bool writeGrid)
{
	vector<Mat> rvecs, tvecs;
	vector<float> reprojErrs;
	double totalAvgErr = 0;
	vector<Point3f> newObjPoints;

	bool ok = runCalibration(imagePoints, imageSize, boardSize, patternType, squareSize,
		aspectRatio, grid_width, release_object, flags, cameraMatrix, distCoeffs,
		rvecs, tvecs, reprojErrs, newObjPoints, totalAvgErr);
	printf("%s. avg reprojection error = %.7f\n",
		ok ? "Calibration succeeded" : "Calibration failed",
		totalAvgErr);

	if (ok)
		saveCameraParams(outputFilename, imageSize,
			boardSize, squareSize, aspectRatio,
			flags, cameraMatrix, distCoeffs,
			writeExtrinsics ? rvecs : vector<Mat>(),
			writeExtrinsics ? tvecs : vector<Mat>(),
			writeExtrinsics ? reprojErrs : vector<float>(),
			writePoints ? imagePoints : vector<vector<Point2f> >(),
			writeGrid ? newObjPoints : vector<Point3f>(),
			totalAvgErr);
	return ok;
}


int main(int argc, char** argv)
{
	Size boardSize, imageSize;
	float squareSize = 0.025, aspectRatio = 1;
	Mat cameraMatrix, distCoeffs;
	string outputFilename;
	string inputFilename = "";

	int i, nframes;
	bool writeExtrinsics, writePoints;
	bool undistortImage = false;
	int flags = 0;
	VideoCapture capture;
	bool flipVertical;
	bool showUndistorted;
	bool videofile;
	int delay;
	clock_t prevTimestamp = 0;
	int mode = DETECTION;
	int cameraId = 0;
	vector<vector<Point2f> > imagePoints;
	vector<string> imageList;
	Pattern pattern = CHESSBOARD;

	cv::CommandLineParser parser(argc, argv,
		"{help ||}{w||}{h||}{pt|chessboard|}{n|10|}{d|1000|}{s|0.025|}{o|out_camera_data.yml|}"
		"{op||}{oe||}{zt||}{a||}{p||}{v||}{V||}{su||}"
		"{oo||}{ws|11|}{dt||}"
		"{@input_data|0|}");
	if (parser.has("help"))
	{
		help();
		return 0;
	}
	boardSize.width = parser.get<int>("w");
	boardSize.height = parser.get<int>("h");
	if (parser.has("pt"))
	{
		string val = parser.get<string>("pt");
		if (val == "circles")
			pattern = CIRCLES_GRID;
		else if (val == "acircles")
			pattern = ASYMMETRIC_CIRCLES_GRID;
		else if (val == "chessboard")
			pattern = CHESSBOARD;
		else
			return fprintf(stderr, "Invalid pattern type: must be chessboard or circles\n"), -1;
	}
	squareSize = parser.get<float>("s");
	nframes = parser.get<int>("n");
	delay = parser.get<int>("d");
	writePoints = parser.has("op");
	writeExtrinsics = parser.has("oe");
	bool writeGrid = parser.has("oo");
	if (parser.has("a")) {
		flags |= CALIB_FIX_ASPECT_RATIO;
		aspectRatio = parser.get<float>("a");
	}
	if (parser.has("zt"))
		flags |= CALIB_ZERO_TANGENT_DIST;
	if (parser.has("p"))
		flags |= CALIB_FIX_PRINCIPAL_POINT;
	flipVertical = parser.has("v");
	videofile = parser.has("V");
	if (parser.has("o"))
		outputFilename = parser.get<string>("o");
	showUndistorted = parser.has("su");
	if (isdigit(parser.get<string>("@input_data")[0]))
		cameraId = parser.get<int>("@input_data");
	else
		inputFilename = parser.get<string>("@input_data");
	int winSize = parser.get<int>("ws");
	float grid_width = squareSize * (boardSize.width - 1);
	bool release_object = false;
	if (parser.has("dt")) {
		grid_width = parser.get<float>("dt");
		release_object = true;
	}
	if (!parser.check())
	{
		help();
		parser.printErrors();
		return -1;
	}
	if (squareSize <= 0)
		return fprintf(stderr, "Invalid board square width\n"), -1;
	if (nframes <= 3)
		return printf("Invalid number of images\n"), -1;
	if (aspectRatio <= 0)
		return printf("Invalid aspect ratio\n"), -1;
	if (delay <= 0)
		return printf("Invalid delay\n"), -1;
	if (boardSize.width <= 0)
		return fprintf(stderr, "Invalid board width\n"), -1;
	if (boardSize.height <= 0)
		return fprintf(stderr, "Invalid board height\n"), -1;

	if (!inputFilename.empty())
	{
		if (!videofile && readStringList(samples::findFile(inputFilename), imageList))
			mode = CAPTURING;
		else
			capture.open(samples::findFileOrKeep(inputFilename));
	}
	else
		capture.open(cameraId);

	if (!capture.isOpened() && imageList.empty())
		return fprintf(stderr, "Could not initialize video (%d) capture\n", cameraId), -2;

	if (!imageList.empty())
		nframes = (int)imageList.size();

	if (capture.isOpened())
		printf("%s", liveCaptureHelp);

	namedWindow("Image View", 1);

	for (i = 0;; i++)
	{
		Mat view, viewGray;
		bool blink = false;

		if (capture.isOpened())
		{
			Mat view0;
			capture >> view0;
			view0.copyTo(view);
		}
		else if (i < (int)imageList.size())
			view = imread(imageList[i], 1);

		if (view.empty())
		{
			if (imagePoints.size() > 0)
				runAndSave(outputFilename, imagePoints, imageSize,
					boardSize, pattern, squareSize, grid_width, release_object, aspectRatio,
					flags, cameraMatrix, distCoeffs,
					writeExtrinsics, writePoints, writeGrid);
			break;
		}

		imageSize = view.size();

		if (flipVertical)
			flip(view, view, 0);

		vector<Point2f> pointbuf;
		cvtColor(view, viewGray, COLOR_BGR2GRAY);

		bool found;
		switch (pattern)
		{
		case CHESSBOARD:
			found = findChessboardCorners(view, boardSize, pointbuf,
				CALIB_CB_ADAPTIVE_THRESH | CALIB_CB_FAST_CHECK | CALIB_CB_NORMALIZE_IMAGE);
			break;
		case CIRCLES_GRID:
			found = findCirclesGrid(view, boardSize, pointbuf);
			break;
		case ASYMMETRIC_CIRCLES_GRID:
			found = findCirclesGrid(view, boardSize, pointbuf, CALIB_CB_ASYMMETRIC_GRID);
			break;
		default:
			return fprintf(stderr, "Unknown pattern type\n"), -1;
		}

		// improve the found corners' coordinate accuracy
		if (pattern == CHESSBOARD && found) cornerSubPix(viewGray, pointbuf, Size(winSize, winSize),
			Size(-1, -1), TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 30, 0.0001));

		if (mode == CAPTURING && found &&
			(!capture.isOpened() || clock() - prevTimestamp > delay * 1e-3 * CLOCKS_PER_SEC))
		{
			imagePoints.push_back(pointbuf);
			prevTimestamp = clock();
			blink = capture.isOpened();
		}

		if (found)
			drawChessboardCorners(view, boardSize, Mat(pointbuf), found);

		string msg = mode == CAPTURING ? "100/100" :
			mode == CALIBRATED ? "Calibrated" : "Press 'g' to start";
		int baseLine = 0;
		Size textSize = getTextSize(msg, 1, 1, 1, &baseLine);
		Point textOrigin(view.cols - 2 * textSize.width - 10, view.rows - 2 * baseLine - 10);

		if (mode == CAPTURING)
		{
			if (undistortImage)
				msg = format("%d/%d Undist", (int)imagePoints.size(), nframes);
			else
				msg = format("%d/%d", (int)imagePoints.size(), nframes);
		}

		putText(view, msg, textOrigin, 1, 1,
			mode != CALIBRATED ? Scalar(0, 0, 255) : Scalar(0, 255, 0));

		if (blink)
			bitwise_not(view, view);

		if (mode == CALIBRATED && undistortImage)
		{
			Mat temp = view.clone();
			undistort(temp, view, cameraMatrix, distCoeffs);
		}

		imshow("Image View", view);
		char key = (char)waitKey(capture.isOpened() ? 50 : 500);

		if (key == 27)
			break;

		if (key == 'u' && mode == CALIBRATED)
			undistortImage = !undistortImage;

		if (capture.isOpened() && key == 'g')
		{
			mode = CAPTURING;
			imagePoints.clear();
		}

		if (mode == CAPTURING && imagePoints.size() >= (unsigned)nframes)
		{
			if (runAndSave(outputFilename, imagePoints, imageSize,
				boardSize, pattern, squareSize, grid_width, release_object, aspectRatio,
				flags, cameraMatrix, distCoeffs,
				writeExtrinsics, writePoints, writeGrid))
				mode = CALIBRATED;
			else
				mode = DETECTION;
			if (!capture.isOpened())
				break;
		}
	}

	if (!capture.isOpened() && showUndistorted)
	{
		Mat view, rview, map1, map2;
		initUndistortRectifyMap(cameraMatrix, distCoeffs, Mat(),
			getOptimalNewCameraMatrix(cameraMatrix, distCoeffs, imageSize, 1, imageSize, 0),
			imageSize, CV_16SC2, map1, map2);

		for (i = 0; i < (int)imageList.size(); i++)
		{
			view = imread(imageList[i], 1);
			if (view.empty())
				continue;
			//undistort( view, rview, cameraMatrix, distCoeffs, cameraMatrix );
			remap(view, rview, map1, map2, INTER_LINEAR);
			imshow("Image View", rview);
			char c = (char)waitKey();
			if (c == 27 || c == 'q' || c == 'Q')
				break;
		}
	}

	return 0;
}

3. 结果

在 \工程目录\x64\Debug,有

out_camera_data.yml

内容如下:

%YAML:1.0
---
calibration_time: "Fri Jan  1 11:19:48 2021"
nframes: 12
image_width: 640
image_height: 480
board_width: 7
board_height: 7
square_size: 2.5000000372529030e-02
flags: 0
camera_matrix: !!opencv-matrix
   rows: 3
   cols: 3
   dt: d
   data: [ 6.1568832966736795e+02, 0., 3.2063453265884039e+02, 0.,
       6.1580682005477615e+02, 2.4369374006989941e+02, 0., 0., 1. ]
distortion_coefficients: !!opencv-matrix
   rows: 5
   cols: 1
   dt: d
   data: [ 1.4275765748892966e-01, -3.2288104969062498e-01,
       -1.2169973640115464e-03, 2.2612283211429729e-04, 0. ]
avg_reprojection_error: 7.3632204716641572e-02
per_view_reprojection_errors: !!opencv-matrix
   rows: 12
   cols: 1
   dt: f
   data: [ 9.29096043e-02, 7.52600208e-02, 7.58743286e-02,
       6.73700422e-02, 5.96404001e-02, 4.60375026e-02, 5.71658425e-02,
       1.08372070e-01, 5.05186506e-02, 5.64781688e-02, 6.00151420e-02,
       1.02156319e-01 ]
extrinsic_parameters: !!opencv-matrix
   rows: 12
   cols: 6
   dt: d
   data: [ -4.9109747854222757e-01, 1.3053100894851183e-01,
       7.2013601900280472e-02, 1.2766764573390105e-01,
       3.1984568411210924e-02, 6.6210048644258235e-01,
       -3.1413839763517970e-01, -1.9941096718783635e-01,
       3.1670918363911983e-02, 1.3711061814608953e-02,
       1.8347599879421753e-02, 5.8700779728490315e-01,
       -2.9556844900993640e-01, 4.1757795063344677e-02,
       1.8937997294930140e-01, -2.2244396740317207e-01,
       1.1402965853973900e-02, 6.2485391926274958e-01,
       9.1163022836795338e-02, 4.8059483519461887e-01,
       5.2343477424411020e-02, 1.7404904050178022e-01,
       -9.5371739482059820e-02, 7.8240445201468201e-01,
       9.2823379395826203e-02, 4.8320325339104325e-01,
       4.7652563049189571e-02, 5.8299522509077092e-02,
       -1.0324790381237205e-01, 8.0947837273675038e-01,
       7.7286319946993157e-02, 1.5161015374981315e-01,
       -7.7595834082769530e-02, -2.6032401355888596e-01,
       -9.5193128275637182e-02, 8.1945137699395842e-01,
       1.2366140954819739e-01, -5.0595476868473412e-02,
       -9.8223757187174562e-02, -3.7272790914499754e-01,
       -8.1851366548550658e-02, 7.9869662532629182e-01,
       1.6148912778701993e-01, 3.8868086491264636e-01,
       -5.7711123845210818e-03, 1.9278298340768288e-01,
       -2.5684130972390068e-01, 7.6805322354623518e-01,
       1.6710630292915185e-01, 7.8316060951803421e-02,
       -1.6015387747208285e-01, -9.8564470005915866e-03,
       -2.5288867311664770e-01, 7.8140162873265773e-01,
       -3.8773661896619335e-02, 6.2144095181130243e-01,
       1.1095508511116815e-01, -1.3440918075419125e-01,
       -2.7609974526083525e-01, 8.6890310998576892e-01,
       3.7136770633854260e-01, -9.8094831018621292e-02,
       -4.6230723102282496e-02, -2.9410532357091534e-01,
       -2.8299980876034025e-01, 8.3966857143509899e-01,
       3.4895801313469360e-01, -2.8392310898048390e-01,
       -6.7502734339331807e-02, -3.9310914209986952e-01,
       -2.7547880582226242e-01, 8.3205127466245454e-01 ]
image_points: !!opencv-matrix
   rows: 12
   cols: 49
   dt: "2f"
   data: [ 4.40031403e+02, 2.73592712e+02, 4.64072693e+02,
       2.74655792e+02, 4.88594604e+02, 2.75732269e+02, 5.13489990e+02,
       2.76844666e+02, 5.38735229e+02, 2.77982483e+02, 5.64328369e+02,
       2.79146484e+02, 5.90104797e+02, 2.80262695e+02, 4.39825562e+02,
       2.95057129e+02, 4.64262512e+02, 2.96315369e+02, 4.89275848e+02,
       2.97587402e+02, 5.14469849e+02, 2.98966553e+02, 5.40363953e+02,
       3.00277100e+02, 5.66396545e+02, 3.01438293e+02, 5.92514954e+02,
       3.02786377e+02, 4.39632355e+02, 3.17350586e+02, 4.64571838e+02,
       3.18780518e+02, 4.89883301e+02, 3.20290283e+02, 5.15825623e+02,
       3.21766327e+02, 5.42075684e+02, 3.23338043e+02, 5.68618591e+02,
       3.24791473e+02, 5.95081116e+02, 3.26085571e+02, 4.39379669e+02,
       3.40486298e+02, 4.64839600e+02, 3.42143280e+02, 4.90847687e+02,
       3.43753632e+02, 5.17218506e+02, 3.45508423e+02, 5.43939453e+02,
       3.47224579e+02, 5.70767883e+02, 3.48808136e+02, 5.97721558e+02,
       3.50418701e+02, 4.39330597e+02, 3.64611908e+02, 4.65245483e+02,
       3.66424683e+02, 4.91767883e+02, 3.68357208e+02, 5.18612122e+02,
       3.70242584e+02, 5.45690002e+02, 3.72103729e+02, 5.72973267e+02,
       3.73916595e+02, 6.00401855e+02, 3.75590668e+02, 4.39231812e+02,
       3.89741333e+02, 4.65705536e+02, 3.91749878e+02, 4.92645050e+02,
       3.93861328e+02, 5.19990051e+02, 3.96049896e+02, 5.47480591e+02,
       3.98155548e+02, 5.75245850e+02, 3.99829956e+02, 6.03070740e+02,
       4.01657196e+02, 4.39008240e+02, 4.15924255e+02, 4.66199188e+02,
       4.18130096e+02, 4.93540833e+02, 4.20447052e+02, 5.21469482e+02,
       4.22695984e+02, 5.49418518e+02, 4.24832001e+02, 5.77635742e+02,
       4.26930786e+02, 6.05804688e+02, 4.28752686e+02, 3.35077515e+02,
       2.62994568e+02, 3.60474152e+02, 2.64360840e+02, 3.85568268e+02,
       2.65816437e+02, 4.10306885e+02, 2.67265747e+02, 4.34689209e+02,
       2.68691498e+02, 4.58814636e+02, 2.70072632e+02, 4.82662170e+02,
       2.71489563e+02, 3.35277161e+02, 2.88541260e+02, 3.61029907e+02,
       2.89844269e+02, 3.86434845e+02, 2.91071228e+02, 4.11439301e+02,
       2.92404114e+02, 4.36209839e+02, 2.93615723e+02, 4.60665527e+02,
       2.94867767e+02, 4.84819244e+02, 2.96179260e+02, 3.35452271e+02,
       3.14910858e+02, 3.61527161e+02, 3.15988342e+02, 3.87307495e+02,
       3.17062683e+02, 4.12728394e+02, 3.18145172e+02, 4.37822479e+02,
       3.19238068e+02, 4.62607025e+02, 3.20369476e+02, 4.87082306e+02,
       3.21487427e+02, 3.35615387e+02, 3.41960358e+02, 3.62173492e+02,
       3.42867920e+02, 3.88299500e+02, 3.43759735e+02, 4.14080597e+02,
       3.44699829e+02, 4.39449707e+02, 3.45645203e+02, 4.64614288e+02,
       3.46652100e+02, 4.89430573e+02, 3.47609924e+02, 3.35849365e+02,
       3.69912933e+02, 3.62824097e+02, 3.70570099e+02, 3.89337646e+02,
       3.71311249e+02, 4.15495392e+02, 3.72060913e+02, 4.41325287e+02,
       3.72842560e+02, 4.66729340e+02, 3.73647491e+02, 4.91976440e+02,
       3.74460663e+02, 3.36092621e+02, 3.98821014e+02, 3.63464783e+02,
       3.99197327e+02, 3.90438721e+02, 3.99785858e+02, 4.17002289e+02,
       4.00359924e+02, 4.43068085e+02, 4.00935730e+02, 4.69094971e+02,
       4.01543549e+02, 4.94525452e+02, 4.02184479e+02, 3.36346497e+02,
       4.28747314e+02, 3.64188751e+02, 4.28930969e+02, 3.91598022e+02,
       4.29237122e+02, 4.18618927e+02, 4.29539215e+02, 4.45181580e+02,
       4.29928680e+02, 4.71373108e+02, 4.30228546e+02, 4.97077179e+02,
       4.30501740e+02, 9.86015396e+01, 2.54997055e+02, 1.23016525e+02,
       2.59530182e+02, 1.47389801e+02, 2.64027954e+02, 1.71694107e+02,
       2.68496460e+02, 1.96105530e+02, 2.73030273e+02, 2.20560257e+02,
       2.77618164e+02, 2.44927948e+02, 2.82196838e+02, 9.11160049e+01,
       2.78779541e+02, 1.15629097e+02, 2.83401215e+02, 1.40303345e+02,
       2.87977081e+02, 1.65066772e+02, 2.92617310e+02, 1.89707458e+02,
       2.97227600e+02, 2.14422623e+02, 3.01833191e+02, 2.39180893e+02,
       3.06585999e+02, 8.34117050e+01, 3.03233337e+02, 1.08148987e+02,
       3.07919037e+02, 1.33097031e+02, 3.12648499e+02, 1.58153763e+02,
       3.17307892e+02, 1.83237396e+02, 3.22083923e+02, 2.08243927e+02,
       3.26787659e+02, 2.33283875e+02, 3.31520416e+02, 7.55231018e+01,
       3.28294983e+02, 1.00486496e+02, 3.33109650e+02, 1.25670258e+02,
       3.37898254e+02, 1.51023621e+02, 3.42733917e+02, 1.76302231e+02,
       3.47506073e+02, 2.01716736e+02, 3.52349304e+02, 2.27061859e+02,
       3.57264160e+02, 6.75040207e+01, 3.53897919e+02, 9.26782837e+01,
       3.58904175e+02, 1.18075378e+02, 3.63909058e+02, 1.43619354e+02,
       3.68806763e+02, 1.69314377e+02, 3.73693817e+02, 1.94873734e+02,
       3.78683228e+02, 2.20634399e+02, 3.83717926e+02, 5.93850365e+01,
       3.80194489e+02, 8.46972809e+01, 3.85371796e+02, 1.10247345e+02,
       3.90480225e+02, 1.35992554e+02, 3.95520538e+02, 1.61910706e+02,
       4.00632660e+02, 1.87941650e+02, 4.05773590e+02, 2.14027954e+02,
       4.10933319e+02, 5.11562500e+01, 4.06967529e+02, 7.67105865e+01,
       4.12224670e+02, 1.02361351e+02, 4.17651886e+02, 1.28341354e+02,
       4.23071320e+02, 1.54515350e+02, 4.28345062e+02, 1.80839050e+02,
       4.33642670e+02, 2.07308609e+02, 4.38961456e+02, 4.58720367e+02,
       1.68043045e+02, 4.78804413e+02, 1.68301117e+02, 4.99594116e+02,
       1.68420044e+02, 5.21115051e+02, 1.68619064e+02, 5.43309814e+02,
       1.68746201e+02, 5.66252991e+02, 1.68968460e+02, 5.89727966e+02,
       1.69289627e+02, 4.57629395e+02, 1.87964462e+02, 4.77594421e+02,
       1.88510559e+02, 4.98306610e+02, 1.88981369e+02, 5.19707275e+02,
       1.89524048e+02, 5.41861206e+02, 1.90046768e+02, 5.64682739e+02,
       1.90660355e+02, 5.88114258e+02, 1.91360748e+02, 4.56546326e+02,
       2.07800568e+02, 4.76418854e+02, 2.08596375e+02, 4.97017975e+02,
       2.09434830e+02, 5.18317322e+02, 2.10331116e+02, 5.40380859e+02,
       2.11220062e+02, 5.63148865e+02, 2.12205536e+02, 5.86527710e+02,
       2.13158493e+02, 4.55508423e+02, 2.27401413e+02, 4.75322205e+02,
       2.28513824e+02, 4.95806183e+02, 2.29713654e+02, 5.16973572e+02,
       2.30927979e+02, 5.38937927e+02, 2.32198776e+02, 5.61613892e+02,
       2.33498215e+02, 5.84921387e+02, 2.34876328e+02, 4.54495270e+02,
       2.46854187e+02, 4.74197815e+02, 2.48322083e+02, 4.94620728e+02,
       2.49811249e+02, 5.15687317e+02, 2.51424484e+02, 5.37563782e+02,
       2.52989990e+02, 5.60128723e+02, 2.54659531e+02, 5.83368652e+02,
       2.56476349e+02, 4.53501556e+02, 2.66197693e+02, 4.73135529e+02,
       2.67973724e+02, 4.93463013e+02, 2.69764496e+02, 5.14484863e+02,
       2.71664124e+02, 5.36199585e+02, 2.73661224e+02, 5.58680115e+02,
       2.75699585e+02, 5.81783020e+02, 2.77746307e+02, 4.52573456e+02,
       2.85396179e+02, 4.72114471e+02, 2.87474213e+02, 4.92366425e+02,
       2.89652191e+02, 5.13161560e+02, 2.91905975e+02, 5.34907837e+02,
       2.94241852e+02, 5.57287720e+02, 2.96578918e+02, 5.80248962e+02,
       2.98937012e+02, 3.65047913e+02, 1.64879089e+02, 3.82883087e+02,
       1.64983261e+02, 4.01240662e+02, 1.65144119e+02, 4.20222717e+02,
       1.65234375e+02, 4.39841705e+02, 1.65256744e+02, 4.60137146e+02,
       1.65346542e+02, 4.81110321e+02, 1.65458969e+02, 3.64439026e+02,
       1.84018417e+02, 3.82194000e+02, 1.84416733e+02, 4.00484406e+02,
       1.84868927e+02, 4.19345520e+02, 1.85302139e+02, 4.38882843e+02,
       1.85727615e+02, 4.59037292e+02, 1.86117966e+02, 4.79942413e+02,
       1.86597641e+02, 3.63847137e+02, 2.03082779e+02, 3.81516693e+02,
       2.03832260e+02, 3.99761993e+02, 2.04533142e+02, 4.18532257e+02,
       2.05260773e+02, 4.37906616e+02, 2.06000946e+02, 4.57975494e+02,
       2.06787735e+02, 4.78758057e+02, 2.07528763e+02, 3.63272186e+02,
       2.22072693e+02, 3.80902100e+02, 2.23011398e+02, 3.99026947e+02,
       2.24021683e+02, 4.17695190e+02, 2.25053802e+02, 4.37027313e+02,
       2.26085510e+02, 4.56990967e+02, 2.27159302e+02, 4.77644287e+02,
       2.28335281e+02, 3.62683929e+02, 2.40853699e+02, 3.80207123e+02,
       2.42093399e+02, 3.98281555e+02, 2.43365616e+02, 4.16901306e+02,
       2.44726227e+02, 4.36138763e+02, 2.46062057e+02, 4.56026581e+02,
       2.47451767e+02, 4.76593353e+02, 2.48895981e+02, 3.62114319e+02,
       2.59555542e+02, 3.79584595e+02, 2.61046478e+02, 3.97585419e+02,
       2.62609802e+02, 4.16119293e+02, 2.64190155e+02, 4.35254456e+02,
       2.65886932e+02, 4.55037262e+02, 2.67602386e+02, 4.75555115e+02,
       2.69390717e+02, 3.61563629e+02, 2.78220551e+02, 3.78946594e+02,
       2.79917603e+02, 3.96866974e+02, 2.81735260e+02, 4.15334869e+02,
       2.83602631e+02, 4.34377563e+02, 2.85554016e+02, 4.54132050e+02,
       2.87596558e+02, 4.74569092e+02, 2.89675659e+02, 1.22571259e+02,
       1.71192642e+02, 1.40725708e+02, 1.69584747e+02, 1.59003204e+02,
       1.67986542e+02, 1.77394165e+02, 1.66339676e+02, 1.95933578e+02,
       1.64754120e+02, 2.14511093e+02, 1.63014755e+02, 2.33279037e+02,
       1.61345413e+02, 1.24747864e+02, 1.90260818e+02, 1.42828018e+02,
       1.88757690e+02, 1.61094391e+02, 1.87154678e+02, 1.79435516e+02,
       1.85678177e+02, 1.97913040e+02, 1.84075287e+02, 2.16452774e+02,
       1.82499390e+02, 2.35097107e+02, 1.80852768e+02, 1.26861794e+02,
       2.09196625e+02, 1.44946106e+02, 2.07802811e+02, 1.63137833e+02,
       2.06263000e+02, 1.81424210e+02, 2.04823746e+02, 1.99859726e+02,
       2.03314911e+02, 2.18333969e+02, 2.01824799e+02, 2.36992859e+02,
       2.00233856e+02, 1.28944885e+02, 2.28079422e+02, 1.47004562e+02,
       2.26706070e+02, 1.65142410e+02, 2.25254547e+02, 1.83381561e+02,
       2.23861130e+02, 2.01766922e+02, 2.22420273e+02, 2.20167740e+02,
       2.20984924e+02, 2.38771667e+02, 2.19512695e+02, 1.31011917e+02,
       2.46852310e+02, 1.48982101e+02, 2.45476044e+02, 1.67081726e+02,
       2.44124588e+02, 1.85342239e+02, 2.42811890e+02, 2.03606079e+02,
       2.41418793e+02, 2.22000092e+02, 2.40073288e+02, 2.40554764e+02,
       2.38701401e+02, 1.32929108e+02, 2.65427307e+02, 1.50934174e+02,
       2.64149200e+02, 1.69018814e+02, 2.62917297e+02, 1.87204956e+02,
       2.61626984e+02, 2.05434433e+02, 2.60340973e+02, 2.23879196e+02,
       2.59075562e+02, 2.42310501e+02, 2.57801056e+02, 1.34908508e+02,
       2.84018524e+02, 1.52880234e+02, 2.82837219e+02, 1.70899445e+02,
       2.81607056e+02, 1.89009491e+02, 2.80365845e+02, 2.07246536e+02,
       2.79172272e+02, 2.25588867e+02, 2.77968506e+02, 2.44104370e+02,
       2.76792297e+02, 2.89081631e+01, 1.79473053e+02, 4.86981659e+01,
       1.77578369e+02, 6.85417633e+01, 1.75714874e+02, 8.84098587e+01,
       1.73973297e+02, 1.08292297e+02, 1.72128769e+02, 1.28174774e+02,
       1.70499405e+02, 1.47888443e+02, 1.68690216e+02, 3.18746758e+01,
       1.98973801e+02, 5.16367874e+01, 1.97060196e+02, 7.14242325e+01,
       1.95224930e+02, 9.12729263e+01, 1.93418045e+02, 1.11083130e+02,
       1.91541885e+02, 1.30838593e+02, 1.89790421e+02, 1.50534683e+02,
       1.88093124e+02, 3.48663712e+01, 2.18301865e+02, 5.45798950e+01,
       2.16386749e+02, 7.43113098e+01, 2.14501633e+02, 9.40987778e+01,
       2.12662445e+02, 1.13885834e+02, 2.10848984e+02, 1.33562912e+02,
       2.09034576e+02, 1.53119324e+02, 2.07164719e+02, 3.78138657e+01,
       2.37486664e+02, 5.74624748e+01, 2.35616638e+02, 7.71745758e+01,
       2.33676849e+02, 9.69143677e+01, 2.31816727e+02, 1.16609161e+02,
       2.29936508e+02, 1.36188599e+02, 2.28036407e+02, 1.55658310e+02,
       2.26185455e+02, 4.07507515e+01, 2.56556122e+02, 6.03493462e+01,
       2.54606476e+02, 8.00066605e+01, 2.52669754e+02, 9.96256180e+01,
       2.50738083e+02, 1.19255989e+02, 2.48831940e+02, 1.38735855e+02,
       2.46892731e+02, 1.58099075e+02, 2.44995743e+02, 4.36969795e+01,
       2.75450836e+02, 6.31443977e+01, 2.73578949e+02, 8.27226028e+01,
       2.71586426e+02, 1.02309090e+02, 2.69516846e+02, 1.21849304e+02,
       2.67566681e+02, 1.41281174e+02, 2.65586029e+02, 1.60605576e+02,
       2.63634338e+02, 4.65509949e+01, 2.94196075e+02, 6.59721298e+01,
       2.92217255e+02, 8.54830246e+01, 2.90192200e+02, 1.04938271e+02,
       2.88187775e+02, 1.24413528e+02, 2.86141388e+02, 1.43790771e+02,
       2.84176117e+02, 1.63055878e+02, 2.82143677e+02, 4.77685242e+02,
       3.43045502e+01, 4.98753052e+02, 3.21560402e+01, 5.20330688e+02,
       2.99961929e+01, 5.42339661e+02, 2.78775215e+01, 5.64986633e+02,
       2.57955818e+01, 5.87918274e+02, 2.36447678e+01, 6.11462830e+02,
       2.14951324e+01, 4.77533142e+02, 5.54940987e+01, 4.98562439e+02,
       5.35254860e+01, 5.20158630e+02, 5.16561813e+01, 5.42060974e+02,
       4.96729355e+01, 5.64543091e+02, 4.78189240e+01, 5.87484009e+02,
       4.59386292e+01, 6.10879944e+02, 4.40858841e+01, 4.77315277e+02,
       7.64718246e+01, 4.98312653e+02, 7.47574310e+01, 5.19724854e+02,
       7.31095123e+01, 5.41734375e+02, 7.13811111e+01, 5.64198120e+02,
       6.97538223e+01, 5.87004822e+02, 6.80641251e+01, 6.10368225e+02,
       6.64260864e+01, 4.77065491e+02, 9.72865524e+01, 4.97955719e+02,
       9.58380661e+01, 5.19394165e+02, 9.43800659e+01, 5.41261780e+02,
       9.28604660e+01, 5.63626221e+02, 9.14012756e+01, 5.86489136e+02,
       9.00572739e+01, 6.09767822e+02, 8.86990738e+01, 4.76786377e+02,
       1.17886925e+02, 4.97658508e+02, 1.16632446e+02, 5.18934448e+02,
       1.15361351e+02, 5.40755249e+02, 1.14166725e+02, 5.63153687e+02,
       1.12992973e+02, 5.85901123e+02, 1.11836571e+02, 6.09097168e+02,
       1.10699768e+02, 4.76546844e+02, 1.38197510e+02, 4.97284058e+02,
       1.37161835e+02, 5.18531006e+02, 1.36212204e+02, 5.40293884e+02,
       1.35323502e+02, 5.62493103e+02, 1.34292480e+02, 5.85330017e+02,
       1.33435654e+02, 6.08415955e+02, 1.32516937e+02, 4.76340576e+02,
       1.58198090e+02, 4.96894501e+02, 1.57532013e+02, 5.18075317e+02,
       1.56820709e+02, 5.39780457e+02, 1.56093033e+02, 5.62014648e+02,
       1.55457962e+02, 5.84687195e+02, 1.54806091e+02, 6.07764465e+02,
       1.54116882e+02, 3.12825134e+02, 4.18844910e+01, 3.32423859e+02,
       3.81741257e+01, 3.52221100e+02, 3.44195137e+01, 3.72167084e+02,
       3.05602894e+01, 3.92214752e+02, 2.67466679e+01, 4.12481354e+02,
       2.28891697e+01, 4.32792206e+02, 1.89881649e+01, 3.16125488e+02,
       6.25755768e+01, 3.35649536e+02, 5.89027214e+01, 3.55321930e+02,
       5.52805786e+01, 3.75110779e+02, 5.14978981e+01, 3.95092194e+02,
       4.77911530e+01, 4.15240509e+02, 4.39197998e+01, 4.35468933e+02,
       4.01437416e+01, 3.19374268e+02, 8.29193268e+01, 3.38805878e+02,
       7.94719238e+01, 3.58299042e+02, 7.57867355e+01, 3.78024567e+02,
       7.21642380e+01, 3.97887207e+02, 6.85110626e+01, 4.17926453e+02,
       6.46877213e+01, 4.38069366e+02, 6.10281715e+01, 3.22637085e+02,
       1.03024132e+02, 3.41923004e+02, 9.96052704e+01, 3.61318085e+02,
       9.61060104e+01, 3.80909180e+02, 9.25897064e+01, 4.00694824e+02,
       8.89112244e+01, 4.20553406e+02, 8.53045654e+01, 4.40625397e+02,
       8.15946960e+01, 3.25803833e+02, 1.22811432e+02, 3.44994293e+02,
       1.19477547e+02, 3.64310974e+02, 1.16077759e+02, 3.83797668e+02,
       1.12662651e+02, 4.03424042e+02, 1.09161926e+02, 4.23187103e+02,
       1.05526627e+02, 4.43173767e+02, 1.01950478e+02, 3.28967285e+02,
       1.42324142e+02, 3.48063202e+02, 1.39118134e+02, 3.67238770e+02,
       1.35787384e+02, 3.86637329e+02, 1.32471497e+02, 4.06097534e+02,
       1.29084579e+02, 4.25822235e+02, 1.25579193e+02, 4.45664185e+02,
       1.22067841e+02, 3.32072174e+02, 1.61663818e+02, 3.51070618e+02,
       1.58431168e+02, 3.70175568e+02, 1.55262939e+02, 3.89419067e+02,
       1.51993256e+02, 4.08859863e+02, 1.48728226e+02, 4.28434448e+02,
       1.45338867e+02, 4.48224030e+02, 1.41942657e+02, 2.24107620e+02,
       4.52682457e+01, 2.37214355e+02, 4.36071091e+01, 2.50760895e+02,
       4.18847466e+01, 2.64819153e+02, 4.01002274e+01, 2.79334320e+02,
       3.82152328e+01, 2.94399231e+02, 3.62746735e+01, 3.10038910e+02,
       3.42121696e+01, 2.22161041e+02, 6.33194504e+01, 2.35224243e+02,
       6.19633484e+01, 2.48704361e+02, 6.06237373e+01, 2.62719635e+02,
       5.91362228e+01, 2.77164093e+02, 5.76677704e+01, 2.92197845e+02,
       5.60721626e+01, 3.07779388e+02, 5.43644867e+01, 2.20219086e+02,
       8.13384018e+01, 2.33222519e+02, 8.03193054e+01, 2.46722046e+02,
       7.93498840e+01, 2.60638611e+02, 7.81306992e+01, 2.75059753e+02,
       7.70040283e+01, 2.90011993e+02, 7.57817230e+01, 3.05498657e+02,
       7.44876099e+01, 2.18286896e+02, 9.93190613e+01, 2.31258514e+02,
       9.86030350e+01, 2.44664154e+02, 9.79105072e+01, 2.58542267e+02,
       9.70911789e+01, 2.72918549e+02, 9.62591171e+01, 2.87825073e+02,
       9.53957367e+01, 3.03213379e+02, 9.45169067e+01, 2.16312027e+02,
       1.17237473e+02, 2.29235947e+02, 1.16854248e+02, 2.42624451e+02,
       1.16419212e+02, 2.56414612e+02, 1.15988564e+02, 2.70784149e+02,
       1.15483101e+02, 2.85604675e+02, 1.14970047e+02, 3.00960052e+02,
       1.14603920e+02, 2.14371033e+02, 1.35143906e+02, 2.27283493e+02,
       1.34992920e+02, 2.40543732e+02, 1.34880753e+02, 2.54323746e+02,
       1.34767441e+02, 2.68609924e+02, 1.34570328e+02, 2.83363861e+02,
       1.34406433e+02, 2.98695526e+02, 1.34201263e+02, 2.12371201e+02,
       1.52865082e+02, 2.25223633e+02, 1.53073898e+02, 2.38474747e+02,
       1.53298859e+02, 2.52210541e+02, 1.53440109e+02, 2.66402435e+02,
       1.53629745e+02, 2.81111359e+02, 1.53816864e+02, 2.96429230e+02,
       1.53942368e+02, 1.01578690e+02, 3.27359314e+01, 1.20559090e+02,
       3.20424805e+01, 1.39497391e+02, 3.14357319e+01, 1.58381470e+02,
       3.08179989e+01, 1.77170578e+02, 3.02791080e+01, 1.95869263e+02,
       2.97545204e+01, 2.14452576e+02, 2.92587585e+01, 1.04367065e+02,
       5.20996437e+01, 1.23194176e+02, 5.14498787e+01, 1.41980698e+02,
       5.08218765e+01, 1.60666916e+02, 5.02568207e+01, 1.79295502e+02,
       4.96947708e+01, 1.97786270e+02, 4.91387100e+01, 2.16194489e+02,
       4.86271858e+01, 1.07142998e+02, 7.11859131e+01, 1.25862686e+02,
       7.04597702e+01, 1.44492355e+02, 6.98418579e+01, 1.62985825e+02,
       6.92657166e+01, 1.81429504e+02, 6.87612839e+01, 1.99704071e+02,
       6.81593170e+01, 2.17923035e+02, 6.76691666e+01, 1.09996704e+02,
       8.98098145e+01, 1.28526520e+02, 8.91328812e+01, 1.46952454e+02,
       8.85141525e+01, 1.65284653e+02, 8.79250031e+01, 1.83520691e+02,
       8.73208466e+01, 2.01605789e+02, 8.67587280e+01, 2.19628860e+02,
       8.61997833e+01, 1.12797279e+02, 1.08070290e+02, 1.31139343e+02,
       1.07381447e+02, 1.49406250e+02, 1.06721451e+02, 1.67571808e+02,
       1.06100578e+02, 1.85567764e+02, 1.05479195e+02, 2.03468582e+02,
       1.04852112e+02, 2.21227036e+02, 1.04278069e+02, 1.15529922e+02,
       1.25963791e+02, 1.33735733e+02, 1.25275772e+02, 1.51811890e+02,
       1.24622612e+02, 1.69784607e+02, 1.23970535e+02, 1.87583389e+02,
       1.23312965e+02, 2.05317856e+02, 1.22687347e+02, 2.22823807e+02,
       1.22001900e+02, 1.18269051e+02, 1.43518616e+02, 1.36263474e+02,
       1.42768631e+02, 1.54187378e+02, 1.42070435e+02, 1.71939606e+02,
       1.41379013e+02, 1.89530960e+02, 1.40662750e+02, 2.07045975e+02,
       1.39976532e+02, 2.24421494e+02, 1.39241013e+02, 2.58153839e+01,
       3.68045959e+01, 4.57595787e+01, 3.61298370e+01, 6.54228439e+01,
       3.55203972e+01, 8.48242798e+01, 3.48982201e+01, 1.03962395e+02,
       3.43513184e+01, 1.22920425e+02, 3.38535614e+01, 1.41644775e+02,
       3.34119339e+01, 2.90066166e+01, 5.62225723e+01, 4.86582336e+01,
       5.54789810e+01, 6.81803055e+01, 5.47213211e+01, 8.74355392e+01,
       5.40196953e+01, 1.06413612e+02, 5.33774567e+01, 1.25180336e+02,
       5.27731705e+01, 1.43731979e+02, 5.22406235e+01, 3.21405182e+01,
       7.52886581e+01, 5.16579895e+01, 7.44166107e+01, 7.09388351e+01,
       7.36003876e+01, 8.99352570e+01, 7.28514099e+01, 1.08879768e+02,
       7.20535431e+01, 1.27486961e+02, 7.13806686e+01, 1.45871872e+02,
       7.07938766e+01, 3.52493973e+01, 9.40121002e+01, 5.45233574e+01,
       9.30363770e+01, 7.37217255e+01, 9.20959167e+01, 9.25907211e+01,
       9.12707825e+01, 1.11293419e+02, 9.04067001e+01, 1.29769455e+02,
       8.96526718e+01, 1.47977585e+02, 8.89293594e+01, 3.82802277e+01,
       1.12402100e+02, 5.74775047e+01, 1.11315720e+02, 7.64151993e+01,
       1.10281792e+02, 9.51579208e+01, 1.09338295e+02, 1.13736885e+02,
       1.08431374e+02, 1.32021912e+02, 1.07576904e+02, 1.50107651e+02,
       1.06740364e+02, 4.13155556e+01, 1.30485687e+02, 6.03425598e+01,
       1.29322372e+02, 7.91462936e+01, 1.28140747e+02, 9.77523346e+01,
       1.27081825e+02, 1.16110168e+02, 1.26078842e+02, 1.34258331e+02,
       1.25143852e+02, 1.52130875e+02, 1.24193298e+02, 4.43538513e+01,
       1.48143005e+02, 6.31968956e+01, 1.46875961e+02, 8.18385696e+01,
       1.45645660e+02, 1.00272339e+02, 1.44508896e+02, 1.18539261e+02,
       1.43469040e+02, 1.36495956e+02, 1.42345551e+02, 1.54221527e+02,
       1.41299149e+02 ]

说明:

  • image_points
  • 定标点的图像坐标,为2xN或者Nx2的矩阵,这里N是所有视图中点的总数。
  • intrinsic_matrix
  • 输出内参矩阵(A),如果指定CV_CALIB_USE_INTRINSIC_GUESS和(或)CV_CALIB_FIX_ASPECT_RATION,fx、 fy、 cx和cy部分或者全部必须被初始化。
  • distortion_coeffs
  • 输出大小为4x1或者1x4的向量,里面为形变参数[k1, k2, p1, p2]。
  • rotation_vectors
  • 输出大小为3xM或者Mx3的矩阵,里面为旋转向量(旋转矩阵的紧凑表示方式,具体参考函数cvRodrigues2)
  • translation_vectors
  • 输出大小为3xM或Mx3的矩阵,里面为平移向量。
  • flags
  • 不同的标志,可以是0,或者下面值的组合:
    • CV_CALIB_USE_INTRINSIC_GUESS - 内参数矩阵包含fx,fy,cx和cy的初始值。否则,(cx, cy)被初始化到图像中心(这儿用到图像大小),焦距用最小平方差方式计算得到。注意,如果内部参数已知,没有必要使用这个函数,使用cvFindExtrinsicCameraParams2则可。
    • CV_CALIB_FIX_PRINCIPAL_POINT - 主点在全局优化过程中不变,一直在中心位置或者在其他指定的位置(当CV_CALIB_USE_INTRINSIC_GUESS设置的时候)。
    • CV_CALIB_FIX_ASPECT_RATIO - 优化过程中认为fx和fy中只有一个独立变量,保持比例fx/fy不变,fx/fy的值跟内参数矩阵初始化时的值一样。在这种情况下, (fx, fy)的实际初始值或者从输入内存矩阵中读取(当CV_CALIB_USE_INTRINSIC_GUESS被指定时),或者采用估计值(后者情况中fx和fy可能被设置为任意值,只有比值被使用)。
    • CV_CALIB_ZERO_TANGENT_DIST – 切向形变参数(p1, p2)被设置为0,其值在优化过程中保持为0。
extrinsic_parameters:
a set of 6-tuples (rotation vector + translation vector) for each view
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

OpenCV样例calibration 的相关文章

  • Opencv matchTemplate 和 np.where():仅保留唯一值

    继带有马里奥硬币的 opencv 教程 https opencv python tutroals readthedocs io en latest py tutorials py imgproc py template matching p
  • 如何在给定目标大小的情况下在 python 中调整图像大小,同时保留纵横比?

    首先 我觉得这是一个愚蠢的问题 对此感到抱歉 目前 我发现计算最佳缩放因子 目标像素数的最佳宽度和高度 同时保留纵横比 的最准确方法是迭代并选择最佳缩放因子 但是必须有更好的方法来做到这一点 一个例子 import cv2 numpy as
  • 我是否必须使用我的数据库训练 Viola-Jones 算法才能获得准确的结果?

    我尝试提取面部数据库的面部特征 但我认识到 Viola Jones 算法在两种情况下效果不佳 当我尝试单独检测眼睛时 当我尝试检测嘴巴时 运作不佳 检测图像的不同部分 例如眼睛或嘴巴 或者有时会检测到其中几个 这是不可能的情况 我使用的图像
  • 如何删除树莓派的相机预览

    我在我的 raspberryPi 上安装了 SimpleCv 并安装了用于使用相机板的驱动程序 uv4l 驱动程序 现在我想使用它 当我在 simpleCV shell Camera 0 getImage save foo jpg 上键入时
  • OpenCV的拼接模块可以拼接平行运动相机拍摄的图像吗?

    我想知道是否缝合 http docs opencv org modules stitching doc stitching html http docs opencv org modules stitching doc stitching
  • 我可以使用 openCV 比较两张不同图像上的两张脸吗?

    我对 openCV 很陌生 我看到它可以计算出脸部并返回一个矩形来指示脸部 我想知道 openCV 是否可以访问两张包含一张脸的图像 并且我希望 openCV 返回这两个人是否相同的可能性 Thanks OpenCV 不提供完整的人脸识别引
  • 指纹奇异点检测

    我正在尝试确定指纹的核心点和增量点 我正在使用庞加莱指数方法 但我无法成功检测到这一点 而且我不明白为什么 First I divide the image in 15x15 blocks then I calculate the x an
  • OpenCV C++ 如何知道每行的轮廓数进行排序?

    我有一个二值图像 https i stack imgur com NRLVv jpg在这张图片中 我可以使用重载的函数轻松地对从上到下 从左到右找到的轮廓进行排序std sort 我首先通过以下方式从上到下排序 sort contours
  • minAreaRect OpenCV 返回的裁剪矩形 [Python]

    minAreaRectOpenCV 中返回一个旋转的矩形 如何裁剪矩形内图像的这部分 boxPoints返回旋转矩形的角点的坐标 以便可以通过循环框内的点来访问像素 但是在 Python 中是否有更快的裁剪方法 EDIT See code在
  • 使用 OpenCV 和/或 Numpy 对两个图像进行 Alpha 混合 [重复]

    这个问题在这里已经有答案了 我想将一个填充纯色的半透明矩形添加到已加载的半透明 PNG 中 这是我正在使用的输入图像示例 该图像加载了标准cv2 IMREAD UNCHANGED标志 以便完美保留 alpha 通道 该输入图像存储在imag
  • 使用 OpenCV 改进特征点匹配

    我想匹配立体图像中的特征点 我已经用不同的算法找到并提取了特征点 现在我需要一个良好的匹配 在本例中 我使用 FAST 算法进行检测和提取 BruteForceMatcher用于匹配特征点 匹配代码 vector lt vector
  • 如何使用 colorchecker 在 opencv 中进行颜色校准?

    我有数码相机获取的色彩检查器图像 我如何使用它来使用 opencv 校准图像 按照以下颜色检查器图像操作 您是想问如何进行颜色校准或如何使用 OpenCV 进行校准 为了进行颜色校准 您可以使用校准板的最后一行 灰色调 以下是您应该逐步进行
  • cv2.drawContours() - 取消填充字符内的圆圈(Python,OpenCV)

    根据 Silencer的建议 我使用了他发布的代码here https stackoverflow com questions 48244328 copy shape to blank canvas opencv python 482465
  • 如何将 Mat (opencv) 转换为 INDArray (DL4J)?

    我希望任何人都可以帮助我解决这个任务 我正在处理一些图像分类并尝试将 OpenCv 3 2 0 和 DL4J 结合起来 我知道DL4J也包含Opencv 但我认为它没什么用 谁能帮我 如何转换成 INDArray 我尝试阅读一些问题here
  • OpenCV Mat 和 Leptonica Pix 之间的转换

    我需要在 C 中在 OpenCV Mat 图像和 Leptonica Pix 图像格式之间进行转换 这用于 8 位灰度图像的二值化 我发现发现了 ikaliga的回答 https stackoverflow com a 25929320 2
  • cv2.VideoWriter:请求一个元组作为 Size 参数,然后拒绝它

    我正在使用 OpenCV 4 0 和 Python 3 7 创建延时视频 构造 VideoWriter 对象时 文档表示 Size 参数应该是一个元组 当我给它一个元组时 它拒绝它 当我尝试用其他东西替换它时 它不会接受它 因为它说参数不是
  • 为什么Android的ImageReader类这么慢?

    我尝试了适用于 Android 3 4 1 的全新 OpenCVJavaCamera2View但它太慢了 仅显示相机视图约 15 fps 当我尝试较旧的JavaCameraView相反 它给了我很好的结果 30fps 这是我相机的极限 我想
  • opencv水印周围的轮廓

    我想在图像中的水印周围画一个框 我已经提取了水印并找到了轮廓 但是 不会在水印周围绘制轮廓 轮廓是在我的整个图像上绘制的 请帮我提供正确的代码 轮廓坐标的输出为 array 0 0 0 634 450 634 450 0 dtype int
  • 从 NumPy 数组到 Mat 的 C++ 转换 (OpenCV)

    我正在围绕 ArUco 增强现实库 基于 OpenCV 编写一个薄包装器 我试图构建的界面非常简单 Python 将图像传递给 C 代码 C 代码检测标记并将其位置和其他信息作为字典元组返回给 Python 但是 我不知道如何在 Pytho
  • 深度估计的准确性 - 立体视觉

    我正在研究立体视觉 我对这个问题的深度估计的准确性感兴趣 这取决于几个因素 例如 适当的立体校准 旋转 平移和失真提取 图像分辨率 相机和镜头质量 失真越小 色彩捕捉正确 两个图像之间的匹配特征 假设我们没有低成本的相机和镜头 没有廉价的网

随机推荐

  • 33. 实战:实现某网站店铺信息的查询与批量抓取(附源码)

    目录 前言 目的 思路 代码实现 1 请求URL 获取源代码 2 解析源代码 获取数据 3 完善保存数据的函数save data 4 理清main函数逻辑 循环传递每一页有效信息的参数 完整代码 运行效果 总结 前言 近日 我们每周四都能刷
  • C#类与结构体的区别

    C 中类 class 与结构体 stract 的区别 1 类是引用类型 结构体是值类型 2 结构体不支持继承 但可以实现接口 类即支持继承也能实现接口 3 结构体中不可以声明无参的构造函数 4 结构体不能定义析构函数 5 结构体不可用作其他
  • 关于json数据的写入(write())必须为str类型及写入后双引号“变为‘号问题

    1 原始json数据 text 黎城县东崖底中心校学生用床购置项目成交公告 label 1 duoyu 0 text 淮南师范学院采购2017年智库项目 科研建设项目 学科及科技创新平台项目 1包 中标公示 label 1 duoyu 0
  • SpringBoot对接微信小程序支付功能开发(二,支付回调功能)

    接着上一篇 SpringBoot对接微信小程序支付功能开发 一 下单功能 在上一篇下单功能中我们有传支付结果回调地址 下面是回调接口实现 package com office miniapp controller import cn hut
  • Blender材质贴图入门图文教程

    推荐 将 NSDT场景编辑器 加入你的3D开发工具链 大家好 今天跟大家分享Blender材质贴图入门图文教程 一套blender的PBR材质包 和HDRI环境纹理贴图 在文末领取 希望能助到大家更高效完成场景练习 据我了解 越来越多人开始
  • Redis、Redission实现分布式锁

    Redis实现 使用spring data redis提供的接口实现redis分布式锁
  • kali使用aircrack无线攻击wifi超详细步骤(包含监听网卡启动,获得握手包,密码本生成)

    平台及工具 linux kali平台 aircrack ng 工具 免驱监听网卡 详细操作 1 首先启动kali 插入网卡 输入ifconfig查看kali是否检测到监听网卡 注意监听网卡要免驱动的 ifconfig 查看自身网卡信息 如图
  • React lazyLoad懒加载

    在React中使用lazy懒加载 效果图 目录结构 index js import React from react import ReactDOM from react dom import App from App import Bro
  • PID算法与PID自整定算法

    PID算法与PID自整定算法 本文是由于研发恒温槽项目故需要了解PID控制算法和PID自整定算法 为方便本人日后需要故作此记录 直接粘贴代码吧 这是PID位置式控温算法 函数名 void Pid positional float speed
  • 【Qt教程】4.1 - Qt5 文件系统 QFile文件读写操作

    1 Qt文件系统简介 QFile 文件系统是应用程序必不可少的部分 Qt作为一个通用开发库 提供了跨平台的文件操作能力 Qt通过 QIODevice 提供了对I O设备的抽象 使这些设备具有读写字节块的能力 在所有的I O设备中 文件I O
  • java forName() 方法

    forName 方法会进行类加载 将MyClass装在到JVM上 静态代码块 在类加载时执行 且只执行一次 如果你只想执行一个类的静态代码块 其它代码不执行 可以使用forName 方法 package leetcode0606 refle
  • Mybatis:传参+提交事务(自动or手动)+sql多表关联查询(两种方法)

    目录 一 参数两种类型 二 传参的几种方法 三 提交事务 四 sql多表关联查询 两种方法 一 参数两种类型 1 参数 预编译方式 更安全 只用于向sql中传值 select from admin where account account
  • Buuctf(Easy Calc 1)

    一 解题步骤 1 发现了一个可以得到计算结果的输入框 说明这题可能是一道命令执行 或者注入题目 我们输几个数字发现可以得到正确答案 但输入字母就会报错 我们看一下html源码 进行代码审计
  • java给byte赋值_关于JAVA中Byte数据类型二进制赋值运算报错问题

    自从JDK7更新之后 新增了二进制变量的表示 支持将整数类型用二进制来表示 用0b开头 例如 byte b byte 0b1000 0001 short s short 0b1000 0000 0000 0001 新手在这个时候会遇到一个问
  • rabbitmq 客户端golang实战

    rabbitmq消息模式 rabbitmq中进行消息控制的组建可以分为以下几部分 exchange rabbitmq中的路由部件 控制消息的转发路径 queue rabbitmq的消息队列 可以有多个消费者从队列中读取消息 consumer
  • 游戏设计模式笔记(一)[自用]

    目录 学习内容 学习笔记 设计模式简介 Design Pattern 单例模式的学习 第一种方式 第二种方式 第三种方式 单例模式的优点 学习内容 设计模式简介 Design Pattern 单例模式的学习 单例模式的优点 学习笔记 设计模
  • 电脑蓝屏终止代码irql_电脑故障排除之五种常见的蓝屏代码及解决方法

    超过10万人正在关注 赶快来关注吧 这里有你想找的热点资讯 这里有你想要的各种资料 还有海量的资源 还在等什么 快来关注 大佬带你开车 电脑蓝屏 又称蓝屏死机 BSDO 它是系统自我保护的一种现象 遇到蓝屏时不必慌张 利用以下几个方法就能解
  • 地址模块丨前端uniapp微信小程序项目

    小兔鲜儿 地址模块 能够获取不同类型的表单数据 能够动态设置导航栏的标题 能够使用 uni ui 组件库的组件 能够完成收货地址的增删改查的功能 准备工作 静态结构 地址模块共两个页面 地址管理页 地址表单页 划分到会员分包中 地址管理页
  • lua知识系列:lua5.3 GC机制

    插眼 总结 暂无 参考 Lua5 3版GC机制理解 https blog csdn net BigBrick article details 85317491 Lua5 3自动GC触发条件分析与理解 https blog csdn net
  • OpenCV样例calibration

    1 将图片地址写入到xml 创建工程 运行一下文件 C Program Files opencv sources samples cpp imagelist creator cpp cmd运行 cd至 工程目录 x64 Debug gt 命