Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created March 20, 2018 23:19
Show Gist options
  • Save parzibyte/eb2c67dd2847e5de4ce12d56e4c7d3c2 to your computer and use it in GitHub Desktop.
Save parzibyte/eb2c67dd2847e5de4ce12d56e4c7d3c2 to your computer and use it in GitHub Desktop.
"""
Tomar foto con Python y opencv
@date 20-03-2018
@author parzibyte
@see https://www.parzibyte.me/blog
"""
import cv2
"""
En este caso, 0 quiere decir que queremos acceder
a la cámara 0. Si hay más cámaras, puedes ir probando
con 1, 2, 3...
"""
cap = cv2.VideoCapture(0)
leido, frame = cap.read()
if leido == True:
cv2.imwrite("foto.png", frame)
print("Foto tomada correctamente")
else:
print("Error al acceder a la cámara")
"""
Finalmente liberamos o soltamos la cámara
"""
cap.release()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment