Skip to content

Instantly share code, notes, and snippets.

@pondahai
Created March 19, 2019 01:31
Show Gist options
  • Save pondahai/2aa1b9c933db941249b6349c22581932 to your computer and use it in GitHub Desktop.
Save pondahai/2aa1b9c933db941249b6349c22581932 to your computer and use it in GitHub Desktop.
import argparse
import cv2
helpText = "'Esc' to Quit"
def parse_args():
parser = argparse.ArgumentParser(description="CV2 Video Capture Test")
parser.add_argument("--vid", dest="video_dev",
help="video device # of USB webcam (/dev/video?) [1]",
default=0, type=int)
args = parser.parse_args()
return args
if __name__ == "__main__":
args = parse_args()
print("Called with args:")
print(args)
cap = cv2.VideoCapture(args.video_dev)
while(True):
ret, frame = cap.read()
cv2.putText(frame, helpText, (11,20), cv2.FONT_HERSHEY_PLAIN, 1.0, (32,32,32), 4, cv2.LINE_AA)
cv2.putText(frame, helpText, (10,20), cv2.FONT_HERSHEY_PLAIN, 1.0, (240,240,240), 1, cv2.LINE_AA)
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == 27:
break
cap.release()
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment