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

Can't Set CV_CAP_PROP_BUFFERSIZE #13

Closed
dactylroot opened this issue Feb 13, 2020 · 3 comments
Closed

Can't Set CV_CAP_PROP_BUFFERSIZE #13

dactylroot opened this issue Feb 13, 2020 · 3 comments

Comments

@dactylroot
Copy link
Owner

Problem

Given an unknown source framerate and unknown frame processing time for each frame, we want to be able to always grab the most recent frame at the time of a read() call. In contrast to traditional process-every-frame stream workflows, which opencv-python seems to have been designed around.

Ideally we could follow cap.set(CV_CAP_PROP_BUFFERSIZE,1) and then always have the most recent frame available. Unfortunately, contrary to this suggestion, we don't appear to be able to set this property in Python:

In : cap.set(cv2.CAP_PROP_BUFFERSIZE,1)                                                                                  
Out: False

It appears everyone tries to manually flush the buffer themselves e.g. 1 2a 2b

Current Workaround

As a workaround, I parameterized the buffer skipping rate. So users of this package still have to be conscious of their source framerate and set a flush rate accordingly.

Possible Solutions

Some options to consider to fix this:

  • Find out how to set the CAP_PROP_BUFFERSIZE property for OpenCV.
  • Use another thread to spool frames as quickly as possible. This is no ideal as we don't want to force every user into multithreading situations, especially when OpenCV supposedly has this capability already.
@Mauhing
Copy link

Mauhing commented Feb 24, 2020

I have also notice that cv2.CAP_PROP_BUFFERSIZE,1) does not work. What I am doing right now is to constantly cv2.grab() and only retrieve when I need it. However, this is not a good solution.

@bvitaz-ck
Copy link

On my Raspberry Pi project, cv2.CAP_PROP_BUFFERSIZE, 1 does actually work, but it means there's still a buffer of 1 that needs to be cleared before reading a live image. cv2.CAP_PROP_BUFFERSIZE, 0 is what I have been trying to get to work, and it does work on my Mac and Windows PCs.

@dactylroot
Copy link
Owner Author

Closing as this is an OpenCV issue

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

3 participants