I have an application, where I have two cameras connected using the v4l API. I am getting images from the cameras, and the methods return &[u8] buffers which are owned by the v4l driver.
I need to synchronize the two cameras, so that their images are in sync, for that the procedure is the following:
- Get
left_img: &[u8] = left_stream.next();
andright_img: &[u8] = right_stream.next();
from the two camera streams - Given the two buffers, extract and compare their timestamps
- If the left camera is behind, we "refresh"
left_img = left_stream.next();
- Else if the right camera is behind, we get the next
right_img = right_stream.next();
- Return (left_img, right_img)
This synchronization logic is verbose and messy, and I want to abstract it out, but the Rust borrow checker does not allow me to. I have been able to make a case where I do almost exactly the thing I want to, but only for a single camera, but the minute I try to do it for two cameras, it breaks down. Could any one help me cracking this nut?
A greatly simplified example showing the issue is available on this link: Rust Playground
Any help and advice would be greatly appreciated!