arccoder/opencvdragrect

unable to return out of selectwindow.py

gwsHunter opened this issue · 3 comments

Run script.py which seems to run selectwindow.py properly at first. White image pops up and allows selection of a rectangle, changing sizes, moving etc. as shown in the demo. Double clicking inside the rectangle then closes the window but the program seems to stay stuck in selectwindow.py and does not return to script.py.

Trouble shooting with print statements I see that the program seems to go all the way through dragrect in selectwindow.py. Even if I put a return statement after the double click it only stops executing within dragrect, but does not seem to break out of selectwindow.py.

if event == cv2.EVENT_LBUTTONDBLCLK:
    mouseDoubleClick(x, y, dragObj)
    print('double click')
    return
    print('past return')

This prints "double click" but not "past return". The program however never goes back to script.py.

I am running python 3.7 and using Spyder 3.

I am probably missing something simple, but not seeing what it is. Thanks for the help.

Im having problems with this too. did you ever found a fix?

Never figured it out. Ended up coding something much simpler without all the features, but worked for what I was doing.

Hi @gwsHunter,

Apologies, I never got to this before today.
As of d56ac9c the code it modified to work with Python3 and a bug fix #3.
I tried your changes after d56ac9c, and I am unable to reproduce it.

I am using Python 3.8.3 on PyCharm.

When I make your change I get the following console output.

double click
double click
Dragged rectangle coordinates
x,y,w,h

As per the implementation, "double click" is suppose to destroy the drawing window which will end the script.py as well.
Did you make any other changes which will help me recreate the issue?
Also, please try the updated code to check if the error can be reproduced.

This time I will try to respond in days rather than a year.

Thanks,
Akshay