diff --git a/src/computervision/ObjectDetection.cpp b/src/computervision/ObjectDetection.cpp index c9ca81e..870eb09 100644 --- a/src/computervision/ObjectDetection.cpp +++ b/src/computervision/ObjectDetection.cpp @@ -11,7 +11,7 @@ namespace computervision { - cv::VideoCapture cap(1); + cv::VideoCapture cap(0); cv::Mat img, imgGray, img2, img2Gray, img3, img4; diff --git a/src/gui/gui_interactable.cpp b/src/gui/gui_interactable.cpp index 1b90251..65cf6f5 100644 --- a/src/gui/gui_interactable.cpp +++ b/src/gui/gui_interactable.cpp @@ -76,12 +76,12 @@ namespace gui { double 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 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 && diff --git a/src/scenes/startup_Scene.cpp b/src/scenes/startup_Scene.cpp index 54024e1..4f3fe11 100644 --- a/src/scenes/startup_Scene.cpp +++ b/src/scenes/startup_Scene.cpp @@ -25,6 +25,7 @@ namespace scene float item_number = 0; + bool hand_mode = false; Startup_Scene::Startup_Scene() { shaders::EntityShader shader; @@ -120,41 +121,42 @@ namespace scene if(new_button != NULL) new_button->Update(window); } - - cameraFrame = objDetect.readCamera(); + if (hand_mode) { + cameraFrame = objDetect.readCamera(); - //Get hand state from camera - bool hand_detection = objDetect.detectHand(cameraFrame); + //Get hand state from camera + bool hand_detection = objDetect.detectHand(cameraFrame); - if (hand_detection) - { - hand_closed = false; - std::cout << "hand is opened" << std::endl; + if (hand_detection) + { + hand_closed = false; + std::cout << "hand is opened" << std::endl; - //Loop through menu items - chosen_item = GetMenuItem(true); + //Loop through menu items + chosen_item = GetMenuItem(true); - gui::Button* new_button = ConvertGuiTextureToButton(chosen_item); - if (new_button != NULL) { - const float x_pos = (chosen_item->position.x + 1.0)*WINDOW_WIDTH/2; - const float y_pos = (1.0 - chosen_item->position.y)*WINDOW_HEIGHT/2; + gui::Button* new_button = ConvertGuiTextureToButton(chosen_item); + if (new_button != NULL) { + const float x_pos = (chosen_item->position.x + 1.0) * WINDOW_WIDTH / 2; + const float y_pos = (1.0 - chosen_item->position.y) * WINDOW_HEIGHT / 2; - //Set cursor to location of selected menu_item - glfwSetCursorPos(window, x_pos, y_pos); + //Set cursor to location of selected menu_item + glfwSetCursorPos(window, x_pos, y_pos); + } } - } - else if (!hand_detection) - { - std::cout << "hand is closed" << std::endl; - - //Gets selected menu_item - chosen_item = GetMenuItem(false); - gui::Button* new_button = ConvertGuiTextureToButton(chosen_item); - - if (new_button != NULL && !hand_closed) { - //Run function click - new_button->ForceClick(GLFW_MOUSE_BUTTON_LEFT); - hand_closed = true; + else if (!hand_detection) + { + std::cout << "hand is closed" << std::endl; + + //Gets selected menu_item + chosen_item = GetMenuItem(false); + gui::Button* new_button = ConvertGuiTextureToButton(chosen_item); + + if (new_button != NULL && !hand_closed) { + //Run function click + new_button->ForceClick(GLFW_MOUSE_BUTTON_LEFT); + hand_closed = true; + } } } @@ -185,5 +187,8 @@ namespace scene { return_value = scene::Scenes::INGAME; } + else if (glfwGetKey(window, GLFW_KEY_BACKSPACE) == GLFW_PRESS) { + hand_mode = !hand_mode; + } } }