[ADD] hand detection in startup scene
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user