Repository navigation
Expand file tree
/
Copy pathprocessor.h
More file actions
141 lines (111 loc) · 3.17 KB
/
Copy pathprocessor.h
File metadata and controls
141 lines (111 loc) · 3.17 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
//
// Created by Louis Krämer on 25.09.25.
//
#pragma once
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <filesystem>
#include <unordered_set>
#include <opencv2/videoio.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/calib3d.hpp>
#include <opencv2/viz/viz3d.hpp>
#include "setter.h"
struct color_count
{
int red = 0, green = 0, blue = 0;
};
struct dimension
{
double x, y, z;
};
struct Ball
{
int id;
std::string name;
double x = 0;
double y = 0;
double z = 0;
dimension positions;
double distances;
std::pair<double, double> middle;
cv::Scalar color;
int field;
double radius;
};
struct Screen
{
std::vector<cv::Point2d> drawPoints;
int width = 1280;
int height = 720;
};
struct screen_M
{
int x = 1280 / 2;
int y = 720 / 2;
};
struct INITIAL_CAMERA_POSITION
{
float PEN_HEIGHT = 18;
float INITIAL_Z_OFFSET = 18;
double initial_green_radii = 0.0;
double initial_blue_radii = 0.0;
double initial_blue_distance = 0.0;
double initial_green_distance = 0.0;
int x = 0;
float y = PEN_HEIGHT;
float z = INITIAL_Z_OFFSET;
};
class Processor
{
public:
std::vector<cv::Point2d> drawPoints;
INITIAL_CAMERA_POSITION camera_position;
Screen screen;
color_count count;
Ball blue_ball, green_ball, red_ball;
float BALL_RADIUS = 3;
float DISTANCE_BETWEEN_BALL = 9;
static constexpr int threshold = 80;
std::array<Ball*, 3> Ball_set;
int framecount = 0;
cv::Mat distCoeffs = cv::Mat::zeros(1, 4, CV_64F);
// Drwaing
void initializeBalls();
void m_display_info(cv::Mat &frame, cv::Mat &out);
void draw_line_to_camera(Ball &b, cv::Mat &img);
void draw_line(cv::Mat &img, cv::Point2f p1, cv::Point2f p2, cv::Scalar color);
void draw_to_screen(cv::Mat &out, std::vector<cv::Point2d> &drawPoints);
// Frame Processor Function
void m_frame_processing(cv::Mat &input, cv::Mat &output);
// Math Functions
bool locate_point(cv::Point& p);
void middle_point(Ball &b);
void crossing_point(cv::Mat &out, std::vector<cv::Point2d> &output);
double get_delta(Ball &b);
//Vector Functions
double euclidian_distance_3D(Ball &p1, INITIAL_CAMERA_POSITION &p2);
double euclidian_distance_2D(Ball &p1, INITIAL_CAMERA_POSITION &p2);
double vektor_length(cv::Point2f p1, cv::Point2f p2);
cv::Point2d middle_two_vek(cv::Point2d p1, cv::Point2d p2);
cv::Point2d target_vek(Ball &b, cv::Point2f p1, cv::Point2f p2);
// Test Function
// cv::Mat image_color_field(const std::string& img_path, const std::string& img_name);
// Video Input
cv::VideoCapture in_video(const std::string &video_path);
void video_loop(cv::VideoCapture &img);
//Camera Settings and Virtual Camera
cv::Mat K_calib_camera();
void create_undistort_camera(
cv::Mat const &cameraMatrix,
cv::Mat const &orig_camera_Matrix,
cv::Mat distCoeffs, cv::Size const &imgsize,
cv::Mat &out_map1, cv::Mat &out_map2);
cv::Mat camera_optimal_matrix();
cv::Mat camera();
};