MouseCallback Lag
I'm running OpenCV 3 on Python 3.4 on a 2015 15" MacBook Pro. Below is a minimal example that illustrates my problem:
import cv2 as cv
import numpy as np
def mouse_callback(event, x, y, flags, param):
if event == 1:
print("Callback!")
cv.namedWindow("Display")
cv.setMouseCallback("Display", mouse_callback)
while True:
img = np.zeros((512,512,3), np.uint8)
cv.imshow("Display", img)
if cv.waitKey(1) == ord("q"):
break
When I click on the black screen, the text "Callback!" takes about one second to appear on the terminal screen, although sometimes the delay is up to three seconds, and other times there is little delay. Additionally, I wrote a similar program in C++, and found that the C++ OpenCV libraries also suffer from this lag.
Any tips on how I can reduce or eliminate the lag?
this should not happen in the 1st place (and does not here, on win)
i'd rather suspect, there's something murky with your build. which gui toolkit do you use there ?
Yeah, I just tested the exact same code on Ubuntu, and the problem doesn't occur. I'm honestly not sure which GUI toolkit I'm using--how would I check that?
First guess, your repaint method of your gui interface is called in fixed intervals, thus the delay is occuring, but in fact it is not... how to fix this however, no idea...