easytarget / esp32-cam-webserver

Expanded version of the Espressif ESP webcam
https://hackaday.io/project/168563-7-esp32-cam-example-expanded
GNU Lesser General Public License v2.1
1.3k stars 352 forks source link

Add timestamp to capture #86

Open drtorchwood opened 3 years ago

drtorchwood commented 3 years ago

Hi there,

I use my unix machine to take regular captures with wget -O capture_$(date) <ip>/capture. In principle, this is fine but I would be great if the time would not only be part of the filename but directly printed in the picture. Alternatively, it might be added to the exif data of the file.

Perhaps (if at some time an ntp module is included) this feature could be added. Thanks!

easytarget commented 3 years ago

Good suggestion, I'd considered this before as I started this project, and decided it was not possible due to memory constraints.

But now I know the code better; I think it is entirely possible to write to the framebuffer before sending images and streams. This is (after all) done for face recognition to put boxes and labels on detected items. So the code is (sorta) already present.

Something for V4, I'll add this to the issues for that.

Meanwhile...

I also capture images on my home server, I do the timestamping on the server side;

Here is an adapted fragment of the script I use (my actual script serves multiple cameras and does some additional sanity/error checking, archive cleaning, and logging)

# Note; this is a bash script for FreeBSD, toolpaths will differ on linux; see comments
# 'convert' is part of the ImageMagick toolset

set URI= http://1.2.3.4/capture/
set CAMERA = Workshop                     # camera name! No spaces...
set TIME = `date "+%d-%b-%Y"`
set DATE = `date "+%H:%M"`
set CONVERT = /usr/local/bin/convert     # /usr/bin/convert on linux
set WGET = /usr/local/bin/wget                # /usr/bin/wget on linux
set CAMHOME = /home/cam/$CAMERA/

$WGET --no-check-certificate --no-verbose "$URI" --output-document=$CAMHOME/capture.jpg

if ( $? == 0 ) then
    convert -quiet $CAMHOME/capture.jpg -gravity South -pointsize 16 -fill White -undercolor Black 
-annotate +0+10 "$CAMERA    $DATE $TIME" $CAMHOME/webcam.jpg
    cp $CAMHOME/webcam.jpg $CAMHOME/archive/$DATE-$TIME.jpg
else 
    cp -f $CAMHOME/webcam-fail-image.jpg $CAMHOME/webcam.jpg
endif

Edit: One advantage of this is control over position, background blending and size. Plus; the standard font used by ImageMagic is quite nice, but if I wanted to change fonts, orientation, etc it is easy; https://legacy.imagemagick.org/Usage/text/#text_operators

easytarget commented 3 years ago

See also #38

Semmu commented 3 years ago

also take a look at fswebcam, as it can do timestamping too.