-
Notifications
You must be signed in to change notification settings - Fork 500
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
Use buffer to gather frames #186
Use buffer to gather frames #186
Conversation
I am not 100% sure about this change, because:
We could think about:
|
I made some changes based upon your suggestions. I need to test these latest changes, because my main issue was that the I think it would be best to not access the variable directly, but to use the Will let you know when I have done some further testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought using the Queue
class might not have been the best recommendation.
I picked it for its thread safety features.
Its main downside is its behaviour on put
calls when the queue is full (i.e. it drops the new items). What we probably want is to drop the oldest item (i.e. the oldest frame).
The documentation suggests the collections.dequeue
class, which is also threadsafe, but drops oldest items instead of the newest ones.
If you want you can change the code to use collections.dequeue or just fix the issues i commented on. I am fine with both solutions.
I made the changes you requested. I also made it so that you can decide whether to use the queue or not at all. By default, the queue is not used. I still have to test the changes, will do that tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks very good now!
Made some changes, to make it work. It works on our Tello Talent now. In our case the queue version works the best. I'm polling the frame at a rate of 60hz, so when there is some delay, I will catch up over time. 1 thing to note (I think this is already in the documentation), enough time between polling of the frame is needed, otherwise the frame will only very occasionally be locked by the |
Also, when using the queued version, accessing the frame variable will occasionally return None (when no frame is available). This has to be checked with |
Made some changes to use a buffer instead of accessing the frame variable of the
BackgroundFrameRead
object. This makes sure you're not reading data from the frame variable while theBackgroundFrameRead
object is writing data to it, thus causing less artifacts in the images.