Created
February 2, 2019 16:25
-
-
Save csvance/01136d6cc27142082bf7bcc7173e67ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
cap = cv2.VideoCapture(0) | |
final_frame = None | |
initial_frame = None | |
while True: | |
# Capture frame-by-frame | |
ret, frame = cap.read() | |
# Our operations on the frame come here | |
final_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) | |
if initial_frame is not None: | |
diff = cv2.absdiff(initial_frame, final_frame) | |
cv2.imshow('frame', diff) | |
if cv2.waitKey(1) & 0xFF == ord('q'): | |
break | |
initial_frame = final_frame | |
# When everything done, release the capture | |
cap.release() | |
cv2.destroyAllWindows() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment