資源簡介
opencv2 3D標定.cpp
代碼片段和文件信息
/*
?*?3calibration.cpp?--?Calibrate?3?cameras?in?a?horizontal?line?together.
?*/
#include?“opencv2/calib3d.hpp“
#include?“opencv2/imgproc.hpp“
#include?“opencv2/imgcodecs.hpp“
#include?“opencv2/highgui.hpp“
#include?“opencv2/core/utility.hpp“
#include?
#include?
#include?
using?namespace?cv;
using?namespace?std;
enum?{?DETECTION?=?0?CAPTURING?=?1?CALIBRATED?=?2?};
static?void?help(char**?argv)
{
????????printf(?“\nThis?is?a?camera?calibration?sample?that?calibrates?3?horizontally?placed?cameras?together.\n“
???????????????“Usage:?%s\n“
???????????????“?????-w=?????????#?the?number?of?inner?corners?per?one?of?board?dimension\n“
???????????????“?????-h=????????#?the?number?of?inner?corners?per?another?board?dimension\n“
???????????????“?????[-s=]???????#?square?size?in?some?user-defined?units?(1?by?default)\n“
???????????????“?????[-o=]?#?the?output?filename?for?intrinsic?[and?extrinsic]?parameters\n“
???????????????“?????[-zt]????????????????????#?assume?zero?tangential?distortion\n“
???????????????“?????[-a=]??????#?fix?aspect?ratio?(fx/fy)\n“
???????????????“?????[-p]?????????????????????#?fix?the?principal?point?at?the?center\n“
???????????????“?????[input_data]?????????????#?input?data?-?text?file?with?a?list?of?the?images?of?the?board\n“
???????????????“\n“?argv[0]?);
}
static?void?calcChessboardCorners(Size?boardSize?float?squareSize?vector&?corners)
{
????corners.resize(0);
????for(?int?i?=?0;?i?????????for(?int?j?=?0;?j?????????????corners.push_back(Point3f(float(j*squareSize)
??????????????????????????????????????float(i*squareSize)?0));
}
static?bool?run3Calibration(vector?>?imagePoints1
????????????????????????????vector?>?imagePoints2
????????????????????????????vector?>?imagePoints3
????????????????????????????Size?imageSize?Size?boardSize
????????????????????????????float?squareSize?float?aspectRatio
????????????????????????????int?flags
????????????????????????????Mat&?cameraMatrix1?Mat&?distCoeffs1
????????????????????????????Mat&?cameraMatrix2?Mat&?distCoeffs2
????????????????????????????Mat&?cameraMatrix3?Mat&?distCoeffs3
????????????????????????????Mat&?R12?Mat&?T12?Mat&?R13?Mat&?T13)
{
????int?c?i;
????//?step?1:?calibrate?each?camera?individually
????vector?>?objpt(1);
????vector?>?imgpt;
????calcChessboardCorners(boardSize?squareSize?objpt[0]);
????vector?rvecs?tvecs;
????for(?c?=?1;?c?<=?3;?c++?)
????{
????????const?vector?>&?imgpt0?=?c?==?1???imagePoints1?:?c?==?2???imagePoints2?:?imagePoints3;
????????imgpt.clear();
????????int?N?=?0;
????????for(?i?=?0;?i?(int)imgpt0.size();?i++?)
????????????if(?!imgpt0[i].empty()?)
????????????{
????????????????imgpt.push
- 上一篇:基于VSCode和CMake實現C++開發
- 下一篇:Qt曲線
評論
共有 條評論