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

When piping output of 'get_blocks_cpp_demo.cpp' to another application, buffering delays output #27

Open
MattTavares opened this issue Sep 18, 2023 · 0 comments

Comments

@MattTavares
Copy link

Related to the changes proposed in this pull request.

In certain scenarios, especially when the program's output is piped to another application, the default buffering behavior of C++ can lead to inconsistent and delayed camera block outputs. This is due to the buffering strategy switching from line-buffered to fully buffered, causing data to be held back until the buffer is full.

This change ensures that the output remains consistently line-buffered, regardless of the environment or how the output is being consumed. By setting the buffering mode explicitly using setvbuf, we guarantee that data is outputted as soon as it's available.

For the Pixy2 camera running the get_blocks_cpp_demo code, the absence of this buffering adjustment can have significant real-time implications. Without this change, the camera data, which is expected to be relayed immediately upon detection, can be delayed. This buffering delay can result in bursts of data being sent every few seconds, rather than a continuous stream. In practical terms, this means that rapid events captured by the camera, such as fast-moving objects, might not be processed in time, leading to missed detections or delayed responses.

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

1 participant