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

Fix darknet_video.py to so it's not off by 1 frame #6717

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mazatov
Copy link

@mazatov mazatov commented Sep 22, 2020

The issue:
Previously the output videofile had detections off by 1 frame from the video.
The reason:
The darknet_image is overwritten in video_capture every time it's being created because it sits in the same memory so effectively the darknet_image_queue is not working properly

Changes:

  • darknet_image is created in every iteration of video_capture so every new darknet_image sits in different memory
  • remove limitations on max_size of the queue. I believe the limitations were put there to avoid the issue above, but it only made it so the result was off by one frame. Now that that's not an issue there is no reason to have max_size for any of the queques

The issue:
Previously the output videofile had detections off by 1 frame from the video. 
The reason: 
The `darknet_image` is overwritten in `video_capture` every time it's being created because it sits in the same memory so effectively the `darknet_image_queue` is not working properly

Changes:
- `darknet_image` is created in every iteration of `video_capture` so every new `darknet_image` sits in different memory
- remove limitations on `max_size` of the queue. I believe the limitations were put there to avoid the issue above, but it only made it so the result was off by one frame. Now that that's not an issue there is no reason to have `max_size` for any of the queques
@mazatov mazatov changed the title Update darknet_video.py Fix darknet_video.py to so it's not off by 1 frame Sep 22, 2020
mazatov and others added 4 commits September 22, 2020 14:26
Added maxsize so there is no memory overload in case too many frames load for the detect_image.
I was getting a memory problem because as `darknet_image` is created in every iteration of `video_capture`, it is not being released by the `darknet_image_queue` when it gets `.get()`. 

To fix it I make a list of darknet_images that is larger than the size of the queue. The list is being repeatedly updated with new darknet_images in `video_capture`, but the image that has not been processed yet, is never overwritten. A bit of a hacky fix, but it works.
Define `darknet_images`
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

Successfully merging this pull request may close these issues.

3 participants