Riddeek
Posts: 31
Joined: Thu Apr 21, 2016 2:12 pm

Help in surveillance system

Wed Aug 10, 2016 12:12 am

I have a rpi 3 which i am running headless, a PIR sensor, 5MP visible light Picam and i am interested in making a video surveillance system incorporated with the PIR sensor, my problem is that i need help with the proper code

Firstly, i have connected the pir sensor and i have tested it using this code

Code: Select all

from gpiozero import MotionSensor
pir = Motionsensor(7)
while True:
if pir.motion_detected:
print ("Motion Detected")
And i see the text "motion detected" on the putty ssh interface


Also i have been able to test the picam and install vlc on my pi and streamed a live video feed to my local network which was viewed with my laptop and phone using VLC player using the below code

Code: Select all

raspivid -o - -t 0 -hf -vf -w 800 -h 400 -fps 24 |cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8160}' :demux=h264
After days of surfing the net, i discovered that almost all blogs made use of "motion" software. I don't need the camera to do any "background subtraction" or any DSP related stuff, i simply want to trigger it with my PIR sensor which unfortunately does not make motion my best choice.

Now what i want is that, each time the pir sensor detects motion i want it to :

(1)stream the video live to my local network

(2)save it to a predefined storage path (i have auto mounted a USB flash drive to my pi3)

(3) and lastly upload to dropbox (i have installed dropbox on my pi and i have gotten the API secret key and connected it to my dropbox account - i have even uploaded an image, i just want it to be automated in this process)

PS: pls do not forget that i am running the pi headless(putty)


I know it might be time consuming for whoever is willing to help, but i will really appreciate if someone can just post all the codes together which i will put in a python file and autorun anytime the pi is booted.

And please, please and please do not refer me to this link: https://www.raspberrypi.org/learning/pa ... worksheet/ i have gone through it but didn't really put all the codes in one place for direct automation of the process. Thanks

Riddeek
Posts: 31
Joined: Thu Apr 21, 2016 2:12 pm

Re: Help in surveillance system

Wed Aug 10, 2016 9:04 am

...

User avatar
Gavinmc42
Posts: 3916
Joined: Wed Aug 28, 2013 3:31 am

Re: Help in surveillance system

Wed Aug 10, 2016 9:54 am

Pi's are for the education market.
You are already 90% there, you just need the learn the last bit.
Rule of thumb, last 10% will take 90% of your time.

Could do it with shell script or python or.......
Google is your friend....
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges


SkyRise
Posts: 179
Joined: Tue Jan 24, 2012 1:20 pm

Re: Help in surveillance system

Wed Aug 10, 2016 12:02 pm

Your indentation in your code looks incorrect (or non-existent)

Code: Select all

from gpiozero import MotionSensor
pir = Motionsensor(7)
while True:
    if pir.motion_detected:
        print ("Motion Detected")

Riddeek
Posts: 31
Joined: Thu Apr 21, 2016 2:12 pm

Re: Help in surveillance system

Sat Aug 13, 2016 5:29 pm

SkyRise wrote:Your indentation in your code looks incorrect (or non-existent)

Code: Select all

from gpiozero import MotionSensor
pir = Motionsensor(7)
while True:
    if pir.motion_detected:
        print ("Motion Detected")


Yeah dats how it is :roll:

Riddeek
Posts: 31
Joined: Thu Apr 21, 2016 2:12 pm

Re: Help in surveillance system

Sat Aug 13, 2016 5:33 pm

Guys pls in using the raspivid command, how do i make it save the video to a predefined path. Whats the correct code for that, i have been searching google but it seems a lot of pple rather save in the directory in which they run their code but in my case i want to save the video to an external USB flash drive which i have automounted on the pi.

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: Help in surveillance system

Sat Aug 13, 2016 6:03 pm

Riddeek wrote:Guys pls in using the raspivid command, how do i make it save the video to a predefined path. Whats the correct code for that, i have been searching google but it seems a lot of pple rather save in the directory in which they run their code but in my case i want to save the video to an external USB flash drive which i have automounted on the pi.

Code: Select all

Display camera output to display, and optionally saves an H264 capture at requested bitrate
usage: raspivid [options]
Image parameter commands
-?, --help      : This help information
-w, --width     : Set image width <size>. Default 1920
-h, --height    : Set image height <size>. Default 1080
-b, --bitrate   : Set bitrate. Use bits per second (e.g. 10MBits/s would be -b 10000000)
-o, --output    : Output filename <filename> (to write to stdout, use '-o -')
I ran raspivid --help on a pi and it presented the above details on how to use it, truncated here at the point where it tells you how to save the output with a specific file name and location.

Riddeek
Posts: 31
Joined: Thu Apr 21, 2016 2:12 pm

Re: Help in surveillance system

Sat Aug 13, 2016 7:44 pm

Yeah i saw that and i tried it but i got an error. Can someone please post an example for me to follow. I really need the output on the flash drive

SonOfAMotherlessGoat
Posts: 690
Joined: Tue Jun 16, 2015 6:01 am

Re: Help in surveillance system

Sun Aug 14, 2016 12:52 am

What command did you use, what flags (did you use -o) and what error did you get?
Account Inactive

Return to “Beginners”