[ADD] hand detection in startup scene

This commit is contained in:
Sem van der Hoeven
2021-06-18 17:15:26 +02:00
parent c1ba33e55b
commit 7c3d68a742
7 changed files with 59 additions and 73 deletions

View File

@@ -23,6 +23,7 @@ namespace computervision
bool background_calibrated = false;
bool skin_calibrated = false;
bool hand_open = false;
ObjectDetection::ObjectDetection()
{
@@ -94,6 +95,7 @@ namespace computervision
skin_calibrated = true;
hand_calibrator.SetSkinCalibration(skin_calibrated);
time = 0;
calibration_callback();
}
}
@@ -126,8 +128,8 @@ namespace computervision
hand_present = hand_calibrator.CheckIfHandPresent(handMask, handcalibration::HandDetectionType::MENU);
hand_calibrator.SetHandPresent(hand_present);
return fingers_amount > 0;
hand_open = fingers_amount > 0;
return hand_open;
}
void ObjectDetection::CalculateDifference()
@@ -187,5 +189,15 @@ namespace computervision
time += delt_time;
}
bool ObjectDetection::IsHandOpen()
{
return hand_open;
}
bool ObjectDetection::IsCalibrated()
{
return background_calibrated && skin_calibrated;
}
}

View File

@@ -11,6 +11,7 @@
#include <opencv2/video.hpp>
#include <GLFW/glfw3.h>
#include <functional>
#include "background_remover.h"
#include "skin_detector.h"
#include "finger_count.h"
@@ -81,6 +82,8 @@ namespace computervision
*/
bool IsHandOpen();
bool IsCalibrated();
/**
* @brief checks whether the hand is held within the detection square.
@@ -91,10 +94,13 @@ namespace computervision
cv::VideoCapture GetCap();
void SetCalibrationCallback(std::function<void()> fun) { calibration_callback = fun; };
private:
bool is_hand_open;
bool is_hand_present;
void UpdateTime();
std::function<void()> calibration_callback;
};