def __init__(self): # If video source is USB device for testing, we will use the vs and cap variables below. #self.vs = WebcamVideoStream(src=0).start() # so we want to read video in as a stream now so we can self.capture = cv2.VideoCapture(0) # CHANGE MILES # 0 for drone, # 1 for webcam in the case of Miles computer # If video source is drone, we will use the code below. self.fourcc = cv2.cv.CV_FOURCC(*'XVID') self.out = cv2.VideoWriter('output.mov', self.fourcc, 20.0, (640, 480)) # So we want to open application for video driver first, and then run file. # Currently the webcam video stream class does not work for video capture, therefore we # need to stick to cv2.VideoCapture() until WebcamVideoStream can be optimized for working. # Instantiate objects self.filters = Filters() # Filters for filtering the file. self.motionDetection = MotionDetection( ) # MotionDetection for grabbing motion. self.cascadeDetection = Cascading( ) # Cascading for feature recognition. self.blurDetection = DetectBlur( 150) # 100 would be the value to be used for fine tuning. self.destroyWindows = WindowDestruction() time.sleep(0.25) # Allow camera a few miliseconds for booting up. self.firstFrame = None # First frame is a variable to be used for motion tracking, firstFrame is the frame being compared for motion change. # Initiate toggles. self.motionTime = False self.cascadeTime = False self.blurDetectionTime = False # Initialize external variables. self.numFrames = 0 self.ts = time.time()
# import the necessary packages import datetime import time import cv2 from WindowDestruction import WindowDestruction from WebcamVideoStream import WebcamVideoStream import numpy as np from MotionDetection import MotionDetection from Cascading import Cascading motion = MotionDetection() destroyWindows = WindowDestruction() cascades = Cascading() # camera = cv2.VideoCapture(0) camera = WebcamVideoStream(src=0).start() time.sleep(0.25) # initialize the first frame in the video stream # WE WILL WANT TO UPDATE THIS VARIABLE TO OFTEN CHANGE THE FIRST FRAME # BASED ON MOVEMENT OF MOTION...WILL BE TRICKY. cascadeTime = False # loop over the frames of the video while True: # grab the current frame and initialize the occupied/unoccupied # text frame = camera.read() #saveFrame = frame # For storing a copy for encoding later on. frame = cv2.resize(frame, (500, 500)) #(grabbed, frame) = camera.read()