Created
May 27, 2017 02:55
-
-
Save zhanghang1989/b413e065041b9bd8679f9b142601ca1d to your computer and use it in GitHub Desktop.
Python Opencv Camera Show
This file contains 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
import cv2 | |
def run_demo(mirror=False): | |
cam = cv2.VideoCapture(0) | |
cam.set(3, 640) | |
cam.set(4, 480) | |
key = 0 | |
while True: | |
# read frame | |
ret_val, img = cam.read() | |
if mirror: | |
img = cv2.flip(img, 1) | |
cv2.imshow('my webcam', img) | |
key = cv2.waitKey(1) | |
if key == 27: | |
break | |
cv2.destroyAllWindows() | |
def main(): | |
run_demo(mirror=True) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment