Created
July 13, 2014 15:59
-
-
Save kamatari/ae0f37cd31375a191e0e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
''' | |
usage: | |
python show_camera_or_video.py | |
or | |
python show_camera_or_video.py cam | |
or | |
python show_camera_or_video.py inputfilename.avi | |
''' | |
import numpy as np | |
import cv2 | |
def getSource(): | |
import sys | |
if (len(sys.argv) != 2): | |
source = "./xxxx.avi" | |
elif (sys.argv[1] == 'cam'): | |
source = 0 # 0 means camera_id | |
else: | |
source = sys.argv[1] | |
return source | |
if __name__=='__main__': | |
source = getSource() | |
cam = cv2.VideoCapture(source) | |
while (True): | |
ret, frame = cam.read() | |
cv2.imshow('frame', frame) | |
if cv2.waitKey(1) & 0xFF == ord('q'): | |
break | |
cam.release() | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment