Cartucho / OpenLabeling

Label images and video for Computer Vision applications
Apache License 2.0
926 stars 266 forks source link

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

Closed vuthede closed 5 years ago

vuthede commented 5 years ago

1> When I double-click at a bounding box, then _is_bboxselected is set to True 2> Right after that, a one-click event is trigger automatically, and _is_bboxselected 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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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.

Cartucho commented 5 years ago

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

vuthede commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

yeah i think so!