-
Notifications
You must be signed in to change notification settings - Fork 0
/
foscam_api.sh
39 lines (32 loc) · 993 Bytes
/
foscam_api.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# Defaults
# Path to save the pictures
PICTURE_PATH=${PICTURE_PATH:-./}
# Path to the log-file
LOG_FILE=${LOG_FILE:-foscam_api.log}
# Time to sleep while the camera is moving
TRAVEL_DURATION=${TRAVEL_DURATION:-10}
goto_position() {
# Function to go to prest position
# Arg1 : URL of the camera
# Argé : Name of the position to go to
CAM="$1"
POSITION="$2"
echo "GOING TO POSITION : $POSITION" >> $LOG_FILE
curl -s "$(cmd_url $CAM ptzGotoPresetPoint)&name=$POSITION" > /dev/null
sleep $TRAVEL_DURATION
}
take_picture(){
# Function to take a picture and save it locally
# Arg1 : URL of the camera
CAM="$1"
PICTURE_NAME="$PICTURE_PATH/$CAM-$POSITION.jpg"
wget "$(cmd_url $CAM snapPicture2)" -O "$PICTURE_NAME" -o /dev/null >> $LOG_FILE
}
cmd_url(){
# Helper function to build the URI
# Arg1 : URL of the camera
CAM="$1"
CMD="$2"
echo "http://$CAM/cgi-bin/CGIProxy.fcgi?cmd=$CMD&usr=$USER&pwd=$PSSWD"
}