1 | initial version |
import numpy as np import cv2
cap = cv2.VideoCapture('/Users/nimya/Desktop/people-walking2.mp4')
ret, current_frame = cap.read()
fgbg = cv2.createBackgroundSubtractorMOG2()
previous_frame = current_frame
def framediff(current_frame_gray,previous_frame_gray): frame_diff = cv2.absdiff(current_frame_gray,previous_frame_gray) cv2.imshow('frame diff ',frame_diff) return frame_diff
while(cap.isOpened()): current_frame_gray = cv2.cvtColor(current_frame, cv2.COLOR_BGR2GRAY) previous_frame_gray = cv2.cvtColor(previous_frame, cv2.COLOR_BGR2GRAY) frame_diff=framediff(current_frame_gray,previous_frame_gray)
if cv2.waitKey(1) & 0xFF == ord('q'): break previous_frame = current_frame.copy() ret, current_frame = cap.read()
cap.release() cv2.destroyAllWindows()
2 | No.2 Revision |
import numpy as np
np
import cv2
cap = cv2.VideoCapture('/Users/nimya/Desktop/people-walking2.mp4')
ret, current_frame = cap.read()
fgbg = cv2.createBackgroundSubtractorMOG2()
previous_frame = current_frame
def framediff(current_frame_gray,previous_frame_gray):
framediff(current_frame_gray,previous_frame_gray):
frame_diff = cv2.absdiff(current_frame_gray,previous_frame_gray)
cv2.imshow('frame diff ',frame_diff)
return frame_diffframe_diff
while(cap.isOpened()):
while(cap.isOpened()):
current_frame_gray = cv2.cvtColor(current_frame, cv2.COLOR_BGR2GRAY)
if cv2.waitKey(1) & 0xFF == ord('q'):
ord('q'):
break
previous_frame = current_frame.copy()
ret, current_frame = cap.read()cap.read()
cap.release()
cap.release()
cv2.destroyAllWindows()
3 | No.3 Revision |
import numpy as np
import cv2
cap = cv2.VideoCapture('/Users/nimya/Desktop/people-walking2.mp4')
ret, current_frame = cap.read()
fgbg = cv2.createBackgroundSubtractorMOG2()
previous_frame = current_frame
def framediff(current_frame_gray,previous_frame_gray):
frame_diff = cv2.absdiff(current_frame_gray,previous_frame_gray)
cv2.imshow('frame diff ',frame_diff)
return frame_diff
while(cap.isOpened()):
current_frame_gray = cv2.cvtColor(current_frame, cv2.COLOR_BGR2GRAY)
previous_frame_gray = cv2.cvtColor(previous_frame, cv2.COLOR_BGR2GRAY)
frame_diff=framediff(current_frame_gray,previous_frame_gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
previous_frame = current_frame.copy()
ret, current_frame = cap.read()
cap.release()
cv2.destroyAllWindows()
4 | No.4 Revision |
import numpy as np
import def framediff(current_frame_gray,previous_frame_gray):
while(cap.isOpened()):
cap.release()
cv2.destroyAllWindows()
5 | No.5 Revision |
Code:
import numpy as np
np
import cv2
cap = cv2.VideoCapture('/Users/nimya/Desktop/people-walking2.mp4')
ret, current_frame = cap.read()
fgbg = cv2.createBackgroundSubtractorMOG2()
previous_frame = current_frame
def framediff(current_frame_gray,previous_frame_gray):
frame_diff = cv2.absdiff(current_frame_gray,previous_frame_gray)
cv2.imshow('frame diff ',frame_diff)
return frame_diff
while(cap.isOpened()):
current_frame_gray = cv2.cvtColor(current_frame, cv2.COLOR_BGR2GRAY)
previous_frame_gray = cv2.cvtColor(previous_frame, cv2.COLOR_BGR2GRAY)
frame_diff=framediff(current_frame_gray,previous_frame_gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
previous_frame = current_frame.copy()
ret, current_frame = cap.read()
cap.release()
cv2.destroyAllWindows()