preface

In the last video we talked about the basic setup of the Raspberry PI environment, and this time we’re going to talk about how the Raspberry PI connects to the camera.

Prepare the material

  1. Raspberry piezero whAn (environment built)
  2. A raspberry PI camera

Connect the Camera

  1. Checking Camera Configurations
$ vcgencmd get_camera
Copy the code

Supported = 0 Indicates that the camera is not enabled

  1. Modify the raspberry PI configuration and enable the camera module
$ sudo raspi-config
Copy the code

Select Interfacing Options and Camera

Select Yes to enable

Check again

$ vcgencmd get_camera
supported = 1 detected = 0
Copy the code

Detected = 0 Indicates that the camera device is not connected. Check whether the device is properly connected

supported = 1 detected = 1  # detected=1: One camera is detected
Copy the code
  1. Test the camera function
$ raspistill -o test.jpg
Copy the code

motion

1. Install the motion

$ sudo apt-get install motion
Copy the code

2. Configuration motion. Conf

$ sudo vi /etc/motion/motion.conf
############## Parameter Description ##################
target_dir /var/lib/motion # Image/video file storage location
webcontrol_localhost on Change on to off to allow non-native access to the HTTP console
stream_localhost on # Change on to off to allow webcam viewing
deamon off # change to on to allow background boot
width # Set the resolution wide
height # Set high resolution
locate_motion_mode on When movement is detected in the image, box the movement area with a rectangle
ffmpeg_video_codec mkv # Set the video encoder
snapshot_interval 1 # Set the period of automatic image collection, when there is movement detected, the collection frequency will be automatically higher
Copy the code
  1. Running motion
$ sudo motion
Copy the code

Now our camera has become a webcam. Visit http://ip:8081 in the browser to see the current picture taken by the camera.