[FIX] showing of pose detection points
This commit is contained in:
@@ -44,7 +44,7 @@ namespace computervision
|
|||||||
net = readNetFromCaffe(protoFile, weightsFile);
|
net = readNetFromCaffe(protoFile, weightsFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenPoseVideo::movementSkeleton(Mat inputImage, std::function<void(std::vector<Point>)> f) {
|
void OpenPoseVideo::movementSkeleton(Mat inputImage, std::function<void(std::vector<Point>,cv::Mat poinst_on_image)> f) {
|
||||||
std::cout << "movement skeleton start" << std::endl;
|
std::cout << "movement skeleton start" << std::endl;
|
||||||
|
|
||||||
int inWidth = 368;
|
int inWidth = 368;
|
||||||
@@ -60,7 +60,7 @@ namespace computervision
|
|||||||
|
|
||||||
frame = inputImage;
|
frame = inputImage;
|
||||||
Mat inpBlob = blobFromImage(frame, 1.0 / 255, Size(inWidth, inHeight), Scalar(0, 0, 0), false, false);
|
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;
|
std::cout << "done reading image and blob" << std::endl;
|
||||||
|
|
||||||
net.setInput(inpBlob);
|
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);
|
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);
|
std::cout << "time taken: " << t << std::endl;
|
||||||
imshow("Output-Skeleton", frame);
|
//imshow("Output-Keypoints", frame);
|
||||||
|
//imshow("Output-Skeleton", frame);
|
||||||
std::cout << "about to call points receiving method" << std::endl;
|
std::cout << "about to call points receiving method" << std::endl;
|
||||||
f(points);
|
f(points,frame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ namespace computervision
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void movementSkeleton(Mat inputImage,std::function<void(std::vector<Point>)> f);
|
void movementSkeleton(Mat inputImage,std::function<void(std::vector<Point>, cv::Mat poinst_on_image)> f);
|
||||||
void setup();
|
void setup();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "async_arm_detection.h"
|
#include "async_arm_detection.h"
|
||||||
#include "../OpenPoseVideo.h"
|
#include "../OpenPoseVideo.h"
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include "StaticCameraInstance.h"
|
||||||
|
|
||||||
|
|
||||||
namespace computervision
|
namespace computervision
|
||||||
@@ -11,8 +12,10 @@ namespace computervision
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsyncArmDetection::run_arm_detection(std::function<void(std::vector<Point>)> points_ready_func, cv::VideoCapture cap, OpenPoseVideo op)
|
void AsyncArmDetection::run_arm_detection(std::function<void(std::vector<Point>, cv::Mat poinst_on_image)> points_ready_func, OpenPoseVideo op)
|
||||||
{
|
{
|
||||||
|
VideoCapture cap = static_camera::getCap();
|
||||||
|
|
||||||
std::cout << "STARTING THREAD LAMBDA" << std::endl;
|
std::cout << "STARTING THREAD LAMBDA" << std::endl;
|
||||||
/*cv::VideoCapture cap = static_camera::getCap();*/
|
/*cv::VideoCapture cap = static_camera::getCap();*/
|
||||||
|
|
||||||
@@ -30,13 +33,13 @@ namespace computervision
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsyncArmDetection::start(std::function<void(std::vector<Point>)> points_ready_func, cv::VideoCapture cap, OpenPoseVideo op)
|
void AsyncArmDetection::start(std::function<void(std::vector<Point>, cv::Mat poinst_on_image)> points_ready_func, OpenPoseVideo op)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::cout << "starting function" << std::endl;
|
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.
|
async_arm_detect_thread.detach(); // makes sure the thread is detached from the variable.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ namespace computervision
|
|||||||
AsyncArmDetection(void);
|
AsyncArmDetection(void);
|
||||||
|
|
||||||
|
|
||||||
void start(std::function<void(std::vector<cv::Point>)>, cv::VideoCapture cap, computervision::OpenPoseVideo op);
|
void start(std::function<void(std::vector<cv::Point>, cv::Mat poinst_on_image)>, computervision::OpenPoseVideo op);
|
||||||
private:
|
private:
|
||||||
void run_arm_detection(std::function<void(std::vector<Point>)> points_ready_func, cv::VideoCapture cap, OpenPoseVideo op);
|
void run_arm_detection(std::function<void(std::vector<Point>, cv::Mat poinst_on_image)> points_ready_func, OpenPoseVideo op);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
21
src/main.cpp
21
src/main.cpp
@@ -32,11 +32,16 @@
|
|||||||
static double UpdateDelta();
|
static double UpdateDelta();
|
||||||
|
|
||||||
static GLFWwindow* window;
|
static GLFWwindow* window;
|
||||||
|
bool points_img_available = false;
|
||||||
|
cv::Mat points_img;
|
||||||
|
|
||||||
void retrieve_points(std::vector<Point> arm_points)
|
void retrieve_points(std::vector<Point> arm_points, cv::Mat points_on_image)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::cout << "got points!!" << std::endl;
|
std::cout << "got points!!" << std::endl;
|
||||||
std::cout << "points: " << arm_points << std::endl;
|
std::cout << "points: " << arm_points << std::endl;
|
||||||
|
points_img = points_on_image;
|
||||||
|
points_img_available = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
@@ -82,11 +87,15 @@ int main(void)
|
|||||||
|
|
||||||
// set up object detection
|
// set up object detection
|
||||||
//objDetect.setup();
|
//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;
|
computervision::AsyncArmDetection as;
|
||||||
as.start(retrieve_points, objDetect.getCap(),openPoseVideo);
|
|
||||||
|
as.start(retrieve_points,openPoseVideo);
|
||||||
|
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
@@ -105,8 +114,12 @@ int main(void)
|
|||||||
|
|
||||||
render_engine::renderer::Render(entity, shader);
|
render_engine::renderer::Render(entity, shader);
|
||||||
|
|
||||||
cameraFrame = objDetect.readCamera();
|
|
||||||
//objDetect.detectHand(cameraFrame);
|
//objDetect.detectHand(cameraFrame);
|
||||||
|
if (points_img_available)
|
||||||
|
{
|
||||||
|
imshow("points", points_img);
|
||||||
|
points_img_available = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Finish up
|
// Finish up
|
||||||
shader.Stop();
|
shader.Stop();
|
||||||
|
|||||||
@@ -131,8 +131,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);;C:\opencv\opencv\build\include</IncludePath>
|
<IncludePath>C:\opencv\build\include\;$(VC_IncludePath);$(WindowsSDK_IncludePath);C:\opencv\opencv\build\include</IncludePath>
|
||||||
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);C:\opencv\opencv\build\x64\vc15\lib</LibraryPath>
|
<LibraryPath>C:\opencv\build\x64\vc15\lib;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);C:\opencv\opencv\build\x64\vc15\lib</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
@@ -205,7 +205,7 @@
|
|||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalLibraryDirectories>$(SolutionDir)lib\glfw-3.3.2\$(Platform);$(SolutionDir)lib\glew-2.1.0\lib\Release\$(Platform);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(SolutionDir)lib\glfw-3.3.2\$(Platform);$(SolutionDir)lib\glew-2.1.0\lib\Release\$(Platform);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>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</AdditionalDependencies>
|
<AdditionalDependencies>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)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|||||||
Reference in New Issue
Block a user