Using on-camera motion detection
Using on-camera motion detection
Is anyone using on-camera motion detection with Grandstream cameras? Possibly using the "Alarm HTTP server" setting to communicate motion triggers to zmtrigger.pl, similar to what's described in the Axis motion detection wiki?
-
- Posts: 2
- Joined: Fri Jan 02, 2015 10:15 pm
Re: Using on-camera motion detection
If you can save to an ftp server or network folder, you can do something like I did with my foscam fi9821w. When my camera detects motion, it saves a snapshot to an ftp server. I wrote a bash script that uses inotify to monitor the folder for files added. When it detects a new file, it uses zmtrigger to put my monitor into an alarm state. I'll attach the script in hopes it helps you or someone else in the future (I'm no programmer and I knew nothing about writing a bash script before this so it is probably crap but gets the job done!).
edit: I seem to be failing with this attachment. The forum says I've met my quota on attachments and I cant link to an outside site (dropox) so I'll copy and paste.
edit: I seem to be failing with this attachment. The forum says I've met my quota on attachments and I cant link to an outside site (dropox) so I'll copy and paste.
Code: Select all
#!/bin/bash
#
zmHost=192.168.1.103
zmPort=6802
zmCamId=8
zmAlarmState="off" #default alarm to off
zmScore="1"
zmCause="foscam motion detection"
snapshotDir="/home/ftpuser/ftpUploads/webCamSnapshots/change/me"
# Send a ZoneMinder trigger
zmtrigger() {
zmAlarmState="$1"
echo "$zmCamId|$zmAlarmState|$zmScore|$zmCause|none|none" >/dev/tcp/"$zmHost"/"$zmPort"
}
latestfile() {
unset -v latest
for file in "$snapshotDir"/*; do
[[ $file -nt $latest ]] && latest=$file
done
echo "$file"
}
#monitor the ftp directory the foscam saves motion snapshots to.
while inotifywait -e create "$snapshotDir"; do
alarmTime=$(date +%s)
alarmSnapshot=$(latestfile)
if [ "$zmAlarmState" == "off" ]; then
zmtrigger "on"
latestSnapshot=$(latestfile)
alarmTime=$(date +%s)
fi
until [ "$zmAlarmState" == "off" ] && [ "$alarmSnapshot" == "$latestSnapshot" ]; do
#check if another motion snapshot was added to the dir.
#If yes, reset alarm variables.
#If no, check if theres been at least 6 seconds from the last snapshot
if [ "$alarmSnapshot" != $(latestfile) ]; then
alarmSnapshot=$(latestfile)
alarmTime=$(date +%s)
latestSnapshot=$(latestfile)
elif [ "$(($(date +%s)-$alarmTime))" -ge 6 ]; then #I set 6 seconds because my camera takes snapshot every 5 seconds while detecting motion
zmtrigger "off"
fi
# wait one second and check again.
sleep 1
done
done
Last edited by farmercyst on Sat Jan 03, 2015 5:48 am, edited 2 times in total.
Re: Using on-camera motion detection
i'm very interested...
that would save a lot of cpu....
Simon
that would save a lot of cpu....
Simon
-
- Posts: 2
- Joined: Fri Jan 02, 2015 10:15 pm
Re: Using on-camera motion detection
Exactly the point! This is the only way I could use 720p with this camera. I can add a few more nowsime wrote:i'm very interested...
that would save a lot of cpu....
Simon
Re: Using on-camera motion detection
Do you use a separate FTP dir and running script for each camera?
Re: Using on-camera motion detection
I used to use it for my foscamspatpend wrote:Is anyone using on-camera motion detection with Grandstream cameras? Possibly using the "Alarm HTTP server" setting to communicate motion triggers to zmtrigger.pl, similar to what's described in the Axis motion detection wiki?
http://www.zoneminder.com/wiki/index.ph ... on_with_ZM
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.
Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs