#!/usr/bin/env python2.7

import sys, math
import numpy as np
import cv2

def main(argv):

  if len(argv) == 2:

    # gram video from file
    cap = cv2.VideoCapture(argv[1])

    while(cap.isOpened()):

      # capture frame-by-frame
      ret, frame = cap.read()

      # our operations on the frame come here
      gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)

      # display the resulting frame
      cv2.imshow('frame',gray)
      if cv2.waitKey(1) & 0xFF == ord('q'):
        break

    # when everything is done, release the capture
    cap.release()
    cv2.destroyAllWindows()

  else:
    print("Usage: ", argv[0], " <vid>")
    sys.exit()

if __name__ == '__main__':
# main(sys.argv[1:])
  main(sys.argv)
