-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
203 additions
and
36 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,43 @@ | ||
# Código para Capturar una Imagen | ||
# https://lemariva.com/blog/2020/06/micropython-support-cameras-m5camera-esp32-cam-etc | ||
# Captura de fotos con ESP32CAM | ||
# Creado el 7 de junio de 2024 | ||
|
||
import esp | ||
import machine | ||
import time | ||
import camera | ||
import machine | ||
from time import sleep | ||
|
||
# Inicializar la cámara | ||
camera.init(0, format=camera.JPEG) | ||
flash = machine.Pin(4, machine.Pin.OUT) | ||
|
||
# Capturar una imagen | ||
buf = camera.capture() | ||
foto_count = 1 | ||
|
||
# Guardar la imagen en un archivo | ||
#with open("captura.jpg", "wb") as f: | ||
# f.write(buf) | ||
while (True): | ||
|
||
nombre = "IMG"+str(foto_count)+".jpg" | ||
print(nombre) | ||
|
||
try: | ||
camera.init(0, format=camera.JPEG, fb_location=camera.PSRAM) | ||
camera.framesize(camera.FRAME_VGA) | ||
|
||
print("Imagen guardada como captura.jpg") | ||
flash.value(1) | ||
sleep (0.5) | ||
|
||
# Finalizar la cámara | ||
camera.deinit() | ||
# Captura la imagen | ||
img = camera.capture() | ||
print("Tamaño=",len(img)) | ||
|
||
flash.value(0) | ||
camera.deinit () | ||
|
||
# Guardar la imagen en el sistema de archivos | ||
imgFile = open(nombre, "wb") | ||
imgFile.write(img) | ||
imgFile.close() | ||
|
||
foto_count += 1 | ||
|
||
sleep (10) | ||
|
||
except Exception as err: | ||
|
||
print("Error= "+str (err)) | ||
sleep(2) |
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