roguedarkjedi / dogcam-ai

The AI based camera focus controller for dogcam
MIT License
1 stars 0 forks source link

Investigate: Thread thrashing in the streamer #10

Closed roguedarkjedi closed 4 years ago

roguedarkjedi commented 4 years ago

The streamer thread doesn't ever give up a time slice, mostly because capturing has to keep on running, so any delays will start stacking up slowly over time. It's not ideal but there might be a better way to capture frames with a frame drop automatically.

roguedarkjedi commented 4 years ago

One thing we can do is limit the stream buffer size. I was not aware this was possible, but doing this should allow us to automatically drop old dead frames.

See: https://stackoverflow.com/questions/58293187/opencv-real-time-streaming-video-capture-is-slow-how-to-drop-frames-or-get-sync

roguedarkjedi commented 4 years ago

I would like to add sleeps but I do worry about time delay. We could add an FPS clock in there but I'm unsure about it overall. Especially when it comes to processing and lock.

Perhaps add an experimental flag that if it's 0 the fps sync is ignored?

roguedarkjedi commented 4 years ago

Investigation has finished, going to close for now and open a new ticket for any future bugs.