[ADD] static camera instance

This commit is contained in:
Sem van der Hoeven
2021-06-02 10:05:09 +02:00
parent cc7cb37840
commit 1a149b8b7e
8 changed files with 24 additions and 6 deletions

View File

@@ -8,10 +8,10 @@
#include "SkinDetector.h" #include "SkinDetector.h"
#include "FaceDetector.h" #include "FaceDetector.h"
#include "FingerCount.h" #include "FingerCount.h"
#include "async/StaticCameraInstance.h"
namespace computervision namespace computervision
{ {
cv::VideoCapture cap(0);
cv::Mat img, imgGray, img2, img2Gray, img3, img4; cv::Mat img, imgGray, img2, img2Gray, img3, img4;
@@ -24,6 +24,8 @@ namespace computervision
FaceDetector faceDetector; FaceDetector faceDetector;
FingerCount fingerCount; FingerCount fingerCount;
cv::VideoCapture cap = computervision_async::getCap();
ObjectDetection::ObjectDetection() ObjectDetection::ObjectDetection()
{ {
} }

View File

@@ -65,6 +65,7 @@ namespace computervision
*/ */
bool drawHandMaskRect(cv::Mat *input); bool drawHandMaskRect(cv::Mat *input);
cv::VideoCapture getCap(); cv::VideoCapture getCap();
}; };

View File

@@ -0,0 +1,12 @@
#pragma once
#include <opencv2/videoio.hpp>
namespace static_camera
{
static cv::VideoCapture getCap()
{
static cv::VideoCapture cap(0);
return cap;
}
};

View File

@@ -21,12 +21,12 @@ namespace computervision
auto lambda = [](std::function<void(std::vector<Point>)> f, cv::VideoCapture c, OpenPoseVideo op) { auto lambda = [](std::function<void(std::vector<Point>)> f, cv::VideoCapture c, OpenPoseVideo op) {
std::cout << "STARTING THREAD LAMBDA" << std::endl; std::cout << "STARTING THREAD LAMBDA" << std::endl;
cv::VideoCapture cap(0); cv::VideoCapture cap = computervision_async::getCap();
if (!cap.isOpened()) if (!cap.isOpened())
{ {
std::cout << "error opening video" << std::endl; std::cout << "capture was closed, opening..." << std::endl;
return; cap.open(0);
} }
while (true) while (true)

View File

@@ -4,6 +4,7 @@
#include <opencv2/videoio.hpp> #include <opencv2/videoio.hpp>
#include <functional> #include <functional>
#include "../OpenPoseVideo.h" #include "../OpenPoseVideo.h"
#include "StaticCameraInstance.h"
namespace computervision namespace computervision

View File

@@ -85,8 +85,6 @@ int main(void)
cv::Mat cameraFrame; cv::Mat cameraFrame;
//openPoseVideo.setup();
computervision::AsyncArmDetection as; computervision::AsyncArmDetection as;
as.start(retrieve_points, objDetect.getCap(),openPoseVideo); as.start(retrieve_points, objDetect.getCap(),openPoseVideo);

View File

@@ -38,6 +38,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="src\computervision\async\async_arm_detection.h" /> <ClInclude Include="src\computervision\async\async_arm_detection.h" />
<ClInclude Include="src\computervision\async\StaticCameraInstance.h" />
<ClInclude Include="src\computervision\FaceDetector.h" /> <ClInclude Include="src\computervision\FaceDetector.h" />
<ClInclude Include="src\computervision\FingerCount.h" /> <ClInclude Include="src\computervision\FingerCount.h" />
<ClInclude Include="src\computervision\BackgroundRemover.h" /> <ClInclude Include="src\computervision\BackgroundRemover.h" />

View File

@@ -116,6 +116,9 @@
<ClInclude Include="src\computervision\async\async_arm_detection.h"> <ClInclude Include="src\computervision\async\async_arm_detection.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\computervision\async\StaticCameraInstance.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Xml Include="res\haarcascade_frontalface_alt.xml" /> <Xml Include="res\haarcascade_frontalface_alt.xml" />