how to turn a camera into a presence detector?
Moderator: leecollings
-
- Posts: 13
- Joined: Saturday 05 November 2016 15:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.7
- Location: Paris (France)
- Contact:
how to turn a camera into a presence detector?
Hi all,
As I bought several cameras before installing Domoticz on my Synology NAS, I'd like to know how I could turn them into presence detectors...
For the moment, I can already use them in Domoticz to take pictures which are trigered by other detectors but what I'm looking for is different:
When they detect a presence, these cameras (D-Link DCS-935L) can send pictures (via ftp) on my Synology NAS. So, I'd like to detect a change in the directory where these files are stored and sent this information to Domoticz. The change would be the number of directories inside this directory, since for each new detection a new directory is created with the new images.
I'm not an IT specialist... but when I run the following command on my NAS, I can get the number I'm looking for
find /volume1/homes/.../Cameras -type d | wc -l
Can I "os-execute" such a command to get this number in Domoticz LUA?? Or something else?
I tried with:
uservariables["Count"] = tostring(os.execute('sudo find /volume1/.../Cameras -type d | wc -l'))
I get the value "True" but no number...
With
uservariables["Count"] = os.execute('sudo find /volume1/.../Cameras -type d | wc -l')
I don't get anything...
I need help and probably a training too...
Any idea?
Thanks for your help,
BR
As I bought several cameras before installing Domoticz on my Synology NAS, I'd like to know how I could turn them into presence detectors...
For the moment, I can already use them in Domoticz to take pictures which are trigered by other detectors but what I'm looking for is different:
When they detect a presence, these cameras (D-Link DCS-935L) can send pictures (via ftp) on my Synology NAS. So, I'd like to detect a change in the directory where these files are stored and sent this information to Domoticz. The change would be the number of directories inside this directory, since for each new detection a new directory is created with the new images.
I'm not an IT specialist... but when I run the following command on my NAS, I can get the number I'm looking for
find /volume1/homes/.../Cameras -type d | wc -l
Can I "os-execute" such a command to get this number in Domoticz LUA?? Or something else?
I tried with:
uservariables["Count"] = tostring(os.execute('sudo find /volume1/.../Cameras -type d | wc -l'))
I get the value "True" but no number...
With
uservariables["Count"] = os.execute('sudo find /volume1/.../Cameras -type d | wc -l')
I don't get anything...
I need help and probably a training too...
Any idea?
Thanks for your help,
BR
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: how to turn a camera into a presence detector?
You'll need a script that runs in a loop with your command. Store the number in a variable and if number is chabged do something.
Probably bash or python will do good here.
Probably bash or python will do good here.
-
- Posts: 13
- Joined: Saturday 05 November 2016 15:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.7
- Location: Paris (France)
- Contact:
Re: how to turn a camera into a presence detector?
I'm not sure I'll be able to do that... I was just looking for something simple that would run in LUA.
I thought I could get the result (number of directories) from my "find" command through a simple "os.execute" but I doubt now!
I thought I could get the result (number of directories) from my "find" command through a simple "os.execute" but I doubt now!
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: how to turn a camera into a presence detector?
Not so hard if you know Google.
Something like this should do it.
Something like this should do it.
Code: Select all
#!/bin/bash
#Count files at start
PREV=`find /volume1/files/PiCam1/archive/ -type f | wc -l`
RUN=1
#Start endless loop
while :
do
#Check number of files again
NEW=`find /volume1/files/PiCam1/archive/ -type f | wc -l`
#if new does not equal previous update prev and do your stuff
if [ $NEW -ne $PREV ]
then
PREV=$NEW
echo 'do your stuff'
curl -s --connect-timeout 2 --max-time 5 "http://127.0.0.1:8084/json.htm?type=command¶m=udevice&idx=6&nvalue=0&svalue=1"
fi
#increment the run counter
((RUN++))
#if loop has run 60 times exit
if [ $RUN -eq 60 ]
then
exit
fi
#adjust sleep and run counter as needed.
sleep 0.9
done
-
- Posts: 13
- Joined: Saturday 05 November 2016 15:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.7
- Location: Paris (France)
- Contact:
Re: how to turn a camera into a presence detector?
Thank you very much Egregius! I'll try today and I'll let you know.
Mr Google didn't help a lot here..
Regards,
BR
Mr Google didn't help a lot here..
Regards,
BR
-
- Posts: 13
- Joined: Saturday 05 November 2016 15:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.7
- Location: Paris (France)
- Contact:
Re: how to turn a camera into a presence detector?
This is awesome, I managed to have it work! (Even if, this morning, I didn't know anything about scripts and bash...)
In reality, the most difficult was to edit this script with vi on my NAS...
And afterwards, it looks so simple.
My cameras are now my new Domoticz detectors. That's great!
Thanks again Egregius!!!
BR
In reality, the most difficult was to edit this script with vi on my NAS...
And afterwards, it looks so simple.
My cameras are now my new Domoticz detectors. That's great!
Thanks again Egregius!!!
BR
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: how to turn a camera into a presence detector?
You're welcome
If you were on a Pi you could use Inotify to watch a folder, probably a cleaner way. If you're folder isn't huge I don't think there wil be a performance penalty for your nas.
If you were on a Pi you could use Inotify to watch a folder, probably a cleaner way. If you're folder isn't huge I don't think there wil be a performance penalty for your nas.
-
- Posts: 13
- Joined: Saturday 05 November 2016 15:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.7
- Location: Paris (France)
- Contact:
Re: how to turn a camera into a presence detector?
This is for next time...
I already use a Pi system as a 24-bit high end sound system which is connected to my Domoticz too. An alert can turn it on and make it bark or yowl as needed!
Next topic (potential headache for me) => Arm my camera with Domoticz.
Thanks,
BR
I already use a Pi system as a 24-bit high end sound system which is connected to my Domoticz too. An alert can turn it on and make it bark or yowl as needed!
Next topic (potential headache for me) => Arm my camera with Domoticz.
Thanks,
BR
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: how to turn a camera into a presence detector?
Arm?
You mean enable/disable motion detection?
Use the developer console of chrome/firefox to find the url.
You mean enable/disable motion detection?
Use the developer console of chrome/firefox to find the url.
-
- Posts: 13
- Joined: Saturday 05 November 2016 15:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.7
- Location: Paris (France)
- Contact:
Re: how to turn a camera into a presence detector?
Something else to understand...
Thanks,
BR
Thanks,
BR
-
- Posts: 3
- Joined: Thursday 10 November 2016 14:27
- Target OS: Windows
- Domoticz version:
- Contact:
Re: how to turn a camera into a presence detector?
that's what I was looking forEgregius wrote:Not so hard if you know Google.
Something like this should do it.
Code: Select all
#!/bin/bash #Count files at start PREV=`find /volume1/files/PiCam1/archive/ -type f | wc -l` RUN=1 #Start endless loop while : do #Check number of files again NEW=`find /volume1/files/PiCam1/archive/ -type f | wc -l` #if new does not equal previous update prev and do your stuff if [ $NEW -ne $PREV ] then PREV=$NEW echo 'do your stuff' curl -s --connect-timeout 2 --max-time 5 "http://127.0.0.1:8084/json.htm?type=command¶m=udevice&idx=6&nvalue=0&svalue=1" fi #increment the run counter ((RUN++)) #if loop has run 60 times exit if [ $RUN -eq 60 ] then exit fi #adjust sleep and run counter as needed. sleep 0.9 done
thanks
-
- Posts: 13
- Joined: Saturday 05 November 2016 15:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.7
- Location: Paris (France)
- Contact:
Re: how to turn a camera into a presence detector?
My DCS935L camera "set Motion" page is this one: http://192.168.1.xxx/setup.asp?menu=setup&page=motion
But how can I check the "Set Motion" box + save it, via an html command?
I found the following line inside the html code but what can I do with it?
<input id="input_motion_enable" type="checkbox" onchange="onEnableMotion();">
Still a mystery to me...
BR
But how can I check the "Set Motion" box + save it, via an html command?
I found the following line inside the html code but what can I do with it?
<input id="input_motion_enable" type="checkbox" onchange="onEnableMotion();">
Still a mystery to me...
BR
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: how to turn a camera into a presence detector?
Use the developer mode of Firefox/Chrome and set it on the network tab.
Then check the box and hit submit. You'll see the request to activate motion.
Then uncheck the box and hit sublit, you'll see the request to deactivate it.
Then check the box and hit submit. You'll see the request to activate motion.
Then uncheck the box and hit sublit, you'll see the request to deactivate it.
-
- Posts: 13
- Joined: Saturday 05 November 2016 15:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.7
- Location: Paris (France)
- Contact:
Re: how to turn a camera into a presence detector?
Hi Egregius,
I found such things...
http://192.168.1.xxx/setup.asp?menu=setup&page=motion
http://192.168.1.xxx/motion_data.asp?103
http://192.168.1.xxx/motion.asp?token=103
Can I launch these from Blockly? All at once?
Thanks,
BR
I found such things...
http://192.168.1.xxx/setup.asp?menu=setup&page=motion
http://192.168.1.xxx/motion_data.asp?103
http://192.168.1.xxx/motion.asp?token=103
Can I launch these from Blockly? All at once?
Thanks,
BR
Who is online
Users browsing this forum: No registered users and 1 guest