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

Fix opencv segmentation fault #442

Conversation

aliberts
Copy link
Collaborator

@aliberts aliberts commented Sep 18, 2024

What this does

  • Adds lock mechanism in OpenCVCamera for thread safe operation
  • Adds yield in pytest monkeypatching fixture for cameras (actually doesn't work)
  • Removes inheritance of MockVideoCapture from cv2.VideoCapture, which was causing ugly errors when trying to monkeypatch cv2.VideoCapture with it.
  • Improve MockVideoCapture for more accurate behavior
  • Use np.testing.assert_allclose instead of assert np.allclose for displaying errors nicely

TODO (this PR or another one):

  • Will probably need to add the same logic to motors and realsense

How it was tested

Running pytest -v -k "opencv" tests/test_cameras.py doesn't raise any segmentation fault anymore, but does still raise assert errors on np.allclose (separate issue)

EDIT: For mock=True this is now fixed. It was caused by the monkeypatch not actually being applied and therefore was using the real camera instead of the mock one.

How to checkout & try? (for the reviewer)

pytest -v -k "opencv" tests/test_cameras.py

@aliberts aliberts added the 🐛 Bug Something isn't working label Sep 18, 2024
@aliberts aliberts self-assigned this Sep 18, 2024
@aliberts aliberts marked this pull request as ready for review September 19, 2024 08:32
Copy link
Collaborator

@Cadene Cadene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Cadene Cadene merged commit 886923a into user/rcadene/2024_09_01_mock_robot_devices Sep 25, 2024
1 check passed
@Cadene Cadene deleted the user/aliberts/2024_09_18_fix_cameras_segfault branch September 25, 2024 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants