Image comparison in python to detect motion detection in a video

1.2k Views Asked by At

I am working on a project where I need to detect motion in a video stream(to be specific, to detect objects in a surveillance videos of atm).

When motion is detected further processing is done. There is no need for detection of an area where the motion was detected or more detailed information. I only need to measure the percentage of changed pixels between two images or something similar as a trigger for further processing.

My idea was to extract the frames of a video and then compare the subsequent frames for motion detection. i have the code for frames extraction below

 import cv2
 vidcap = cv2.VideoCapture('Compton.mp4')
 success,image = vidcap.read()
 count = 0
 success = True
 while success:
 success,image = vidcap.read()
cv2.imwrite("frame%d.jpg" % count, image)     # save frame as JPEG file
if cv2.waitKey(10) == 27:                     # exit if Escape is hit
 break
count += 1 

Could anyone help me in finding a way to compare the frame images for motion detection as I am new to python.

0

There are 0 best solutions below