Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict Between pupil_labs Imports and OpenCV cv2.imshow() #3

Open
Liuuuxy opened this issue Feb 18, 2025 · 1 comment
Open

Conflict Between pupil_labs Imports and OpenCV cv2.imshow() #3

Liuuuxy opened this issue Feb 18, 2025 · 1 comment

Comments

@Liuuuxy
Copy link

Liuuuxy commented Feb 18, 2025

When importing pupil_labs.realtime_api.simple or pupil_labs.real_time_screen_gaze.gaze_mapper, OpenCV's cv2.imshow() does not display the image as expected. However, when these imports are commented out, cv2.imshow() functions normally. This issue occurs without any other changes to the script.

Steps to Reproduce

Run the following minimal script:

import cv2
import numpy as np

# Uncommenting these two lines causes cv2.imshow() to stop working
from pupil_labs.realtime_api.simple import discover_one_device
from pupil_labs.real_time_screen_gaze.gaze_mapper import GazeMapper

black_screen  = np.ones([500,500,3])
cv2.imshow("Simple_black", black_screen)
cv2.waitKey(0)

When pupil_labs is imported, the OpenCV image window does not appear.
No error messages are displayed in the terminal.

Environment:

OS: Ubuntu 22.04
Python Version: 3.10.16
Pupil Labs Package Version: 1.3.6
OpenCV Version: 4.11.0

Possible Causes

is that GUI backend conflicts between pupil_labs and OpenCV?

Could you confirm if pupil_labs alters any OpenCV-related settings or GUI backends? If so, is there a workaround to allow OpenCV's cv2.imshow() to function normally while using pupil_labs?

Thanks!

@domstoppable
Copy link
Member

domstoppable commented Feb 18, 2025

There's a known issue between OpenCV and pyav on Linux, and I'll bet this is just that.

Could you try the following? Immediately after the numpy import, add these lines:

# Workaround for https://github.com/opencv/opencv/issues/21952
cv2.imshow("cv/av bug", np.zeros(1))
cv2.destroyAllWindows()

and then uncomment the other imports after that.

Let me know if that works for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants