2016-09-14 17:16:10 +08:00
|
|
|
// This file is part of OpenCV project.
|
|
|
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
|
|
|
// of this distribution and at http://opencv.org/license.html.
|
|
|
|
|
2016-04-08 21:30:56 +08:00
|
|
|
#ifndef CALIB_COMMON_HPP
|
|
|
|
#define CALIB_COMMON_HPP
|
|
|
|
|
|
|
|
#include <opencv2/core.hpp>
|
2016-09-14 17:16:10 +08:00
|
|
|
|
|
|
|
#include <memory>
|
2016-04-08 21:30:56 +08:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace calib
|
|
|
|
{
|
|
|
|
#define OVERLAY_DELAY 1000
|
|
|
|
#define IMAGE_MAX_WIDTH 1280
|
|
|
|
#define IMAGE_MAX_HEIGHT 960
|
|
|
|
|
|
|
|
bool showOverlayMessage(const std::string& message);
|
|
|
|
|
|
|
|
enum InputType { Video, Pictures };
|
|
|
|
enum InputVideoSource { Camera, File };
|
|
|
|
enum TemplateType { AcirclesGrid, Chessboard, chAruco, DoubleAcirclesGrid };
|
|
|
|
|
|
|
|
static const std::string mainWindowName = "Calibration";
|
|
|
|
static const std::string gridWindowName = "Board locations";
|
|
|
|
static const std::string consoleHelp = "Hot keys:\nesc - exit application\n"
|
|
|
|
"s - save current data to .xml file\n"
|
|
|
|
"r - delete last frame\n"
|
2016-08-18 17:37:04 +08:00
|
|
|
"u - enable/disable applying undistortion\n"
|
2016-04-08 21:30:56 +08:00
|
|
|
"d - delete all frames\n"
|
|
|
|
"v - switch visualization";
|
|
|
|
|
|
|
|
static const double sigmaMult = 1.96;
|
|
|
|
|
|
|
|
struct calibrationData
|
|
|
|
{
|
|
|
|
cv::Mat cameraMatrix;
|
|
|
|
cv::Mat distCoeffs;
|
|
|
|
cv::Mat stdDeviations;
|
|
|
|
cv::Mat perViewErrors;
|
|
|
|
std::vector<cv::Mat> rvecs;
|
|
|
|
std::vector<cv::Mat> tvecs;
|
|
|
|
double totalAvgErr;
|
|
|
|
cv::Size imageSize;
|
|
|
|
|
2022-06-08 18:59:55 +08:00
|
|
|
std::vector<cv::Mat> allFrames;
|
|
|
|
|
2016-04-08 21:30:56 +08:00
|
|
|
std::vector<std::vector<cv::Point2f> > imagePoints;
|
|
|
|
std::vector< std::vector<cv::Point3f> > objectPoints;
|
|
|
|
|
|
|
|
std::vector<cv::Mat> allCharucoCorners;
|
|
|
|
std::vector<cv::Mat> allCharucoIds;
|
|
|
|
|
|
|
|
cv::Mat undistMap1, undistMap2;
|
|
|
|
|
|
|
|
calibrationData()
|
|
|
|
{
|
|
|
|
imageSize = cv::Size(IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cameraParameters
|
|
|
|
{
|
|
|
|
cv::Mat cameraMatrix;
|
|
|
|
cv::Mat distCoeffs;
|
|
|
|
cv::Mat stdDeviations;
|
|
|
|
double avgError;
|
|
|
|
|
|
|
|
cameraParameters(){}
|
|
|
|
cameraParameters(cv::Mat& _cameraMatrix, cv::Mat& _distCoeffs, cv::Mat& _stdDeviations, double _avgError = 0) :
|
|
|
|
cameraMatrix(_cameraMatrix), distCoeffs(_distCoeffs), stdDeviations(_stdDeviations), avgError(_avgError)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct captureParameters
|
|
|
|
{
|
|
|
|
InputType captureMethod;
|
|
|
|
InputVideoSource source;
|
|
|
|
TemplateType board;
|
|
|
|
cv::Size boardSize;
|
|
|
|
int charucoDictName;
|
|
|
|
int calibrationStep;
|
2020-02-17 00:16:33 +08:00
|
|
|
float charucoSquareLength, charucoMarkerSize;
|
2016-04-08 21:30:56 +08:00
|
|
|
float captureDelay;
|
|
|
|
float squareSize;
|
|
|
|
float templDst;
|
|
|
|
std::string videoFileName;
|
|
|
|
bool flipVertical;
|
|
|
|
int camID;
|
|
|
|
int fps;
|
|
|
|
cv::Size cameraResolution;
|
|
|
|
int maxFramesNum;
|
|
|
|
int minFramesNum;
|
2022-06-08 18:59:55 +08:00
|
|
|
bool saveFrames;
|
2016-04-08 21:30:56 +08:00
|
|
|
|
|
|
|
captureParameters()
|
|
|
|
{
|
|
|
|
calibrationStep = 1;
|
|
|
|
captureDelay = 500.f;
|
|
|
|
maxFramesNum = 30;
|
|
|
|
minFramesNum = 10;
|
|
|
|
fps = 30;
|
|
|
|
cameraResolution = cv::Size(IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT);
|
2022-06-08 18:59:55 +08:00
|
|
|
saveFrames = false;
|
2016-04-08 21:30:56 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct internalParameters
|
|
|
|
{
|
|
|
|
double solverEps;
|
|
|
|
int solverMaxIters;
|
|
|
|
bool fastSolving;
|
|
|
|
double filterAlpha;
|
|
|
|
|
|
|
|
internalParameters()
|
|
|
|
{
|
|
|
|
solverEps = 1e-7;
|
|
|
|
solverMaxIters = 30;
|
|
|
|
fastSolving = false;
|
|
|
|
filterAlpha = 0.1;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|