AdamSpannbauer / python_video_stab

A Python package to stabilize videos using OpenCV
https://adamspannbauer.github.io/python_video_stab/html/index.html
MIT License
682 stars 118 forks source link

Improve throughput for live higher resolutions #99

Closed bryanbosworth closed 4 years ago

bryanbosworth commented 4 years ago

The library performs very well with live video from a machine vision camera on a microscope (30 fps, 4096x2160 binned in camera to 2048x1080 and resized by OpenCV to 614x324, smoothing parameter = 3). However, slightly increasing the frame's linear dimensions quickly makes the software unusable (e.g., scaling down to 819x432 permits only 23 fps).

Can a straightforward improvement be implemented to calculate the transforms on a scaled image and then apply adapted transforms to the full resolution version? When I profile the code, gftt requires the most time by far and scales poorly with frame resolution while frame handling and application of the transforms occur very quickly.

The ROI approach should work well #85, but in this case I think the ROI will likely be occluded or in poor focus some of the time.

Thanks so much for the hard work, Adam!

AdamSpannbauer commented 4 years ago

Thanks for reporting the issue and for providing an idea for a possible solution! Both are appreciated (especially the 2nd part).

This issue relates pretty closely with #97*; so when I get back into working on this (likely over the weekend). I might end up closing one of the 2. If I close this one, I'll be sure to tag you on the other in case you want to follow the progress.

*Hard to know that based on the title though. I'll change the title now.

AdamSpannbauer commented 4 years ago

Closing this issue to tidy up.

The progress on speeding up live video processing will be documented in #97.

AdamSpannbauer commented 4 years ago

Hi @bryanbosworth, I'm not totally sure how GitHub notifications work. So I apologize if you've already been notified about the discussion in #97

Would you be willing to test the potential fix on your use case? The instructions on how to install the patch are here.