diff --git a/src/computervision/HandDetectRegion.cpp b/src/computervision/HandDetectRegion.cpp index 3ef6c28..87f3538 100644 --- a/src/computervision/HandDetectRegion.cpp +++ b/src/computervision/HandDetectRegion.cpp @@ -34,7 +34,7 @@ namespace computervision //imshow("output" + region_id, frame_out); //imshow("foreground" + region_id, foreground); - imshow("handMask" + region_id, handMask); + //imshow("handMask" + region_id, handMask); /*imshow("handDetection", fingerCountDebug);*/ hand_present = hand_calibrator.CheckIfHandPresent(handMask,handcalibration::HandDetectionType::GAME); @@ -47,6 +47,8 @@ namespace computervision hand_calibrator.DrawBackgroundSkinCalibrated(camera_frame); + + } cv::Mat HandDetectRegion::GenerateHandMaskSquare(cv::Mat img) diff --git a/src/computervision/HandDetectRegion.h b/src/computervision/HandDetectRegion.h index 7cc1a9a..067badd 100644 --- a/src/computervision/HandDetectRegion.h +++ b/src/computervision/HandDetectRegion.h @@ -7,6 +7,7 @@ #include "BackgroundRemover.h" #include "SkinDetector.h" #include "FingerCount.h" +#include "calibration/StaticSkinTreshold.h" namespace computervision { class HandDetectRegion diff --git a/src/computervision/ObjectDetection.cpp b/src/computervision/ObjectDetection.cpp index 155512e..ad3e13e 100644 --- a/src/computervision/ObjectDetection.cpp +++ b/src/computervision/ObjectDetection.cpp @@ -10,6 +10,8 @@ #include "async/StaticCameraInstance.h" #include "calibration/HandCalibrator.h" +#include "calibration/StaticSkinTreshold.h" + namespace computervision { @@ -62,7 +64,6 @@ namespace computervision // draw the hand rectangle on the camera input, and draw text showing if the hand is open or closed. DrawHandMask(&camera_frame); - hand_calibrator.SetAmountOfFingers(fingers_amount); finger_count.DrawHandContours(camera_frame); @@ -88,7 +89,13 @@ namespace computervision } else if (key == 115) // s, calibrate the skin color { - skin_detector.calibrate(input_frame); + std::vector treshold = skin_detector.calibrateAndReturn(input_frame); + StaticSkinTreshold::hLowThreshold = treshold[0]; + StaticSkinTreshold::hHighThreshold = treshold[1]; + StaticSkinTreshold::sLowThreshold = treshold[2]; + StaticSkinTreshold::sHighThreshold = treshold[3]; + StaticSkinTreshold::vLowThreshold = treshold[4]; + StaticSkinTreshold::vHighThreshold = treshold[5]; hand_calibrator.SetSkinCalibration(true); } diff --git a/src/computervision/calibration/StaticSkinTreshold.h b/src/computervision/calibration/StaticSkinTreshold.h new file mode 100644 index 0000000..cfce1f7 --- /dev/null +++ b/src/computervision/calibration/StaticSkinTreshold.h @@ -0,0 +1,10 @@ +#pragma once +namespace StaticSkinTreshold +{ + static int hLowThreshold, + hHighThreshold, + sLowThreshold, + sHighThreshold, + vLowThreshold, + vHighThreshold; +}; diff --git a/src/scenes/in_Game_Scene.cpp b/src/scenes/in_Game_Scene.cpp index 44db2e9..48d099b 100644 --- a/src/scenes/in_Game_Scene.cpp +++ b/src/scenes/in_Game_Scene.cpp @@ -130,6 +130,7 @@ namespace scene { if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS) { + cv::destroyWindow("camera"); return_value = scene::Scenes::STOP; }