opencvdragrect
opencvdragrect copied to clipboard
Crash and how to fix it
If the mouse is moved fast while dragging a rect, the app crashes (on Windows, Python 3.9). The GUI seems to be overloaded. This can be fixed as follows.
In the beginning of selectwindows add from timeit import default_timer as timer lastt=timer()
In the beginning of def dragrect(event, x, y, flags, dragObj): global lastt ctime=timer() gap=ctime-lastt if gap < 0.1 and event == cv2.EVENT_MOUSEMOVE: return lastt = ctime
You can change the 0.1 to sth larger or a bit smaller.