diff --git a/src/computervision/OpenPoseVideo.cpp b/src/computervision/OpenPoseVideo.cpp index 9cf1cad..dbaf6e5 100644 --- a/src/computervision/OpenPoseVideo.cpp +++ b/src/computervision/OpenPoseVideo.cpp @@ -44,7 +44,7 @@ namespace computervision net = readNetFromCaffe(protoFile, weightsFile); } - void OpenPoseVideo::movementSkeleton(Mat inputImage, std::function)> f) { + void OpenPoseVideo::movementSkeleton(Mat inputImage, std::function,cv::Mat poinst_on_image)> f) { std::cout << "movement skeleton start" << std::endl; int inWidth = 368; @@ -60,7 +60,7 @@ namespace computervision frame = inputImage; Mat inpBlob = blobFromImage(frame, 1.0 / 255, Size(inWidth, inHeight), Scalar(0, 0, 0), false, false); - + std::cout << "done reading image and blob" << std::endl; net.setInput(inpBlob); @@ -96,9 +96,10 @@ namespace computervision } cv::putText(frame, cv::format("time taken = %.2f sec", t), cv::Point(50, 50), cv::FONT_HERSHEY_COMPLEX, .8, cv::Scalar(255, 50, 0), 2); - // imshow("Output-Keypoints", frameCopy); - imshow("Output-Skeleton", frame); + std::cout << "time taken: " << t << std::endl; + //imshow("Output-Keypoints", frame); + //imshow("Output-Skeleton", frame); std::cout << "about to call points receiving method" << std::endl; - f(points); + f(points,frame); } } \ No newline at end of file diff --git a/src/computervision/OpenPoseVideo.h b/src/computervision/OpenPoseVideo.h index 8b9d75e..7f61449 100644 --- a/src/computervision/OpenPoseVideo.h +++ b/src/computervision/OpenPoseVideo.h @@ -13,7 +13,7 @@ namespace computervision private: public: - void movementSkeleton(Mat inputImage,std::function)> f); + void movementSkeleton(Mat inputImage,std::function, cv::Mat poinst_on_image)> f); void setup(); }; } diff --git a/src/computervision/async/async_arm_detection.cpp b/src/computervision/async/async_arm_detection.cpp index cd88542..e9649a1 100644 --- a/src/computervision/async/async_arm_detection.cpp +++ b/src/computervision/async/async_arm_detection.cpp @@ -2,6 +2,7 @@ #include "async_arm_detection.h" #include "../OpenPoseVideo.h" #include +#include "StaticCameraInstance.h" namespace computervision @@ -11,8 +12,10 @@ namespace computervision } - void AsyncArmDetection::run_arm_detection(std::function)> points_ready_func, cv::VideoCapture cap, OpenPoseVideo op) + void AsyncArmDetection::run_arm_detection(std::function, cv::Mat poinst_on_image)> points_ready_func, OpenPoseVideo op) { + VideoCapture cap = static_camera::getCap(); + std::cout << "STARTING THREAD LAMBDA" << std::endl; /*cv::VideoCapture cap = static_camera::getCap();*/ @@ -30,13 +33,13 @@ namespace computervision } } - void AsyncArmDetection::start(std::function)> points_ready_func, cv::VideoCapture cap, OpenPoseVideo op) + void AsyncArmDetection::start(std::function, cv::Mat poinst_on_image)> points_ready_func, OpenPoseVideo op) { std::cout << "starting function" << std::endl; - std::thread async_arm_detect_thread(&AsyncArmDetection::run_arm_detection,this, points_ready_func, cap, op); + std::thread async_arm_detect_thread(&AsyncArmDetection::run_arm_detection,this, points_ready_func, 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 c577dc7..98fd163 100644 --- a/src/computervision/async/async_arm_detection.h +++ b/src/computervision/async/async_arm_detection.h @@ -15,9 +15,9 @@ namespace computervision AsyncArmDetection(void); - void start(std::function)>, cv::VideoCapture cap, computervision::OpenPoseVideo op); + void start(std::function, cv::Mat poinst_on_image)>, computervision::OpenPoseVideo op); private: - void run_arm_detection(std::function)> points_ready_func, cv::VideoCapture cap, OpenPoseVideo op); + void run_arm_detection(std::function, cv::Mat poinst_on_image)> points_ready_func, OpenPoseVideo op); }; } diff --git a/src/main.cpp b/src/main.cpp index 00492e6..260694c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,11 +32,16 @@ static double UpdateDelta(); static GLFWwindow* window; +bool points_img_available = false; +cv::Mat points_img; -void retrieve_points(std::vector arm_points) +void retrieve_points(std::vector arm_points, cv::Mat points_on_image) { + std::cout << "got points!!" << std::endl; std::cout << "points: " << arm_points << std::endl; + points_img = points_on_image; + points_img_available = true; } int main(void) @@ -82,11 +87,15 @@ int main(void) // set up object detection //objDetect.setup(); - cv::Mat cameraFrame; + cv::VideoCapture cam = objDetect.getCap(); + cv::Mat img; + cam.read(img); + imshow("camera in main loop", img); computervision::AsyncArmDetection as; - as.start(retrieve_points, objDetect.getCap(),openPoseVideo); + + as.start(retrieve_points,openPoseVideo); // Main game loop @@ -105,8 +114,12 @@ int main(void) render_engine::renderer::Render(entity, shader); - cameraFrame = objDetect.readCamera(); //objDetect.detectHand(cameraFrame); + if (points_img_available) + { + imshow("points", points_img); + points_img_available = false; + } // Finish up shader.Stop(); diff --git a/wk2_fps.vcxproj b/wk2_fps.vcxproj index ddc8113..64c02b8 100644 --- a/wk2_fps.vcxproj +++ b/wk2_fps.vcxproj @@ -131,8 +131,8 @@ false - $(VC_IncludePath);$(WindowsSDK_IncludePath);;C:\opencv\opencv\build\include - $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);C:\opencv\opencv\build\x64\vc15\lib + C:\opencv\build\include\;$(VC_IncludePath);$(WindowsSDK_IncludePath);C:\opencv\opencv\build\include + C:\opencv\build\x64\vc15\lib;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);C:\opencv\opencv\build\x64\vc15\lib @@ -205,7 +205,7 @@ true true $(SolutionDir)lib\glfw-3.3.2\$(Platform);$(SolutionDir)lib\glew-2.1.0\lib\Release\$(Platform);%(AdditionalLibraryDirectories) - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies); opencv_world452.lib + opencv_world452.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)