Created
June 8, 2019 17:30
-
-
Save falco694/a67fba0b04f7205768d3ba5e68f8d1e6 to your computer and use it in GitHub Desktop.
Webカメラの映像表示
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
#!/usr/bin/python | |
#coding: utf-8 | |
import cv2 | |
def main(): | |
#Webカメラの映像表示 | |
capture = cv2.VideoCapture(0) | |
if capture.isOpened() is False: | |
raise("IO Error") | |
while True: | |
#Webカメラの映像とりこみ | |
ret, image = capture.read() | |
if ret == False: | |
continue | |
#Webカメラの映像表示 | |
cv2.imshow("Capture", image) | |
k = cv2.waitKey(10) | |
#ESCキーでキャプチャー画面を閉じる | |
if k == 27: | |
break | |
cv2.destroyAllWindows() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment