Photo Capture Plugin

Purpose

The purpose of this plugin is to capture an image from locally connected cameras.

Usage

Cameras connected via a local ethernet network are sometimes referred to as IP or WEB cameras. Most IP/WEB connected cameras allow photo and/or video collection by one of two protocols; http or rtsp. The site https://www.ispyconnect.com/sources.aspx can be used to determine if and how a camera image can be captured from a particular make and model of camera, via http or rtsp. The file defined in config_filename (see Arguments below) must contain a single command that is used get the photo, and only 2 command types re currently supported by this plugin, either http or ffmpeg. The command must start with either of these keywords. Comments are allowed in the config filename, but must start with '#'. Some examples of the contents of config_filename:
1
http://root:[email protected]/cgi-bin/viewer/video.jpg
2
ffmpeg -y -i rtsp://admin:[email protected]:554/live -vframes 1
Copied!
If collecting via rtsp, then installation of the ffmpeg command must be done manually, as below, if its not already installed. If ffmpeg is not installed, do the following on an X86 device.
1
sudo apt-get update
2
sudo apt-get install -y libav-tools
3
ffmpeg -version
Copied!
Installing ffmpeg on a Rasp Pi, use an armhf static build (See -> https://johnvansickle.com/ffmpeg/)
1
cd /usr/local/bin
2
wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-armhf-static.tar.xz
3
tar xf ffmpeg-release-armhf-static.tar.xz
4
cd ffmpeg-4.1.4-armhf-static
5
mv * ../
6
ffmpeg -version
Copied!
For testing, try and caputre an image to the filename /tmp/img.jpg, try the following:
1
ffmpeg -y -i rtsp://admin:[email protected]:554/live -vframes 1 /tmp/img.jpg
Copied!
Capturing an image via http is much easier. The convert tool is optional, and only to reduce the size of the image if it is too big.
1
sudo apt-get update
2
sudo apt-get install -y imagemajick
3
wget -O /tmp/temp.jpg http://<uid>:<pwd>@192.168.0.23/jpg/image.jpg?size=3 && convert /tmp/temp.jpg -resize 650 /tmp/photo1.jpg
4
wget -O /tmp/photo1.jpg http://<uid>:<pwd>@192.168.0.23/jpg/image.jpg?size=3
Copied!
You may have to encode the password using this guide: https://www.w3schools.com/tags/ref_urlencode.ASP if it contains special characters. For example; A password of (say) ()&^% becomes: %28%29%26%5E%25.
At the moment, the plugin WILL NOT setup the WATCH scenario in the Ardexa YAML file. This MUST be done manually. An example is shown below. If you don't know how to do this, contact Ardexa.
1
watch:
2
- table: data
3
source: photo
4
file: /opt/ardexa/watch/image.jpg
5
check: hash
6
attach: true
Copied!
Ardexa does not recommend USB connected cameras. However if you need to connect to a USB device, the fswebcam seems to be a more usable and stable app. The fswebcam allows for better collection and control of camera properties. Its best to use a config file to control exposure and resolution. Its usually better to leave the settings to auto, so the camera can work it out. It may be work better to make sure the camera skips the first 50 or so frames, so it can execute its auto focus, etc functions before taking a frame. To install the fswebcam package and set controls, do the following:
1
sudo apt-get update
2
sudo apt-get install -y fswebcam
3
fswebcam -d /dev/video1 -r 640x480 --jpeg 85 -F 1 /home/ardexa/test.jpg
4
fswebcam -d v4l2:/dev/video0 --list-controls
5
fswebcam -d v4l2:/dev/video0 --set brightness=50%
6
fswebcam -d v4l2:/dev/video0 --set contrast=3
Copied!

Arguments

This plugin only needs 1 mandatory argument, a config filename, which as described above contains the Linux command to take a frame. All the other options are as follows --latitude ... The lattiude, required if taking pictures only during daylight hours --longitude ... The longitude, required if taking pictures only during daylight hours --elevation ... The elevation (in metres), required if taking pictures only during daylight hours --photo_only_during_sunlight ... If present, it will only take photos during daylight hours --after_sunrise_before_sunset ... If present, it will only take photos sunsetrise hours before sunset or after sunrise --sunsetrise ... A value something like 0.0 to 24.0, in hours --copy_storage ... If if this argument is present, it will copy photos to storage_directory --config_filename ... This is the config filename (see below). The default is /opt/ardexa/config/photo-capture/photo.config --output_filename ... This is the directory for copying the photo. Default is /opt/ardexa/watch/image.jpg --storage_directory ... This is the directory to store the photos. Default is /opt/ardexa/photo/storage/ --max_storage_age ... This is the maximum days to store photos. Default is 10.0 days. Anything after this will be deleted. Fractions may be used.

AXIS Camera Control

These are high quality cameras made in Sweden. They can be controlled (pan/zoom/tilt/etc) using a (local) web API. See reference: https://www.axis.com/support/developer-support/axis-camera-application-platform/q-and-a. API guide is found at : https://www.axis.com/files/tech_notes/script_guide.pdf. For controlling the camera, the userid must have access rights to undertake the task. Examples below
1
curl --digest -u "userid:password" -X GET http://192.168.2.2/axis-cgi/com/ptz.cgi?whoami=1
2
curl --digest -u "userid:password" -X GET http://192.168.2.2/axis-cgi/com/ptz.cgi?info=1&camera=1
3
curl --digest -u "userid:password" -X GET http://192.168.2.2/axis-cgi/com/ptz.cgi?query=position
4
curl --digest -u "userid:password" -X GET http://192.168.2.2/axis-cgi/com/ptz.cgi?rpan=10&camera=1
5
curl --digest -u "userid:password" -X GET http://192.168.2.2/axis-cgi/com/ptz.cgi?rpan=-30&camera=1
6
curl --digest -u "userid:password" -X GET http://192.168.2.2/axis-cgi/com/ptz.cgi?move=home
7
curl --digest -u "userid:password" -X GET http://192.168.2.2/axis-cgi/com/ptz.cgi?rtilt=-30&camera=1
Copied!

VIVOTEK Camera Control

These are cameras made in Taiwan. Some of them can be controlled (pan/zoom/tilt/etc) using a (local) web API. See reference: http://download.vivotek.com/downloadfile/downloads/usersmanuals/fd8167manual_en.pdf. For controlling the camera, the userid must have access rights to undertake the task. Examples below
1
curl -X GET http://userid:[email protected]/cgi-bin/admin/getparam.cgi?network_ipaddress
2
curl -X GET http://userid:[email protected]/cgi-bin/admin/getparam.cgi?system_hostname
3
curl -X GET http://userid:[email protected]/cgi-bin/admin/getparam.cgi?videoin_ptzstatus
4
curl -X GET http://userid:[email protected]/cgi-bin/admin/getparam.cgi?capability_eptz
5
curl -X GET http://userid:[email protected]/cgi-bin/admin/syslog.cgi
6
curl -X GET http://userid:[email protected]/cgi-bin/admin/getparam.cgi?ircutcontrol_disableirled
7
curl -X GET http://userid:[email protected]/cgi-bin/admin/setparam.cgi?ircutcontrol_disableirled=1
8
curl -X GET http://userid:[email protected]/cgi-bin/admin/getparam.cgi?eptz_c0_zoomspeed
Copied!
Last modified 2mo ago