libVision  1.0
A vision library made by FRC team #4529
TargetDetector.h
Go to the documentation of this file.
1 #ifndef TARGETDETECTOR_H
2 #define TARGETDETECTOR_H
3 
10 #include <opencv2/imgproc/imgproc.hpp>
11 
12 using namespace cv;
13 
17 struct LineDetails {
18  int length,
19  xPos;
20 };
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
29 enum rotation_t {
31  NONE = 0,
32  CLOCKWISE = 1
33 };
34 
38 typedef struct LineResult {
39  bool isProcessed,
41  isGood;
42  float xPos;
43  float width;
46 } LineResult;
47 
48 #ifdef __cplusplus
49 }
50 #endif
51 
61 public:
66  TargetDetector(Mat &_image);
70  virtual ~TargetDetector();
75  void prepareImage();
80  void findContours();
86  bool filterContours(); // Check and eliminate invalid contours - if this returns false, this frame doesn't contain the target
96  LineResult getContours();
103 
104 private:
105  Mat &image;
106  vector<vector<Point> > contours, validContours;
107  vector<Vec4i> hierarchy;
108  LineResult result;
109  bool shouldFilterContours;
110 
111 };
112 
113 #endif /* TARGETDETECTOR_H */
114 
int xPos
The X position of the start point of the line.
Definition: TargetDetector.h:18
Vision processing/target acquisition code.
Definition: TargetDetector.h:60
Rotated clockwise.
Definition: TargetDetector.h:32
rotation_t
Rotation direction.
Definition: TargetDetector.h:29
rotation_t rotation
Rotation direction of the target.
Definition: TargetDetector.h:45
Result returned from TargetDetector::getContours()
Definition: TargetDetector.h:38
Rotated anticlockwise.
Definition: TargetDetector.h:30
float width
Combined width of the bounding boxes of the targets - goes from 0.0f to 100.0f.
Definition: TargetDetector.h:43
float xPos
Centeral X position of the target - goes from -100.0f to 100.0f, 0.0f being centered.
Definition: TargetDetector.h:42
int thresholdVal
Threshold value for cuttoff when running prepareImage.
Definition: TargetDetector.h:102
For comparison of lines.
Definition: TargetDetector.h:17
Not rotated.
Definition: TargetDetector.h:31
struct LineResult LineResult
Result returned from TargetDetector::getContours()