Gestro
Public Member Functions | Private Member Functions | Private Attributes | List of all members
GestureDetection::FingerCounter Class Reference

checks the number of fingers and sends the respective command to be processed. More...

#include <FingerCounter.h>

Collaboration diagram for GestureDetection::FingerCounter:
Collaboration graph

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...
 
CaptureAndDetectCallbackInterfacepalmCallback
 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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ FingerCounter()

FingerCounter::FingerCounter ( void  )

The constructor for the FingerCounter class. Initializes the colors and iir filters.

Definition at line 5 of file FingerCounter.cpp.

Member Function Documentation

◆ ConnectCallback()

void FingerCounter::ConnectCallback ( CaptureAndDetectCallbackInterface callback)

This function is used to connect the callback interface of CaptureAndDetect with this class

Parameters
callbackThe callback function that will be called when the fist is detected.

Definition at line 14 of file FingerCounter.cpp.

Here is the caller graph for this function:

◆ farthest_point()

Point FingerCounter::farthest_point ( vector< Vec4i >  defects,
vector< Point >  contour,
Point  centroid 
)
private

It returns the point on the contour that is the farthest from the centroid

Parameters
defectsthe convexity defects of the hand
contourthe contour of the hand
centroidThe centroid of the hand
Returns
the point with the highest y value.

Definition at line 150 of file FingerCounter.cpp.

Here is the caller graph for this function:

◆ findAngle()

double FingerCounter::findAngle ( Point  a,
Point  b,
Point  c 
)
private

It finds the angle between the three points

Parameters
apoint one
bpoint two
cpoint three
Returns
The angle between the three points.

Definition at line 166 of file FingerCounter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findFingersCount()

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

Parameters
input_imageThe image that we want to find the fingers in.
frameThe frame from the camera
Returns
a struct of type FingerAndCoordinates.

Definition at line 18 of file FingerCounter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findPointsDistance()

double FingerCounter::findPointsDistance ( Point  a,
Point  b 
)
private

It finds the distance between two points

Parameters
aThe first point
bThe second point.
Returns
The distance between two points.

Definition at line 161 of file FingerCounter.cpp.

Here is the caller graph for this function:

◆ getFinger()

int FingerCounter::getFinger ( )
private

It counts the number of times each finger is detected and returns the finger that is detected the most

Returns
The finger that is most frequently detected.

Definition at line 134 of file FingerCounter.cpp.

Here is the caller graph for this function:

◆ getHighestPoint()

Point FingerCounter::getHighestPoint ( const Mat &  frame,
const vector< vector< Point >> &  contours,
int  biggest_contour_index,
vector< Vec4i > &  defects 
)
private

It finds the highest point of the hand

Parameters
frameThe frame to draw on
contoursThe contours of the hand
biggest_contour_indexThe index of the biggest contour in the vector of contours.
defectsThe convexity defects of the hand.
Returns
The highest point of the hand.

Definition at line 125 of file FingerCounter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ color_blue

Scalar GestureDetection::FingerCounter::color_blue
private

scalar to store blue color

Definition at line 49 of file FingerCounter.h.

◆ color_green

Scalar GestureDetection::FingerCounter::color_green
private

scalar to store green color

Definition at line 51 of file FingerCounter.h.

◆ color_white

Scalar GestureDetection::FingerCounter::color_white
private

scalar to store white color

Definition at line 53 of file FingerCounter.h.

◆ color_yellow

Scalar GestureDetection::FingerCounter::color_yellow
private

scalar to store yellow color

Definition at line 55 of file FingerCounter.h.

◆ currentFinger

int GestureDetection::FingerCounter::currentFinger = 0
private

store the current detected finger

Definition at line 61 of file FingerCounter.h.

◆ fingers

vector<int> GestureDetection::FingerCounter::fingers
private

to store number of fingers in the buffer for 15 frames

Definition at line 59 of file FingerCounter.h.

◆ oldFarPoint

Point GestureDetection::FingerCounter::oldFarPoint
private

last detected far point

Definition at line 65 of file FingerCounter.h.

◆ oldFinger

int GestureDetection::FingerCounter::oldFinger = 0
private

last detected finger

Definition at line 63 of file FingerCounter.h.

◆ palmCallback

CaptureAndDetectCallbackInterface* GestureDetection::FingerCounter::palmCallback
private

Callback interface to detect fist.

Definition at line 57 of file FingerCounter.h.

◆ xFilter

Iir::Butterworth::LowPass<2> GestureDetection::FingerCounter::xFilter
private

2nd order low pass iir filter to process x coordinates

Definition at line 68 of file FingerCounter.h.

◆ yFilter

Iir::Butterworth::LowPass<2> GestureDetection::FingerCounter::yFilter
private

2nd order low pass iir filter to process y coordinates

Definition at line 70 of file FingerCounter.h.


The documentation for this class was generated from the following files: