[FIX] only clicks ones when you close hand now
This commit is contained in:
@@ -59,10 +59,10 @@ namespace computervision
|
|||||||
putText(cameraFrame,hand_text, Point(10, 75), FONT_HERSHEY_PLAIN, 2.0, Scalar(255, 0, 255),3);
|
putText(cameraFrame,hand_text, Point(10, 75), FONT_HERSHEY_PLAIN, 2.0, Scalar(255, 0, 255),3);
|
||||||
imshow("camera", cameraFrame);
|
imshow("camera", cameraFrame);
|
||||||
|
|
||||||
imshow("output", frameOut);
|
//imshow("output", frameOut);
|
||||||
//imshow("foreground", foreground);
|
//imshow("foreground", foreground);
|
||||||
//imshow("handMask", handMask);
|
//imshow("handMask", handMask);
|
||||||
imshow("handDetection", fingerCountDebug);
|
//imshow("handDetection", fingerCountDebug);
|
||||||
|
|
||||||
int key = waitKey(1);
|
int key = waitKey(1);
|
||||||
|
|
||||||
|
|||||||
@@ -76,10 +76,14 @@ 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;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
|
||||||
if (x_rel >= minXY.x && x_rel <= maxXY.x &&
|
if (x_rel >= minXY.x && x_rel <= maxXY.x &&
|
||||||
y_rel >= minXY.y && y_rel <= maxXY.y)
|
y_rel >= minXY.y && y_rel <= maxXY.y)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ namespace scene
|
|||||||
if (texture->GetType() == gui::GuiType::BUTTON) {
|
if (texture->GetType() == gui::GuiType::BUTTON) {
|
||||||
|
|
||||||
gui::Button* button = (gui::Button*)texture;
|
gui::Button* button = (gui::Button*)texture;
|
||||||
std::cout << button->clicked_texture << std::endl;
|
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -110,6 +109,7 @@ namespace scene
|
|||||||
computervision::ObjectDetection objDetect;
|
computervision::ObjectDetection objDetect;
|
||||||
cv::Mat cameraFrame;
|
cv::Mat cameraFrame;
|
||||||
gui::GuiTexture* chosen_item = NULL;
|
gui::GuiTexture* chosen_item = NULL;
|
||||||
|
bool hand_closed = false;
|
||||||
|
|
||||||
while (return_value == scene::Scenes::STARTUP)
|
while (return_value == scene::Scenes::STARTUP)
|
||||||
{
|
{
|
||||||
@@ -130,6 +130,8 @@ namespace scene
|
|||||||
|
|
||||||
if (hand_detection)
|
if (hand_detection)
|
||||||
{
|
{
|
||||||
|
hand_closed = false;
|
||||||
|
|
||||||
std::cout << "hand is opened" << std::endl;
|
std::cout << "hand is opened" << std::endl;
|
||||||
|
|
||||||
//Loop through menu items
|
//Loop through menu items
|
||||||
@@ -182,9 +184,10 @@ namespace scene
|
|||||||
|
|
||||||
std::cout << chosen_item->texture << std::endl;
|
std::cout << chosen_item->texture << std::endl;
|
||||||
gui::Button* new_button = ConvertGuiTextureToButton(chosen_item);
|
gui::Button* new_button = ConvertGuiTextureToButton(chosen_item);
|
||||||
if (new_button != NULL) {
|
if (new_button != NULL && !hand_closed) {
|
||||||
//Run function click
|
//Run function click
|
||||||
new_button->ForceClick(GLFW_MOUSE_BUTTON_LEFT);
|
new_button->ForceClick(GLFW_MOUSE_BUTTON_LEFT);
|
||||||
|
hand_closed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user