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 | /**
* @file RedBallDetector.h
*
* Definition of class RedBallDetector
*/
#ifndef _RedBallDetector_H_
#define _RedBallDetector_H_
#include <ModuleFramework/Module.h>
#include <ModuleFramework/Representation.h>
// common tools
#include <Tools/ColorClasses.h>
#include <Tools/Math/Vector2.h>
#include <Tools/Math/Matrix_nxn.h>
#include <Tools/ImageProcessing/ColorModelConversions.h>
#include <Representations/Infrastructure/Image.h>
#include "Representations/Infrastructure/FieldInfo.h"
#include <Representations/Infrastructure/FrameInfo.h>
#include "Representations/Perception/FieldPercept.h"
#include "Representations/Perception/FieldColorPercept.h"
#include "Representations/Perception/CameraMatrix.h"
#include "Representations/Modeling/KinematicChain.h"
#include "Representations/Perception/Histograms.h"
#include "Representations/Perception/MultiBallPercept.h"
// tools
#include "Tools/DoubleCamHelpers.h"
#include "Representations/Debug/Stopwatch.h"
#include "Tools/Debug/DebugRequest.h"
#include "Tools/Debug/DebugImageDrawings.h"
#include "Tools/Debug/DebugParameterList.h"
BEGIN_DECLARE_MODULE(RedBallDetector)
PROVIDE(DebugRequest)
PROVIDE(DebugImageDrawings)
PROVIDE(DebugImageDrawingsTop)
PROVIDE(DebugParameterList)
REQUIRE(FieldInfo)
REQUIRE(FrameInfo)
REQUIRE(Image)
REQUIRE(ImageTop)
REQUIRE(CameraMatrix)
REQUIRE(CameraMatrixTop)
REQUIRE(FieldPercept)
REQUIRE(FieldPerceptTop)
REQUIRE(FieldColorPercept)
REQUIRE(FieldColorPerceptTop)
PROVIDE(MultiBallPercept)
END_DECLARE_MODULE(RedBallDetector)
class RedBallDetector: private RedBallDetectorBase
{
public:
RedBallDetector();
~RedBallDetector();
void execute(CameraInfo::CameraID id);
virtual void execute()
{
getMultiBallPercept().reset();
execute(CameraInfo::Top);
execute(CameraInfo::Bottom);
}
private:
CameraInfo::CameraID cameraID;
class Parameters: public ParameterList
{
public:
Parameters() : ParameterList("RedBallDetector")
{
PARAMETER_REGISTER(stepSize) = 2;
PARAMETER_REGISTER(maxBorderBrightness) = 70;
PARAMETER_REGISTER(minOffsetToFieldY) = 100;
PARAMETER_REGISTER(minOffsetToFieldV) = 10;
PARAMETER_REGISTER(mitUVDifference) = 50;
PARAMETER_REGISTER(thresholdGradientUV) = 6;
PARAMETER_REGISTER(thresholdSanityCheck) = 0.5;
syncWithConfig();
}
~Parameters()
{
}
int stepSize;
int maxBorderBrightness;
int minOffsetToFieldY;
int minOffsetToFieldV;
//int minOffsetToGoalV;
int mitUVDifference;
int thresholdGradientUV;
double thresholdSanityCheck;
} params;
private:
inline bool isOrange(const Pixel& pixel) const {
return getFieldColorPercept().isRedColor(pixel);
}
bool findMaximumRedPoint(std::vector<Vector2i>& points) const;
bool spiderScan(const Vector2i& start, std::vector<Vector2i>& endPoints) const;
bool scanForEdges(const Vector2i& start, const Vector2d& direction, std::vector<Vector2i>& endpoint) const;<--- Function 'scanForEdges' argument 3 names different: declaration 'endpoint' definition 'points'.
void calculateBallPercept(const Vector2i& center, double radius);
bool randomBallScan(const Vector2i& center, double radius) const;
bool sanityCheck(const Vector2i& center, double radius) const;
/*void estimateCircleSimple(const std::vector<Vector2i>& endPoints, Vector2d& center, double& radius) const;*/
private: //data members
std::vector<Vector2i> listOfRedPoints;
std::vector<Vector2i> ballEndPoints;
private:
DOUBLE_CAM_PROVIDE(RedBallDetector, DebugImageDrawings);
// double cam stuff
DOUBLE_CAM_REQUIRE(RedBallDetector, Image);
DOUBLE_CAM_REQUIRE(RedBallDetector, CameraMatrix);
DOUBLE_CAM_REQUIRE(RedBallDetector, FieldColorPercept);
DOUBLE_CAM_REQUIRE(RedBallDetector, FieldPercept);
};//end class RedBallDetector
#endif // _RedBallDetector_H_
|