diff --git a/src/computervision/ObjectDetection.cpp b/src/computervision/ObjectDetection.cpp index dc405ac..b305e71 100644 --- a/src/computervision/ObjectDetection.cpp +++ b/src/computervision/ObjectDetection.cpp @@ -24,7 +24,7 @@ namespace computervision FaceDetector faceDetector; FingerCount fingerCount; - cv::VideoCapture cap = computervision_async::getCap(); + cv::VideoCapture cap = static_camera::getCap(); ObjectDetection::ObjectDetection() { diff --git a/src/computervision/async/async_arm_detection.cpp b/src/computervision/async/async_arm_detection.cpp index 2557e6e..cd88542 100644 --- a/src/computervision/async/async_arm_detection.cpp +++ b/src/computervision/async/async_arm_detection.cpp @@ -11,33 +11,33 @@ namespace computervision } - void AsyncArmDetection::run_arm_detection() + void AsyncArmDetection::run_arm_detection(std::function)> points_ready_func, cv::VideoCapture cap, OpenPoseVideo op) { + std::cout << "STARTING THREAD LAMBDA" << std::endl; + /*cv::VideoCapture cap = static_camera::getCap();*/ + if (!cap.isOpened()) + { + std::cout << "capture was closed, opening..." << std::endl; + cap.open(0); + } + + while (true) + { + Mat img; + cap.read(img); + op.movementSkeleton(img, points_ready_func); + } } void AsyncArmDetection::start(std::function)> points_ready_func, cv::VideoCapture cap, OpenPoseVideo op) { - auto lambda = [](std::function)> f, cv::VideoCapture c, OpenPoseVideo op) { - std::cout << "STARTING THREAD LAMBDA" << std::endl; - cv::VideoCapture cap = computervision_async::getCap(); - - if (!cap.isOpened()) - { - std::cout << "capture was closed, opening..." << std::endl; - cap.open(0); - } - - while (true) - { - Mat img; - cap.read(img); - op.movementSkeleton(img, f); - } - }; - std::cout << "starting function" << std::endl; - std::thread async_arm_detect_thread(lambda, points_ready_func, cap, op); + + + std::thread async_arm_detect_thread(&AsyncArmDetection::run_arm_detection,this, points_ready_func, cap, op); + + async_arm_detect_thread.detach(); // makes sure the thread is detached from the variable. } } diff --git a/src/computervision/async/async_arm_detection.h b/src/computervision/async/async_arm_detection.h index a265ce6..c577dc7 100644 --- a/src/computervision/async/async_arm_detection.h +++ b/src/computervision/async/async_arm_detection.h @@ -17,7 +17,7 @@ namespace computervision void start(std::function)>, cv::VideoCapture cap, computervision::OpenPoseVideo op); private: - void run_arm_detection(); + void run_arm_detection(std::function)> points_ready_func, cv::VideoCapture cap, OpenPoseVideo op); }; }