Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change class label with mouse wheel #127

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ std::atomic<bool> right_button_click;
std::atomic<int> move_rect_id;
std::atomic<bool> move_rect;
std::atomic<bool> clear_marks;
std::atomic<bool> wheel_increase_label_class;
std::atomic<bool> wheel_decrease_label_class;
std::atomic<bool> copy_previous_marks(false);

std::atomic<bool> show_help;
Expand Down Expand Up @@ -110,6 +112,19 @@ void callback_mouse_click(int event, int x, int y, int flags, void* user_data)
x_end = max(x, 0);
y_end = max(y, 0);
}
else if (event == cv::EVENT_MOUSEWHEEL) //catch mouse wheel movement
{
if (getMouseWheelDelta(flags)>0)
{
wheel_increase_label_class = false;
wheel_decrease_label_class = true;
}
else
{
wheel_increase_label_class = true;
wheel_decrease_label_class = false;
}
}
}

class comma : public std::numpunct<char> {
Expand Down Expand Up @@ -774,6 +789,19 @@ int main(int argc, char *argv[])
#else
int pressed_key = cv::waitKey(20); // OpenCV 2.x
#endif
// handle mouse wheel event
if (wheel_increase_label_class)
{
wheel_increase_label_class = false;
current_obj_id += 1;
current_obj_id = min(max_object_id, current_obj_id);
}
if (wheel_decrease_label_class)
{
wheel_decrease_label_class = false;
current_obj_id -= 1;
current_obj_id = max(0, current_obj_id);
}

if (pressed_key >= 0)
for (int i = 0; i < 5; ++i) cv::waitKey(1);
Expand Down Expand Up @@ -808,11 +836,14 @@ int main(int argc, char *argv[])
++trackbar_value;
break;

case 'a':
case 2424832: // <-
case 65361: // <-
case 91: // [
--trackbar_value;
break;

case 's':
case 2555904: // ->
case 65363: // ->
case 93: // ]
Expand Down