February 2022
Intermediate to advanced
182 pages
4h 25m
English
Create a new Python script file in the projects/photohook directory using your preferred code editor and name it phototest.py. Add the following lines of Python code, paste your generated webhook URL in place of WEBHOOK_URL_GOES_HERE, and save the file:
| | import requests |
| | |
| | WEBHOOK_URL = 'WEBHOOK_URL_GOES_HERE' |
| | CAPTURE_FILE = r'/home/pi/projects/photohook/capture.jpg' |
| | |
| | photo = {'media': open(CAPTURE_FILE, 'rb')} |
| | requests.post(WEBHOOK_URL, files=photo) |
Open a Terminal window, change to the PhotoHook project directory, and snap a Pi Camera picture using the raspistill app:
$ cd ~/projects/photohook $ raspistill --width 640 --heigh 480 --quality 75 -o capture.jpg
Confirm that the new capture.jpg ...
Read now
Unlock full access