kNOw SIGN
Public Member Functions | Private Member Functions | List of all members
handDetect Class Reference

Class to detect the hand from a video stream using thresholding and contours. More...

#include <handDetect.h>

Public Member Functions

 handDetect ()
 constructor More...
 
void init (FrameGen *m)
 Function to take the initial video stream and specify the area of calibrartion squares. More...
 
void waitForPalmCover (FrameGen *m)
 specify the location of the calibration squares on the incoming frame and draw them More...
 
void average (FrameGen *m)
 calculate the final average color of the hand in hue lightness saturation space based on average skin color from the calibration squares to find the threshold and detect the hand. More...
 
void initTrackbars ()
 create trackbars to be able to manually adjust the threshold if needed. To use the trackbars, umcomment the function in the main file. More...
 
void produceBinaries (FrameGen *m)
 getting the lower and upper boundries of the hand color. the function calculate these boundries based on the average color from the calibration squares after normalization and then perform median Blur to remove the noise More...
 
cv::Mat crop (FrameGen *m, InterHand *hg)
 crop the detected hand area of each frame and store it in Mat object to be fed to the inference model More...
 
void makeContours (FrameGen *m, InterHand *hg)
 create contours for the hand from the incoming frame to get the hand location and detect the hand More...
 

Private Member Functions

void col2origCol (int hsv[3], int bgr[3], cv::Mat src)
 convert the frame color to the original color from two input color spaces More...
 
void printText (cv::Mat src, std::string text)
 function to print text on the frame when needed More...
 
int getMedian (std::vector< int > val)
 calculate the median value of the color averaging results More...
 
void getAvgColor (FrameGen *m, My_ROI roi, int avg[3])
 aquire the average hand skin color from the calibration squares More...
 
void normalizeColors (FrameGen *myImage)
 get the color boundries and normalize them to 0-255 More...
 
int findBiggestContour (std::vector< std::vector< cv::Point >> contours)
 get the biggest contours and remove the cotours that do not represent hands More...
 

Detailed Description

Class to detect the hand from a video stream using thresholding and contours.

Firstly, the skin color is sampled through several squares in the frame in different locations. Next, the average of these samples is taken and the resulting values are transformed into HLS. After that, contours are calculated and the biggest contour is considered as the hand. The hand area is then calculated and the cropped to be fed to the inference core.

Constructor & Destructor Documentation

◆ handDetect()

handDetect::handDetect ( )

constructor

Member Function Documentation

◆ average()

void handDetect::average ( FrameGen m)

calculate the final average color of the hand in hue lightness saturation space based on average skin color from the calibration squares to find the threshold and detect the hand.

◆ col2origCol()

void handDetect::col2origCol ( int  hsv[3],
int  bgr[3],
cv::Mat  src 
)
private

convert the frame color to the original color from two input color spaces

◆ crop()

cv::Mat handDetect::crop ( FrameGen m,
InterHand hg 
)

crop the detected hand area of each frame and store it in Mat object to be fed to the inference model

◆ findBiggestContour()

int handDetect::findBiggestContour ( std::vector< std::vector< cv::Point >>  contours)
private

get the biggest contours and remove the cotours that do not represent hands

◆ getAvgColor()

void handDetect::getAvgColor ( FrameGen m,
My_ROI  roi,
int  avg[3] 
)
private

aquire the average hand skin color from the calibration squares

◆ getMedian()

int handDetect::getMedian ( std::vector< int >  val)
private

calculate the median value of the color averaging results

◆ init()

void handDetect::init ( FrameGen m)

Function to take the initial video stream and specify the area of calibrartion squares.

◆ initTrackbars()

void handDetect::initTrackbars ( )

create trackbars to be able to manually adjust the threshold if needed. To use the trackbars, umcomment the function in the main file.

◆ makeContours()

void handDetect::makeContours ( FrameGen m,
InterHand hg 
)

create contours for the hand from the incoming frame to get the hand location and detect the hand

◆ normalizeColors()

void handDetect::normalizeColors ( FrameGen myImage)
private

get the color boundries and normalize them to 0-255

◆ printText()

void handDetect::printText ( cv::Mat  src,
std::string  text 
)
private

function to print text on the frame when needed

◆ produceBinaries()

void handDetect::produceBinaries ( FrameGen m)

getting the lower and upper boundries of the hand color. the function calculate these boundries based on the average color from the calibration squares after normalization and then perform median Blur to remove the noise

◆ waitForPalmCover()

void handDetect::waitForPalmCover ( FrameGen m)

specify the location of the calibration squares on the incoming frame and draw them


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