-
Notifications
You must be signed in to change notification settings - Fork 3
/
ballDetector.h
28 lines (22 loc) · 957 Bytes
/
ballDetector.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
#ifndef _BALLDETECTOR_H_
#define _BALLDETECTOR_H_
#include "opencv2/bgsegm.hpp"
#include "opencv2/features2d.hpp"
using namespace cv;
using namespace std;
#define SSTR( x ) static_cast< std::ostringstream & >( \
( std::ostringstream() << std::dec << x ) ).str()
// Class to detect ball by using simple background subtraction
// (more info: http://docs.opencv.org/trunk/d1/dc5/tutorial_background_subtraction.html)
class BallDetector {
private:
int keypointSizeThreshold; // all keypoints smaller than this will be considered as noise
Ptr<BackgroundSubtractor> pMOG2; // MOG2 Background subtractor
Ptr<SimpleBlobDetector> detector; // Blob detector with default parameters (http://docs.opencv.org/trunk/d0/d7a/classcv_1_1SimpleBlobDetector.html)
Mat fgMaskMOG2; // fg mask generated by MOG2 method
public:
BallDetector(int keypointNoiseThreshold);
void clearBackgroundModel();
void detectionStep(Mat& frame, Point2f& center);
};
#endif