L_i_v_e wrote: ↑
Wed Sep 20, 2017 9:37 am
Hi guys, i need help to configure the camera.
I have a python script that runs 24/7 and i want RPi Cam Web Interface
to save a picture when a button (GPIO connected) is pressed. Every time the button is pressed the picture has to be saved with the same name, deleting the old one. After the picture is taken i will send it to a server via the python script.
So, how can i order RPi Cam Web Interface to save a picture always with the same name, in a script?
It can be shell, python or whatever, i'll integrate it later in my code.
There are a few options here but it also depends on what type of image you want.
The software is continuously generating the image that is used for the preview. The resolution of this is set by the 'width' camera setting. It defaults to 512 pixels but can be increased. If this resolution image is Ok for your purposes then you can just grab the latest copy from /dev/shm/mjpeg/cam.jpg
If you want a full resolution image as defined by the camera settings then you can grab this by sending the 'im' command to command pipe in the web folder. This takes a picture and creates the image jpg file and a thumbnail image in the media folder.
Sending the command from a shell file is a simple as echo 'im' > /var/www/html/FIFO (adjust folder if different). For python you just need to open the pipe like a file, print the 'im' command and close the file.
The captured image file will normally be given a unique name so for your purpose you need to rename it and copy / move it to where you want it. This could be done by either waiting in the same program that did the im command for say 1 second, or you could just use the end_img macro to do it separately. The macro will be fed the image file name as captured so the macro isjust a shell mv to the folder/name you want.
Also if you are not using the web interface for anything you could change the image_path definition in the config file in /etc/raspimjpeg
Normally this is something like
where the %variables are what define the unique captured image name. So if that was made
all captured images would have the same name
As an aside I do something similar to support a doorbell notification operation. When my doorbell is pushed I get a IFTTT phone notification plus web access command is made to the RPi camera software camera by the door to grab the latest image. It keeps the last 4 images on the same webserver and a html page shows these images which I can view on my phone. If that is of any interest I can point to further details,