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

A one-click event is trigger by double click event, which cause the program work not as expected. #37

Closed
vuthede opened this issue Jan 23, 2019 · 8 comments

Comments

@vuthede
Copy link
Contributor

vuthede commented Jan 23, 2019

1> When I double-click at a bounding box, then is_bbox_selected is set to True
2> Right after that, a one-click event is trigger automatically, and is_bbox_selected is set to False
I found 2 solutions for that:
First: Using timer as mentioned on this https://stackoverflow.com/questions/21373110/how-to-distinguish-between-click-and-double-click-in-opencv
Second: I changed the code a bit in the event listener:

  elif event == cv2.EVENT_LBUTTONDOWN:
    if not prev_was_double_click:
        print('Normal left click')
        if point_1[0] is -1:
            if is_bbox_selected:
                if is_mouse_inside_delete_button():
                    edit_bbox('delete')
                is_bbox_selected = False

            else:
                # first click (start drawing a bounding box or delete an item)
                point_1 = (x, y)
        else:
            # minimal size for bounding box to avoid errors
            threshold = 20
            if abs(x - point_1[0]) > threshold or abs(y - point_1[1]) > threshold:
                # second click
                point_2 = (x, y)

    if prev_was_double_click:
        #print('Finish double click')
        prev_was_double_click = False
@Cartucho
Copy link
Owner

Hello, thanks for your feedback.
Why do you say that it causes the program to work not as expected? In terms of usability, what were you expecting?

@vuthede
Copy link
Contributor Author

vuthede commented Jan 23, 2019

Yeah, I have tried to select a bbox, and then change the class of this bbox. But the class of bbox never change.
I think it is because :when I double-click to select a bbox, the parameter is_bbox_selected is turn into True and immediately is turned into False because a one-click event is triggered also.
The class of bbox is able to be changed only if is_bbox_selected is True, which never happen.
Btw, I use opencv 3.4

@Cartucho
Copy link
Owner

Cartucho commented Jan 23, 2019

That's weird... On my computer:

  1. I double click and bounding box gets selected (it should show the x button)
    image

  2. I press w or s the class changes
    image

In your computer step 1 is not working, right? When you select a bbox it automatically de-selects itself and you don't even see the red x button?

@vuthede
Copy link
Contributor Author

vuthede commented Jan 23, 2019

Sorry for late reply.
yeah, in my computer, the bbox automatically de-selects itself and don't even see the red x button.
I have tried to uninstall my opencv 3.4.3 and quick install the 3.2.0 instead, then the problem is resolved.

@vuthede vuthede closed this as completed Jan 23, 2019
@vuthede vuthede reopened this Jan 23, 2019
@Cartucho
Copy link
Owner

Does the problem remain with 3.2.0? I would actually recommend going to the newest version the 4.0.0.21

@vuthede
Copy link
Contributor Author

vuthede commented Jan 24, 2019

It is so weird now,
If using 3.2.0 this problem is resolved
If using 4.0.0.21, the problem is raising a gain.

@Cartucho
Copy link
Owner

Gosh, I will try with other OpenCV versions (in 3.3.1 it works).
It may be the case that it is an OpenCV bug.

@vuthede
Copy link
Contributor Author

vuthede commented Jan 25, 2019

yeah i think so!

@vuthede vuthede closed this as completed Jan 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants