Gestro
|
checks the number of fingers and sends the respective command to be processed. More...
#include <FingerCounter.h>
Public Member Functions | |
FingerCounter (void) | |
FingerAndCoordinates | findFingersCount (Mat input_image, Mat frame) |
void | ConnectCallback (CaptureAndDetectCallbackInterface *) |
Private Member Functions | |
int | getFinger () |
Point | getHighestPoint (const Mat &frame, const vector< vector< Point >> &contours, int biggest_contour_index, vector< Vec4i > &defects) |
Point | farthest_point (vector< Vec4i > defects, vector< Point > contour, Point centroid) |
double | findPointsDistance (Point a, Point b) |
double | findAngle (Point a, Point b, Point c) |
Private Attributes | |
Scalar | color_blue |
scalar to store blue color More... | |
Scalar | color_green |
scalar to store green color More... | |
Scalar | color_white |
scalar to store white color More... | |
Scalar | color_yellow |
scalar to store yellow color More... | |
CaptureAndDetectCallbackInterface * | palmCallback |
Callback interface to detect fist. More... | |
vector< int > | fingers |
to store number of fingers in the buffer for 15 frames More... | |
int | currentFinger = 0 |
store the current detected finger More... | |
int | oldFinger = 0 |
last detected finger More... | |
Point | oldFarPoint |
last detected far point More... | |
Iir::Butterworth::LowPass< 2 > | xFilter |
2nd order low pass iir filter to process x coordinates More... | |
Iir::Butterworth::LowPass< 2 > | yFilter |
2nd order low pass iir filter to process y coordinates More... | |
checks the number of fingers and sends the respective command to be processed.
This class is called from the CaptureAndDetect after the initial image processing is done, the fingers and stored in the buffer. Once the buffer size is 15 the finger that occurs the most number of times in the buffer is considered and the appropriate command is sent. If finger is one or 3 then the coordinates are sent until a new finger is detected.
Definition at line 23 of file FingerCounter.h.
FingerCounter::FingerCounter | ( | void | ) |
The constructor for the FingerCounter class. Initializes the colors and iir filters.
Definition at line 5 of file FingerCounter.cpp.
void FingerCounter::ConnectCallback | ( | CaptureAndDetectCallbackInterface * | callback | ) |
This function is used to connect the callback interface of CaptureAndDetect with this class
callback | The callback function that will be called when the fist is detected. |
Definition at line 14 of file FingerCounter.cpp.
|
private |
It returns the point on the contour that is the farthest from the centroid
defects | the convexity defects of the hand |
contour | the contour of the hand |
centroid | The centroid of the hand |
Definition at line 150 of file FingerCounter.cpp.
|
private |
It finds the angle between the three points
a | point one |
b | point two |
c | point three |
Definition at line 166 of file FingerCounter.cpp.
FingerAndCoordinates FingerCounter::findFingersCount | ( | Mat | input_image, |
Mat | frame | ||
) |
It finds the contours of the hand, finds the convex hull and the defects, and then counts the number of fingers
input_image | The image that we want to find the fingers in. |
frame | The frame from the camera |
Definition at line 18 of file FingerCounter.cpp.
|
private |
It finds the distance between two points
a | The first point |
b | The second point. |
Definition at line 161 of file FingerCounter.cpp.
|
private |
It counts the number of times each finger is detected and returns the finger that is detected the most
Definition at line 134 of file FingerCounter.cpp.
|
private |
It finds the highest point of the hand
frame | The frame to draw on |
contours | The contours of the hand |
biggest_contour_index | The index of the biggest contour in the vector of contours. |
defects | The convexity defects of the hand. |
Definition at line 125 of file FingerCounter.cpp.
|
private |
scalar to store blue color
Definition at line 49 of file FingerCounter.h.
|
private |
scalar to store green color
Definition at line 51 of file FingerCounter.h.
|
private |
scalar to store white color
Definition at line 53 of file FingerCounter.h.
|
private |
scalar to store yellow color
Definition at line 55 of file FingerCounter.h.
|
private |
store the current detected finger
Definition at line 61 of file FingerCounter.h.
|
private |
to store number of fingers in the buffer for 15 frames
Definition at line 59 of file FingerCounter.h.
|
private |
last detected far point
Definition at line 65 of file FingerCounter.h.
|
private |
last detected finger
Definition at line 63 of file FingerCounter.h.
|
private |
Callback interface to detect fist.
Definition at line 57 of file FingerCounter.h.
|
private |
2nd order low pass iir filter to process x coordinates
Definition at line 68 of file FingerCounter.h.
|
private |
2nd order low pass iir filter to process y coordinates
Definition at line 70 of file FingerCounter.h.