New to opencv.
I’m looking to sort a bunch of videos I have based on the motion in the videos. Basically if a video has any moving objects place it in a folder, if not, place in another folder.
Would optical flow or background subtraction be useful for this? Or perhaps there’s another algorithm I could use to determine motion?
Any suggestions would be appreciated.
yes, both methods should give you useful results. either method gives you per-pixel numbers proportional to “things that change”, so you’d only have to calculate some simple statistics (sums) and act on these values.
I’d recommend python to start playing with it. you can run
samples/python/dis_opt_flow.py and watch it work.
or have a look at this
Looks like calcOpticalFlowFarneback() outputs a flow matrix from which I could calculate vector magnitudes and sum up and take an average from.
if you go with optical flow, do check out the available algorithms. DIS is quite fast and gives good results.
a simple background subtractor (see OpenCV module for those) should be enough for your purposes. you don’t need flow vectors for your purpose, only motion or no motion.