Search code examples
image-processingopencvvideo-processing

How to find correlation between frames of a video using Opencv?


I want to segregate the frames that have high correlation. Suppose in a video the first 6 seconds, the scenes do not change much except that there is a very little movement of objects. How can I separate out those frames by finding the correlation between all of them. ....

For this I visited this link but it did not help much ....

Please help me in this problem !


Solution

  • I will assume that a keyframe is a frame presenting content a lot different from the previous ones (it's not a formal definition, but it fits). Take frames i and i+1. Use cv2.absDiff to compute the difference between the frames and cv2.sumElems to get the sum of all pixels differences. Do this for all frames i. This will reduce your video stream to an one dimensional signal. Look for peaks in this signal and pick keyframes corresponding to these peaks.

    found here: Key Frame Extraction From Video