Last active
October 23, 2018 06:37
-
-
Save astrophysik928/3fde418b2bd30a451703377cb4f49299 to your computer and use it in GitHub Desktop.
ノートPC内蔵カメラで写真撮影(python)
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 | |
import datetime | |
fileName = "photo_" + datetime.datetime.today().strftime('%Y%m%d_%H%M%S') + ".png" | |
# 内蔵カメラのデバイスIDは0、USBで接続したカメラは1以降。 | |
capture = cv2.VideoCapture(0) | |
# 取得した画像データは変数imageに格納。retは取得成功変数。 | |
ret, image = capture.read() | |
if ret == True: | |
# 取得した画像を出力。fileNameは出力する画像名。 | |
cv2.imwrite(fileName, image) | |
print("taking picture is completed!!") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment