Last active
May 28, 2017 18:44
-
-
Save erogol/d742eae0ad68366f5f9d56eaf1de3e1b 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
# capture frames from the camera | |
for f in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True): | |
# grab the raw NumPy array representing the image and initialize | |
# the timestamp and occupied/unoccupied text | |
frame = f.array | |
timestamp = datetime.datetime.now() | |
text = "Unoccupied" | |
###################################################################### | |
# COMPUTER VISION | |
###################################################################### | |
# resize the frame, convert it to grayscale, and blur it | |
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) | |
gray = cv2.GaussianBlur(gray, tuple(conf['blur_size']), 0) | |
# if the average frame is None, initialize it | |
if avg is None: | |
print "[INFO] starting background model..." | |
avg = gray.copy().astype("float") | |
rawCapture.truncate(0) | |
continue | |
# accumulate the weighted average between the current frame and | |
# previous frames, then compute the difference between the current | |
# frame and running average | |
frameDelta = cv2.absdiff(gray, cv2.convertScaleAbs(avg)) | |
cv2.accumulateWeighted(gray, avg, 0.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment