-
Notifications
You must be signed in to change notification settings - Fork 1
/
objectedgestracker.h
154 lines (116 loc) · 4.55 KB
/
objectedgestracker.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
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
142
143
144
145
146
147
148
149
150
151
152
153
154
#ifndef OBJECTEDGESTRACKER_H
#define OBJECTEDGESTRACKER_H
#include <memory>
#include <unordered_map>
#include <tuple>
#include <QVector2D>
#include <QMatrix4x4>
#include <QSharedPointer>
#include <Eigen/Eigen>
#include <opencv2/core.hpp>
#include "objectmodel.h"
#include "debugimageobject.h"
#include "posefilter.h"
struct TrackingQuality
{
Q_GADGET
public:
enum Enum
{
Good,
Bad,
Ugly
};
Q_ENUM(Enum)
};
class PerformanceMonitor;
class PinholeCamera;
class ObjectEdgesTracker:
public DebugImageObject
{
Q_OBJECT
Q_PROPERTY(bool useLaplacian READ useLaplacian WRITE setUseLaplacian NOTIFY useLaplacianChanged)
Q_PROPERTY(bool useAdaptiveBinarization READ useAdaptiveBinarization
WRITE setUseAdaptiveBinarization NOTIFY useAdaptiveBinarizationChanged)
Q_PROPERTY(int adaptiveBinarizationWinSize READ adaptiveBinarizationWinSize
WRITE setAdaptiveBinarizationWinSize NOTIFY adaptiveBinarizationWinSizeChanged)
Q_PROPERTY(bool useDilate READ useDilate WRITE setUseDilate NOTIFY useDilateChanged)
Q_PROPERTY(bool useErode READ useErode WRITE setUseErode NOTIFY useErodeChanged)
Q_PROPERTY(float controlPixelDistance READ controlPixelDistance WRITE setControlPixelDistance
NOTIFY controlPixelDistanceChanged)
Q_PROPERTY(double binaryThreshold READ binaryThreshold WRITE setBinaryThreshold
NOTIFY binaryThresholdChanged)
Q_PROPERTY(double minBlobArea READ minBlobArea WRITE setMinBlobArea NOTIFY minBlobAreaChanged)
Q_PROPERTY(double maxBlobCircularity READ maxBlobCircularity WRITE setMaxBlobCircularity
NOTIFY maxBlobCircularityChanged)
Q_PROPERTY(QVector2D focalLength READ focalLength NOTIFY cameraChanged)
Q_PROPERTY(QVector2D opticalCenter READ opticalCenter NOTIFY cameraChanged)
Q_PROPERTY(QSize frameSize READ frameSize NOTIFY cameraChanged)
Q_PROPERTY(TrackingQuality::Enum trackingQuality READ trackingQuality NOTIFY trackingQualityChanged)
public:
using Pose = PoseFilter::Pose;
ObjectEdgesTracker(const QSharedPointer<PerformanceMonitor> & monitor);
bool useLaplacian() const;
void setUseLaplacian(bool useLaplacian);
bool useAdaptiveBinarization() const;
void setUseAdaptiveBinarization(bool useAdaptiveBinarization);
int adaptiveBinarizationWinSize() const;
void setAdaptiveBinarizationWinSize(int adaptiveBinarizationWinSize);
bool useDilate() const;
void setUseDilate(bool useDilate);
bool useErode() const;
void setUseErode(bool useErode);
float controlPixelDistance() const;
void setControlPixelDistance(float controlPixelDistance);
double binaryThreshold() const;
void setBinaryThreshold(double binaryThreshold);
double minBlobArea() const;
void setMinBlobArea(double minBlobArea);
double maxBlobCircularity() const;
void setMaxBlobCircularity(double maxBlobCircularity);
std::shared_ptr<PinholeCamera> camera() const;
void setCamera(const std::shared_ptr<PinholeCamera> & camera);
QVector2D focalLength() const;
QVector2D opticalCenter() const;
QSize frameSize() const;
TrackingQuality::Enum trackingQuality() const;
QMatrix4x4 viewMatrix() const;
void compute(cv::Mat image);
cv::Mat debugImage() const override;
signals:
void controlPixelDistanceChanged();
void binaryThresholdChanged();
void minBlobAreaChanged();
void maxBlobCircularityChanged();
void cameraChanged();
void trackingQualityChanged();
void useLaplacianChanged();
void useAdaptiveBinarizationChanged();
void adaptiveBinarizationWinSizeChanged();
void useDilateChanged();
void useErodeChanged();
private:
bool m_useLaplacian;
bool m_useAdaptiveBinarization;
int m_adaptiveBinarizationWinSize;
bool m_useDilate;
bool m_useErode;
QSharedPointer<PerformanceMonitor> m_monitor;
PoseFilter m_poseFilter;
float m_controlPixelDistance;
double m_binaryThreshold;
double m_minBlobArea;
double m_maxBlobCircularity;
ObjectModel m_model;
std::shared_ptr<PinholeCamera> m_camera;
Pose m_resetCameraPose;
TrackingQuality::Enum m_trackingQuality;
cv::Mat m_debugImage;
Eigen::Matrix<double, 6, 1> _pose2x(const Pose & pose) const;
Pose _x2pose(const Eigen::Matrix<double, 6, 1> & x) const;
float _tracking1(const cv::Mat & edges);
float _tracking2(const cv::Mat & edges);
TrackingQuality::Enum _error2quality(float error) const;
void _setTrackingQuality(TrackingQuality::Enum quality);
};
#endif // OBJECTEDGESTRACKER_H