forked from frc1444/robot2020-vision
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TargetFinder.h
67 lines (38 loc) · 1.78 KB
/
TargetFinder.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
#pragma once
#include <memory>
#include <opencv2/opencv.hpp>
#include "spdlog/spdlog.h"
#include "TargetModel.h"
#include "CameraModel.h"
#include "VisionData.hpp"
#include "Target.h"
namespace Lightning
{
class TargetFinder
{
public:
TargetFinder(std::vector<spdlog::sink_ptr>, std::string, std::unique_ptr<TargetModel>, std::unique_ptr<CameraModel>, cv::Vec3d);
bool Process(cv::Mat&, std::vector<VisionData>&);
void ShowDebugImages();
private:
void ConvertImage(const cv::Mat&, cv::Mat&, cv::Mat&);
void FilterOnColor(const cv::Mat&, cv::Mat&, const cv::Scalar, const cv::Scalar, const int iter);
bool FindContours(const cv::Mat&, std::vector<std::vector<cv::Point>>&);
void ApproximateContours(const std::vector<std::vector<cv::Point>>&, std::vector<std::vector<cv::Point>>&, cv::Mat&);
void TargetSectionsFromContours(const std::vector<std::vector<cv::Point>>&, std::vector<TargetSection>&, const cv::Size);
void TargetSectionsFromContoursFast(const std::vector<std::vector<cv::Point>>&, std::vector<TargetSection>&, const cv::Size);
void SortTargetSections(const std::vector<TargetSection>&, std::vector<Target>&);
void RefineTargetCorners(std::vector<Target>&, const cv::Mat&);
void FindTargetTransforms(std::vector<Target>&, const cv::Size&);
double Distance(const cv::Point2d&, const cv::Point2d&);
bool CornerSort(cv::Point2f, cv::Point2f, cv::Point2f);
cv::Vec3d EulerAnglesFromRotationMaxtrix(const cv::Mat&);
void DrawDebugImage(cv::Mat&, const std::vector<Target>&);
std::shared_ptr<spdlog::logger> _logger;
std::unique_ptr<TargetModel> _targetModel;
std::unique_ptr<CameraModel> _cameraModel;
std::vector<std::pair<std::string, cv::Mat>> _debugImages;
cv::Vec3d _offset;
std::string _name;
};
}