Repository navigation
Expand file tree
/
Copy pathCalibrate.h
More file actions
125 lines (118 loc) · 2.84 KB
/
Copy pathCalibrate.h
File metadata and controls
125 lines (118 loc) · 2.84 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#ifndef CALIBRATE_H
#define CALIBRATE_H
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/opencv.hpp>
#include "ImageProcess.h"
using namespace std;
class CalibrateBoard
{
private:
//计算世界坐标
void calRealPoint(
std::vector<std::vector<cv::Point3f>>& obj,
int boardwidth,
int boardheight,
int imgNumber,
float squaresize
);
//标定板参数
int BoardNums;
int circle_width;
int circle_height;
float squaresize;
public:
int Get_CircleWidth();
int Get_CircleHeight();
float Get_SquareSize();
//保存标定板的世界坐标
std::vector<std::vector<cv::Point3f>> obj;
CalibrateBoard(int nums,int circle_width,int circle_height,float squaresize);
};
class CalibrateCamera {
private:
//保存标定时用的像素坐标
std::vector<std::vector<cv::Point2f>> imagePoint;
//保存标定使用的世界坐标
std::vector<std::vector<cv::Point3f>> objRealPoint;
//标定
cv::Size imageSize;
//内参矩阵、畸变矩阵
cv::Mat cameraMatrix, distCoeff;
//标定旋转向量
vector<cv::Mat> rvecsMat;
//标定位移向量
vector<cv::Mat> tvecsMat;
//标定图片数量
int ImageNum;
//所有标定图像误差总和
double total_err;
//每幅图像的平均误差
double *Err_All;
//拼接基准的旋转位移向量
cv::Mat Base_RVecsMat;
cv::Mat Base_TVecsMat;
public:
//加载标定图片
void LoadCalibImage(vector<cv::Mat> img);
//通过旋转向量和
cv::Point3f getWorldPoints(const cv::Point2f& inPoints, cv::Mat& rvec, cv::Mat& tvec);
//畸变矫正(不保存原图像)
void adjustImage(cv::Mat& Image);
//标定,并计算误差
bool calibrate(
CalibrateBoard *caliboard
);
//计算基准参数
void BaseCaculate(cv::Mat rgbImage, CalibrateBoard* caliboard);
//Get
cv::Mat GetCameraMatrix();
cv::Mat GetDistCoeff();
double GetAverage_err();
int GetImageNum();
double* GetErr_ALL();
cv::Mat GetBaseRvecMat();
cv::Mat GetBaseTvecMat();
};
class LaserPlane {
public:
//光平面参数
void CaculateLaserPlane();
void LoadBoard(vector<cv::Mat> BoardLaser,CalibrateCamera *camera, CalibrateBoard* caliboard);
void LoadLaser(vector<cv::Mat> BoardLaser, CalibrateCamera* camera);
//get
vector<cv::Mat> GetRVecsMat();
vector<cv::Mat> GetTVecsMat();
double Get_A();
double Get_B();
double Get_C();
double Get_D();
private:
//保存读取的标定像素点
std::vector<std::vector<cv::Point2f>> imagePoint;
//保存计算的旋转向量和位移向量,用于之后的向基准坐标系转换
vector<cv::Mat> rvecsMat;
vector<cv::Mat> tvecsMat;
//保存所有转化到基准的点坐标
std::vector<cv::Point3f> Points3ds;
double A;
double B;
double C;
double D;
};
class step {
private:
cv::Mat move_step;
vector<cv::Mat> rvecsMat;
vector<cv::Mat> tvecsMat;
CalibrateCamera* camera;
CalibrateBoard* caliboard;
int steps_between;
public:
void LoadTrackImage(vector<cv::Mat> TrackImg);
step(CalibrateBoard *caliboard,CalibrateCamera *camera,int steps_between);
void CaculateStep();
cv::Mat GetStep();
};
#endif