[ADD] added a on/off for hand detection in menu
you can switch between mouse and hand detection now
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace computervision
|
namespace computervision
|
||||||
{
|
{
|
||||||
cv::VideoCapture cap(1);
|
cv::VideoCapture cap(0);
|
||||||
|
|
||||||
cv::Mat img, imgGray, img2, img2Gray, img3, img4;
|
cv::Mat img, imgGray, img2, img2Gray, img3, img4;
|
||||||
|
|
||||||
|
|||||||
@@ -76,12 +76,12 @@ namespace gui
|
|||||||
{
|
{
|
||||||
double x_pos, y_pos;
|
double x_pos, y_pos;
|
||||||
glfwGetCursorPos(window, &x_pos, &y_pos);
|
glfwGetCursorPos(window, &x_pos, &y_pos);
|
||||||
std::cout << "Cursor pos in method: " << x_pos <<"::" << y_pos << std::endl;
|
//std::cout << "Cursor pos in method: " << x_pos <<"::" << y_pos << std::endl;
|
||||||
|
|
||||||
const float x_rel = (x_pos / SCALED_WIDTH / DEFAULT_WIDTH) * 2.0f - 1.0f;
|
const float x_rel = (x_pos / SCALED_WIDTH / DEFAULT_WIDTH) * 2.0f - 1.0f;
|
||||||
const float y_rel = -((y_pos / SCALED_HEIGHT / DEFAULT_HEIGHT) * 2.0f - 1.0f);
|
const float y_rel = -((y_pos / SCALED_HEIGHT / DEFAULT_HEIGHT) * 2.0f - 1.0f);
|
||||||
|
|
||||||
std::cout << "x_rel And y_rel in method: " << x_rel << "::" << y_rel << std::endl;
|
//std::cout << "x_rel And y_rel in method: " << x_rel << "::" << y_rel << std::endl;
|
||||||
|
|
||||||
|
|
||||||
if (x_rel >= minXY.x && x_rel <= maxXY.x &&
|
if (x_rel >= minXY.x && x_rel <= maxXY.x &&
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ namespace scene
|
|||||||
|
|
||||||
float item_number = 0;
|
float item_number = 0;
|
||||||
|
|
||||||
|
bool hand_mode = false;
|
||||||
|
|
||||||
Startup_Scene::Startup_Scene() {
|
Startup_Scene::Startup_Scene() {
|
||||||
shaders::EntityShader shader;
|
shaders::EntityShader shader;
|
||||||
@@ -120,7 +121,7 @@ namespace scene
|
|||||||
if(new_button != NULL)
|
if(new_button != NULL)
|
||||||
new_button->Update(window);
|
new_button->Update(window);
|
||||||
}
|
}
|
||||||
|
if (hand_mode) {
|
||||||
cameraFrame = objDetect.readCamera();
|
cameraFrame = objDetect.readCamera();
|
||||||
|
|
||||||
//Get hand state from camera
|
//Get hand state from camera
|
||||||
@@ -157,6 +158,7 @@ namespace scene
|
|||||||
hand_closed = true;
|
hand_closed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
@@ -185,5 +187,8 @@ namespace scene
|
|||||||
{
|
{
|
||||||
return_value = scene::Scenes::INGAME;
|
return_value = scene::Scenes::INGAME;
|
||||||
}
|
}
|
||||||
|
else if (glfwGetKey(window, GLFW_KEY_BACKSPACE) == GLFW_PRESS) {
|
||||||
|
hand_mode = !hand_mode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user