项目作者: Xorfor

项目描述 :
Python program to take pictures or movies triggered by motion or time with a Raspberry Pi
高级语言: Python
项目地址: git://github.com/Xorfor/Camera.git
创建时间: 2018-06-19T18:34:06Z
项目社区:https://github.com/Xorfor/Camera

开源协议:MIT License

下载


Camera

Python program to take pictures or movies triggered by motion or time on a RPi with the PiCamera attached. Code also supports the use of a PIR connected to the GPIO pins.

Prerequisites

Picamera

Install picamera and gpiozero (Python 3):

  1. sudo apt install python3-picamera python3-gpiozero -y

Be sure the Raspberry Pi camera module is connected and enabled in raspi-config:

  1. sudo raspi-config
  1. Go to 5 Interfacing Options
  2. Choose P1 Camera
  3. Choose Yes
  4. Choose Ok
  5. Choose Finish, and boot your RPi if required

PIR (optional)

Buy a PIR like the one which can be found at Kiwi.

Connect the pins of the PIR to the GPIO pins on the Raspberry Pi in the following way:

PIR GPIO
VCC 2
OUT 11
GND 14

Installation

Be sure git is installed:

  1. sudo apt install git

Now install this camera program:

  1. git clone https://github.com/Xorfor/Camera.git

This will create a Camera directory with all the software.

Update

Go to Camera folder and pull new version:

  1. cd Camera
  2. git pull

Get started

Try this program:

  1. cd Camera
  2. python3 camera.py

The output generated will look like (with logging.INFO):

  1. [INFO ] 2020-02-01 21:44:56 Starting Camera 0.2
  2. [INFO ] 2020-02-01 21:44:56 Modus = TESTIMAGE
  3. [INFO ] 2020-02-01 21:44:56 Checking configuration
  4. [INFO ] 2020-02-01 21:44:56 Folder /mnt/usba/images
  5. [INFO ] 2020-02-01 21:44:56 startTestImage
  6. [INFO ] 2020-02-01 21:44:56 Initializing camera
  7. [INFO ] 2020-02-01 21:44:56 camera version: V2.x
  8. [INFO ] 2020-02-01 21:44:56 camera.resolution = (1920,1080)
  9. [INFO ] 2020-02-01 21:44:56 camera.rotation = 0
  10. [INFO ] 2020-02-01 21:44:56 camera.vflip = False
  11. [INFO ] 2020-02-01 21:44:56 camera.hflip = False
  12. [INFO ] 2020-02-01 21:44:56 camAnnotate = False
  13. [INFO ] 2020-02-01 21:44:56 camera.framerate = 10
  14. [INFO ] 2020-02-01 21:44:56 camera.led = False
  15. [INFO ] 2020-02-01 21:44:58 camera.exposure_mode = auto
  16. [INFO ] 2020-02-01 21:44:58 camera.awb_mode = auto
  17. [INFO ] 2020-02-01 21:44:58 camera.shutter_speed = 0
  18. [INFO ] 2020-02-01 21:44:58 camera.iso = 0
  19. [INFO ] 2020-02-01 21:44:58 Camera initialized
  20. [INFO ] 2020-02-01 21:44:58 Making test image
  21. [INFO ] 2020-02-01 21:44:58 image = /mnt/usba/images/imgtest_roos.jpg
  22. [INFO ] 2020-02-01 21:44:59 Test image ended
  23. [INFO ] 2020-02-01 21:44:59 Actions: 1
  24. [INFO ] 2020-02-01 21:44:59 Camera turned off
  25. [INFO ] 2020-02-01 21:44:59 Camera ended

Screen

Under normal conditions, if our connection drops, everything that was running inside of it is terminated. This may result in a lot of hard work being lost. The application screen allows us to create a session, which you can detach and re-attach as required. While detached, everything will continue to run as normal. If the connection drops, you can simply re-attach to the screen session and continue where you left off.

Unfortunately, Raspbian does not come with screen preinstalled, so run the following command to install it:

  1. sudo apt install screen

Once installed, it can be launched by running the following command:

  1. screen

You will receive a welcome screen. Now you can enter your command, eg:

  1. python3 camera.py

Once detached, you can return back to the screen session by running the following command:

  1. screen -x