Ask Your Question

Shivam Sarodia's profile - activity

2015-07-02 23:06:06 -0600 received badge  Enthusiast
2015-06-29 01:10:41 -0600 commented question MouseCallback Lag

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?

2015-06-28 01:17:53 -0600 asked a question 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?