How to make a Basic Security Camera | Raspberry Pi
HTML-код
- Опубликовано: 22 окт 2024
- Making a Basic Raspberry Pi Security Camera! In this video I teach you how to use the Camera Module and PIR sensor to take motion triggered photos with your raspberry pi! Also, there will be no video next week due to travels. I'll see you soon!
_________________________________________________________________
Code:
import RPi.GPIO as GPIO
import time
from picamera import PiCamera
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.IN)
camera = PiCamera()
i=0
while True:
i+=1
state = GPIO.input(11)
if state==0:
print "We're clear"
time.sleep(0.1)
elif state==1:
print "STOP RIGHT THERE!"
camera.capture('/home/pi/PIR/pics/image{0:04d}.jpg'.format(i))
______________________________________________________________
Music:
Instrumental produced by Chuki: / chukimusic
I'm trying to do this sec. camera with motion sensor, I am using a pi3 so I'm using the GPIOs connection instead of the breadboard, the software is working except that the camera is not taking pics. can you help me out?
Hey, double to check to make sure you have the camera module enabled.
Here is a more detailed description about using the camera: www.raspberrypi.org/learning/getting-started-with-picamera/worksheet/
Hey Ethan, thanks for replying, I had to change the code to (GPIO.BCM) and (17, GPIO.IN). I see you have the recording option on the link, but how to I add the recording code to the pictures code? can you help me
Hey! Instead of the camera capture line, use the following
camera.start_preview()
camera.start_recording('/home/pi/video.h264')
sleep(10)
camera.stop_recording()
camera.stop_preview()
*Note: Make sure you change the path from '/home/pi/video.h264' to whatever you want it to be.
Let me know if you need more help!
I am using the PIR motion sensor so I wanted to include the code you have in the link, but I am not good at python. What do I need to change or replace?
NOT TESTED: but try this
import RPi.GPIO as GPIO
import time
from picamera import PiCamera
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.IN)
camera = PiCamera()
i=0
while True:
i+=1
state = GPIO.input(11)
if state==0:
print "We're clear"
time.sleep(0.1)
elif state==1:
print "STOP RIGHT THERE!"
camera.start_preview()
camera.start_recording('/home/pi/PIR/pics/video.h264')
sleep(10)
camera.stop_recording()
camera.stop_preview()
Thank you so much for this guide. It has helped me on my hidden camera school project and was much more helpful than other guides I used.
Thanks, your video gets right to the point. Great Job
Thanks! Glad I could help. :D
Nice banging music just loved listening to that all through the video !! and why didn't you use Rapsberry pi motion eye??
Will definitely move to that in the future haha
Thank you !
Very helpful and explained in great detail, I hope you will continue to make this science with things cool and new. once again thank you very much, you really helped me when I was stuck and trouble
Thanks for the feedback! :))
What happened to your channel on all things Rpi?
Great video, especially for me as a newcomer to the RPi. Is there a way one could get the pi to send an image when detected either via sms or upload to Dropbox etc? This would be a great way to alert me to who called at my house when I’m not home.
Hey did you get the answer to this?
I'm trying to get the camera to click 2 pics per second and when it gets all clear it should upload all those images to FTP or cloud or email.
.something on those lines.
I am not a programming guy, so I find this difficult.
Great job, thank you! I'm trying to take 5 pictures when motion is detected while camera is streaming, but when pictures are taken, camera needs to continue streaming. Can you please help me with that?
amazing video man really usefull in comibinatin with some other scripts
Great vid. Cheers! :)
Great job
I'm looking to do the same thing as you but save a 10s or so video instead of taking pictures, would you know how to accomplish this? Nice video though!
Instead of camera.capture() use: raspivid -o video.h264 -t 10000
For more Information: www.raspberrypi.org/documentation/usage/camera/raspicam/raspivid.md
How to help me get the code to run the motion sensor and code capture image when the movement I need him and thank you
Camera is not working with this script. Any ideas? It does scroll saying "we're clear" but does not stop when I get in front of the camera and make movements.
The camera does take photos tho, just not video from what I can tell
@@jafodan1 The program just takes pictures. But you can take the pictures and make a video with them!
Its working
but what coding software are you using? just the command prompt or python?
Hey! I'm using python language and I'm using the text editor PICO to write my code ( PICO can be accessed through the terminal).
Can you help me? Kindly state all the things to do to achieve this project, from beggining to end. What languages are you using? And the codes also. Pleaase. Coz its my school s final project. I badly need help
How to connect it in the Pc to view the pictures taken . And what Os are you using. Pls state all of it
Hello.I am working on a project where I have connected pir motion sensor to arduino uno and connected my webcam to raspberry pi.What I want to do is when motion is detected my webcam should be triggered so that it can capture photo and then send it through email.I am little bit aware that this can be achieved using serial communication but still I need help.
Sounds like an awesome project!
Here are some links to help you get started:
create.arduino.cc/projecthub/eani/diy-how-to-use-the-arduino-uno-to-send-an-email-sms-an-28ac4d
playground.arduino.cc/Code/PIRsense
Let me know if you need more assistance!
I used this code with some modifications for an ultrasonic sensor and save the pics as stated in this code... But it says name ( 'i' is not defined ) in the picture saving line of the code
Hmm. Make sure you're spelling the name of the program right if you're running it from the command line. Also, try locating the program in the file explorer (try looking for an image icon for the program). If these things still don't work please send me pictures of the error you get.
hi the code is working for me ...but it says only we re clear it is not capturing any image what
should i do....the motion is detected by the camera or the motion sensor plz help me with
this?
Sorry you're having issues, it seems like there may be a problem with the GPIO communication with the sensor - so I would double check that.
what do you save the pics directory as??
I saved it as 'pics'.
The path to it would be '/home/pi/PIR/pics/'
I am running the program a python program and it says that 'i' is not defined
Hmm. Make sure you're spelling the name of the program right if you're running it from the command line. Also, try locating the program in the file explorer (try looking for an image icon for the program). If these things still don't work please send me pictures of the error you get.
NAV recorded his Yosemite verse on the same microphone as you
جميل
Please help me 1)Would you please help me to write this code based on when an motion is detected with PIR sensor through raspberry Pi 3 trigger the pi camera to capture the images to load it into a web browser.(based on IOT technique ) 2) 1)Would you please help me to write this code based on when an motion is detected with PIR sensor through raspberry Pi 3 trigger the pi camera to capture the images and send an alert email.(based on IOT technique) Please please help me to write the python code in any of these sections.
Turn off the music and speak up! Otherwise a very useful contribution - thanks
Thanks for the feedback!
Doesn’t work,
No help at all .
Not explained very well
Sorry I couldn't help, please message me if you want help 1 on 1!