Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/apps/interactive-calibration/calibCommon.hpp
16337 views
1
// This file is part of OpenCV project.
2
// It is subject to the license terms in the LICENSE file found in the top-level directory
3
// of this distribution and at http://opencv.org/license.html.
4
5
#ifndef CALIB_COMMON_HPP
6
#define CALIB_COMMON_HPP
7
8
#include <opencv2/core.hpp>
9
10
#include <memory>
11
#include <vector>
12
#include <string>
13
14
namespace calib
15
{
16
#define OVERLAY_DELAY 1000
17
#define IMAGE_MAX_WIDTH 1280
18
#define IMAGE_MAX_HEIGHT 960
19
20
bool showOverlayMessage(const std::string& message);
21
22
enum InputType { Video, Pictures };
23
enum InputVideoSource { Camera, File };
24
enum TemplateType { AcirclesGrid, Chessboard, chAruco, DoubleAcirclesGrid };
25
26
static const std::string mainWindowName = "Calibration";
27
static const std::string gridWindowName = "Board locations";
28
static const std::string consoleHelp = "Hot keys:\nesc - exit application\n"
29
"s - save current data to .xml file\n"
30
"r - delete last frame\n"
31
"u - enable/disable applying undistortion\n"
32
"d - delete all frames\n"
33
"v - switch visualization";
34
35
static const double sigmaMult = 1.96;
36
37
struct calibrationData
38
{
39
cv::Mat cameraMatrix;
40
cv::Mat distCoeffs;
41
cv::Mat stdDeviations;
42
cv::Mat perViewErrors;
43
std::vector<cv::Mat> rvecs;
44
std::vector<cv::Mat> tvecs;
45
double totalAvgErr;
46
cv::Size imageSize;
47
48
std::vector<std::vector<cv::Point2f> > imagePoints;
49
std::vector< std::vector<cv::Point3f> > objectPoints;
50
51
std::vector<cv::Mat> allCharucoCorners;
52
std::vector<cv::Mat> allCharucoIds;
53
54
cv::Mat undistMap1, undistMap2;
55
56
calibrationData()
57
{
58
imageSize = cv::Size(IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT);
59
}
60
};
61
62
struct cameraParameters
63
{
64
cv::Mat cameraMatrix;
65
cv::Mat distCoeffs;
66
cv::Mat stdDeviations;
67
double avgError;
68
69
cameraParameters(){}
70
cameraParameters(cv::Mat& _cameraMatrix, cv::Mat& _distCoeffs, cv::Mat& _stdDeviations, double _avgError = 0) :
71
cameraMatrix(_cameraMatrix), distCoeffs(_distCoeffs), stdDeviations(_stdDeviations), avgError(_avgError)
72
{}
73
};
74
75
struct captureParameters
76
{
77
InputType captureMethod;
78
InputVideoSource source;
79
TemplateType board;
80
cv::Size boardSize;
81
int charucoDictName;
82
int calibrationStep;
83
float charucoSquareLenght, charucoMarkerSize;
84
float captureDelay;
85
float squareSize;
86
float templDst;
87
std::string videoFileName;
88
bool flipVertical;
89
int camID;
90
int fps;
91
cv::Size cameraResolution;
92
int maxFramesNum;
93
int minFramesNum;
94
95
captureParameters()
96
{
97
calibrationStep = 1;
98
captureDelay = 500.f;
99
maxFramesNum = 30;
100
minFramesNum = 10;
101
fps = 30;
102
cameraResolution = cv::Size(IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT);
103
}
104
};
105
106
struct internalParameters
107
{
108
double solverEps;
109
int solverMaxIters;
110
bool fastSolving;
111
double filterAlpha;
112
113
internalParameters()
114
{
115
solverEps = 1e-7;
116
solverMaxIters = 30;
117
fastSolving = false;
118
filterAlpha = 0.1;
119
}
120
};
121
}
122
123
#endif
124
125