Skip to content

Instantly share code, notes, and snippets.

@falco694
Created June 8, 2019 17:30
Show Gist options
  • Save falco694/a67fba0b04f7205768d3ba5e68f8d1e6 to your computer and use it in GitHub Desktop.
Save falco694/a67fba0b04f7205768d3ba5e68f8d1e6 to your computer and use it in GitHub Desktop.
Webカメラの映像表示
#!/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