-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCaptureCalibration.h
73 lines (56 loc) · 2.27 KB
/
CaptureCalibration.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef CAPTURE_CALIBRATION_H
#define CAPTURE_CALIBRATION_H
#include <string>
#include <opencv2/highgui/highgui.hpp>
class Capture;
class CaptureCalibration
{
public:
CaptureCalibration();
enum Pattern { NOT_EXISTING, CHESSBOARD, CIRCLES_GRID, ASYMMETRIC_CIRCLES_GRID };
void SaveXML(cv::FileStorage& fs);
void LoadXML(cv::FileNode& fn);
void CalibrationLoadXML(cv::FileNode& fn); // performs extra checks (for UI)
void Start ();
void Calibrate ();
void Reset ();
bool CalculateCalibration();
void CalcBoardCornerPositions(cv::Size boardSize, float squareSize, std::vector<cv::Point3f>& corners, Pattern patternType /*= Settings::CHESSBOARD*/);
double ComputeReprojectionErrors( const std::vector<std::vector<cv::Point3f> >& objectPoints, const std::vector<std::vector<cv::Point2f> >& imagePoints);
void OutputHud (cv::Mat& hud);
void Undistort (cv::Mat& frame);
void UpdateFlags();
public:
Capture* capture;
cv::Size boardSize; // The size of the board -> Number of items by width and height
Pattern pattern;// One of the Chessboard, circles, or asymmetric circle pattern
float squareSize; // The size of a square in your defined unit (point, millimeter,etc).
int nrFrames; // The number of frames to use from the input for calibration
float aspectRatio; // The aspect ratio
bool firstAnalysisStep;
double delay; // In case of a video input
double lastAnalysisTime;
bool zeroTangentDist; // Assume zero tangential distortion
bool fixPrincipalPoint;// Fix the principal point at the center
bool flipVertical; // Flip the captured images around the horizontal axis
int flags;
std::vector<cv::Point2f> pointBuf;
bool boardFound;
int calibratedImageWidth;
int calibratedImageHeight;
std::string patternString;
std::vector<std::vector<cv::Point2f> > imagePoints;
cv::Mat cameraMatrix;
cv::Mat distCoeffs;
bool calibrated;
bool calibrating;
int analyzedFrames;
cv::Mat undistortedMap1, undistortedMap2;
std::vector<cv::Mat> rvecs, tvecs;
std::vector<float> reprojErrs;
double totalAvgErr = 0;
// about frames
int frameNumber = 0;
int lastFrameNumber = 0;
};
#endif