destroyWindows = WindowDestruction()

firstFrame = None

while True:
    # grab the frame from the threaded video stream and resize it
    # to have a maximum width of 400 pixels
    frame = vs.read()
    #saveFrame = frame                       # For storing a copy for encoding later on.
    #frame = cv2.resize(frame, (500, 500))

# If the WebcamVideoStream object has a frame grabbed, lets perform operations.
if (vs.grabbed):
        gray = filters.grayScaleImage(frame)
        gray = filters.gausBlurSpecified(gray, 21, 21)
        # originally our dimensions for gaussian blur is 21 by 21
         
        # if the first frame is None, initialize it
        '''if (cv2.waitKey(20) & 0xFF == ord('r')):    # If r is pressed we want to refresh frame to
            firstFrame = gray
            continue
        else:
            firstFrame = gray
            continue'''
        if firstFrame is None:
            firstFrame = gray
            continue

        # compute the absolute difference between the current frame and
        # first frame