├── README.md └── photos.py /README.md: -------------------------------------------------------------------------------- 1 | # esp32cam-python 2 | 3 | Take photo from ESP32-CAM with Python 4 | 5 | [![N|Solid](http://www.gsampallo.com/wp-content/uploads/2019/09/DSC_0062.jpg)](http://www.gsampallo.com/wp-content/uploads/2019/09/DSC_0062.jpg) 6 | 7 | In the program change the URL for yours, as indicated in the serial terminal 8 | ```python 9 | url = "http://IP/cam-hi.jpg" 10 | ``` 11 | 12 | This example work with https://github.com/yoursunny/esp32cam library. 13 | 14 | Check the project page: https://www.gsampallo.com/blog/?p=500 15 | -------------------------------------------------------------------------------- /photos.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import requests 3 | from io import BytesIO 4 | import os, sys 5 | import datetime 6 | 7 | datetime_object = datetime.datetime.now() 8 | print(datetime_object) 9 | d1 = str(datetime_object) 10 | output = d1.replace(":","") 11 | output = output.replace(" ","_") 12 | output = output[0:17]+".jpg" 13 | 14 | #Cambiar la direccion IP segun su configuracion 15 | url = "http://192.168.12.226/cam-hi.jpg" 16 | 17 | response = requests.get(url) 18 | img = Image.open(BytesIO(response.content)) 19 | 20 | try: 21 | img.save(output) 22 | except IOError: 23 | print("cannot convert", infile) 24 | 25 | datetime_object = datetime.datetime.now() 26 | print(datetime_object) 27 | --------------------------------------------------------------------------------