[ADD] comments
This commit is contained in:
@@ -24,9 +24,6 @@ namespace computervision
|
|||||||
FaceDetector faceDetector;
|
FaceDetector faceDetector;
|
||||||
FingerCount fingerCount;
|
FingerCount fingerCount;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ObjectDetection::ObjectDetection()
|
ObjectDetection::ObjectDetection()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -41,16 +38,22 @@ namespace computervision
|
|||||||
Mat inputFrame = generateHandMaskSquare(cameraFrame);
|
Mat inputFrame = generateHandMaskSquare(cameraFrame);
|
||||||
frameOut = inputFrame.clone();
|
frameOut = inputFrame.clone();
|
||||||
|
|
||||||
|
// detect skin color
|
||||||
skinDetector.drawSkinColorSampler(frameOut);
|
skinDetector.drawSkinColorSampler(frameOut);
|
||||||
|
|
||||||
|
// remove background from image
|
||||||
foreground = backgroundRemover.getForeground(inputFrame);
|
foreground = backgroundRemover.getForeground(inputFrame);
|
||||||
|
|
||||||
//faceDetector.removeFaces(inputFrame, foreground);
|
// detect the hand contours
|
||||||
handMask = skinDetector.getSkinMask(foreground);
|
handMask = skinDetector.getSkinMask(foreground);
|
||||||
|
|
||||||
|
// count the amount of fingers and put the info on the matrix
|
||||||
fingerCountDebug = fingerCount.findFingersCount(handMask, frameOut);
|
fingerCountDebug = fingerCount.findFingersCount(handMask, frameOut);
|
||||||
|
|
||||||
|
// get the amount of fingers
|
||||||
int fingers_amount = fingerCount.getAmountOfFingers();
|
int fingers_amount = fingerCount.getAmountOfFingers();
|
||||||
//backgroundRemover.calibrate(frame);
|
|
||||||
|
// draw the hand rectangle on the camera input, and draw text showing if the hand is open or closed.
|
||||||
drawHandMaskRect(&cameraFrame);
|
drawHandMaskRect(&cameraFrame);
|
||||||
string hand_text = fingers_amount > 0 ? "open" : "closed";
|
string hand_text = fingers_amount > 0 ? "open" : "closed";
|
||||||
putText(cameraFrame,hand_text, Point(10, 75), FONT_HERSHEY_PLAIN, 2.0, Scalar(255, 0, 255),3);
|
putText(cameraFrame,hand_text, Point(10, 75), FONT_HERSHEY_PLAIN, 2.0, Scalar(255, 0, 255),3);
|
||||||
@@ -63,9 +66,9 @@ namespace computervision
|
|||||||
|
|
||||||
int key = waitKey(1);
|
int key = waitKey(1);
|
||||||
|
|
||||||
if (key == 98) // b
|
if (key == 98) // b, calibrate the background
|
||||||
backgroundRemover.calibrate(inputFrame);
|
backgroundRemover.calibrate(inputFrame);
|
||||||
else if (key == 115) // s
|
else if (key == 115) // s, calibrate the skin color
|
||||||
skinDetector.calibrate(inputFrame);
|
skinDetector.calibrate(inputFrame);
|
||||||
|
|
||||||
return fingers_amount > 0;
|
return fingers_amount > 0;
|
||||||
@@ -113,16 +116,6 @@ namespace computervision
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectDetection::detect()
|
|
||||||
{
|
|
||||||
int key = waitKey(1);
|
|
||||||
|
|
||||||
if (key == 98) // b
|
|
||||||
backgroundRemover.calibrate(frame);
|
|
||||||
else if (key == 115) // s
|
|
||||||
skinDetector.calibrate(frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ObjectDetection::showWebcam()
|
void ObjectDetection::showWebcam()
|
||||||
{
|
{
|
||||||
imshow("Webcam image", img);
|
imshow("Webcam image", img);
|
||||||
|
|||||||
Reference in New Issue
Block a user