Description
Describe the bug
When using a CvSink to grab frames from a UsbCamera started with the CameraServer.startAutomaticCapture()
method, the CvSink's grabFrame
method will randomly time out, even though capture of the camera is definitely running and viewable from Shuffleboard. It is also running at a high enough frame rate that multiple frames should have been supplied to the sink before timing out.
This only seems to happen the first time grabFrame is called after code starts. Future calls after the first one succeeds will work fine.
To Reproduce
Steps to reproduce the behavior:
- Start automatic capture of a UsbCamera in robotInit and create a CvSink for it
- In teleopInit, grab a frame.
- Observe that when enabled, the grabFrame method will sometimes time out and return 0
Expected behavior
grabFrame
method should be able to grab a frame before the time out expires if the camera is being streamed properly
Desktop (please complete the following information):
- WPILib Version: 2023.4.2
- OS: Windows 11
- Java version: 17