wjs018/QuantitativeEditing

Use StatsManager to improve runtime

Breakthrough opened this issue · 2 comments

Hi @wjs018;

I noticed in https://github.com/wjs018/QuantitativeEditing/blob/master/detect_scenes.py that you made a function called analyze_video which saves a stats file. In the event you give a stats file, you might want to consider loading it back from disk - this will significantly improve the performance of subsequent calls to analyze_video.

Another option is to just re-use the same StatsManager object during multiple calls to analyze_video (assuming you're using the same video). If you can keep the SceneManager/StatsManager instances saved between calls to this function, the stats that have been cached improve subsequent calls to detect_scenes.

You can do this by calling clear() on the SceneManager - after doing so, if you close and re-open the same video source, another call to detect_scenes will be a lot quicker, since those frames have already been cached.

Hope this helps, if you don't feel this issue is relevant feel free to close it. Thanks for your interest in the project btw! Will definitely be looking into adding an EdgeDetector class that looks at object edge changes between frames, great insight.

@Breakthrough,

Thanks for the feedback idea. I am currently working on polishing this repo up a bit. Using the new StatsManager API is definitely on the list of things to do.

@Breakthrough

I have implemented this speed-up using the statsmanager as you suggested. It has been working great and has sped up subsequent video analysis from ~25 fps to over 700 fps.