1 | initial version |
With your current code snippet, you are simply drawing a rectangle over a selected button. To achieve what you want, two things are needed:
lastSelectedBtn
Your callback manipulation will look like this
void callBackFunc1(int event, int x, int y, int flags, void* userdata)
{
Buttons* button = (Buttons*)userdata;
Vec3b selectButton;
if (event == EVENT_LBUTTONDOWN)
{
if (button-> leftHand.contains(Point(x, y)))
{
lastSelectedBtn.hidden = true; // hide the last selected button
lastSelectedBtn = button; // update it to the recently selected button
selectButton = Vec3b(0, 0, 250);
cout << "Select Left Hand ROI\n" << endl;
rectangle(drawRect, button->leftHand, selectButton, 5, 8, 0);
}
else if (button->leftElbow.contains(Point(x, y)))
{
lastSelectedBtn.hidden = true; // hide the last selected button
lastSelectedBtn = button; // update it to the recently selected button
selectButton = Vec3b(0, 0, 250);
cout << "Select Left Elbow ROI\n" << endl;
rectangle(drawRect, button->leftElbow, selectButton, 5, 8, 0);
}
imshow("Label Tool", drawRect);
}
}
DISCLAIMER
Correct me if I am wrong but a glimpse into OpenCV High GUI shows that they do not provide any way of hiding created GUI element. This means that the lastSelectedBtn.hidden = true
logic part will have to be done at the OS level.
2 | No.2 Revision |
With your current code snippet, you are simply drawing a rectangle over a selected button. To achieve what you want, two things are needed:
lastSelectedBtn
Your callback manipulation will look like this
void callBackFunc1(int event, int x, int y, int flags, void* userdata)
{
Buttons* button = (Buttons*)userdata;
Vec3b selectButton;
if (event == EVENT_LBUTTONDOWN)
{
if (button-> leftHand.contains(Point(x, y)))
{
lastSelectedBtn.hidden = true; // hide the last selected button
lastSelectedBtn = button; // update it to the recently selected button
selectButton = Vec3b(0, 0, 250);
cout << "Select Left Hand ROI\n" << endl;
rectangle(drawRect, button->leftHand, selectButton, 5, 8, 0);
}
else if (button->leftElbow.contains(Point(x, y)))
{
lastSelectedBtn.hidden = true; // hide the last selected button
lastSelectedBtn = button; // update it to the recently selected button
selectButton = Vec3b(0, 0, 250);
cout << "Select Left Elbow ROI\n" << endl;
rectangle(drawRect, button->leftElbow, selectButton, 5, 8, 0);
}
imshow("Label Tool", drawRect);
}
}
DISCLAIMER
Correct me if I am wrong but a glimpse into OpenCV High GUI shows that they do not provide any a way of hiding created GUI element. elements. This means that the lastSelectedBtn.hidden = true
logic part will have to be done at the OS level.
3 | No.3 Revision |
With your current code snippet, you are simply drawing a rectangle over a selected button. To achieve what you want, two things are needed:
lastSelectedBtn
Your callback manipulation will look like this
void callBackFunc1(int event, int x, int y, int flags, void* userdata)
{
Buttons* button = (Buttons*)userdata;
Vec3b selectButton;
if (event == EVENT_LBUTTONDOWN)
{
if (button-> leftHand.contains(Point(x, y)))
{
lastSelectedBtn.hidden lastSelectedBtn->hidden = true; // hide the last selected button
lastSelectedBtn = button; // update it to the recently selected button
selectButton = Vec3b(0, 0, 250);
cout << "Select Left Hand ROI\n" << endl;
rectangle(drawRect, button->leftHand, selectButton, 5, 8, 0);
}
else if (button->leftElbow.contains(Point(x, y)))
{
lastSelectedBtn.hidden lastSelectedBtn->hidden = true; // hide the last selected button
lastSelectedBtn = button; // update it to the recently selected button
selectButton = Vec3b(0, 0, 250);
cout << "Select Left Elbow ROI\n" << endl;
rectangle(drawRect, button->leftElbow, selectButton, 5, 8, 0);
}
imshow("Label Tool", drawRect);
}
}
DISCLAIMER
Correct me if I am wrong but a glimpse into OpenCV High GUI shows that they do not provide a way of hiding created GUI elements. This means that the
logic part will have to be done at the OS level.lastSelectedBtn.hidden lastSelectedBtn->hidden = true
4 | No.4 Revision |
With your current code snippet, you are simply drawing a rectangle over a selected button. To achieve what you want, two things are needed:
lastSelectedBtn
Your callback manipulation will look like this
void callBackFunc1(int event, int x, int y, int flags, void* userdata)
{
Buttons* button = (Buttons*)userdata;
Vec3b selectButton;
if (event == EVENT_LBUTTONDOWN)
{
if (button-> leftHand.contains(Point(x, y)))
{
lastSelectedBtn->hidden = true; // hide the last selected button
lastSelectedBtn = button; // update it to the recently selected button
selectButton = Vec3b(0, 0, 250);
cout << "Select Left Hand ROI\n" << endl;
rectangle(drawRect, button->leftHand, selectButton, 5, 8, 0);
}
else if (button->leftElbow.contains(Point(x, y)))
{
lastSelectedBtn->hidden = true; // hide the last selected button
lastSelectedBtn = button; // update it to the recently selected button
selectButton = Vec3b(0, 0, 250);
cout << "Select Left Elbow ROI\n" << endl;
rectangle(drawRect, button->leftElbow, selectButton, 5, 8, 0);
}
imshow("Label Tool", drawRect);
}
}
DISCLAIMER
Correct me if I am wrong but a glimpse into OpenCV High GUI shows that they do not provide a way of hiding created GUI elements. This means that the lastSelectedBtn->hidden = true
logic part will have to be done at the OS level.