Raspberry Pi wide-angle camera usage tutorial, you have already configured the system by default.
Ready to work
- Raspberry Pi Development Board x 1
- Raspberry Pi wide-angle camera x 1
Method 1: Operate the camera locally on the Raspberry Pi
1. Connect the camera to our Raspberry Pi
2. Upgrading the system
To use the camera module, you must use a newer operating system, which can recognize that the camera module is connected. The easiest way is to download a Raspbian system image directly from the Raspberry Pi official website and install it on a brand new SD card.
No matter what version of the Raspbian system you are using, it is strongly recommended that you use the following command to update the system:
sudo apt-get update
sudo apt-get upgrade
3. Enable the camera in raspi-config
sudo raspi-config
Enter the following interface:
Select the fifth one, press enter to enter the configuration
Next select the first Camera: enable the camera
Next we restart our Raspberry Pi.
4. Operate the camera
System commands to use the official Raspberry Pi camera
raspistill
: Command to get static pictures
The following picture is the parameter information about this command displayed by directly entering the command raspistill.
raspivid
: Commands for obtaining video information
Raspistill's related commands:
-
Take a picture after a delay of 1 second (time unit is millisecond) and name it image.jpg
raspistill -t 1000 -o image.jpg
-
Take a photo with a custom size and frame rate
raspistill -t 1000 -o image.jpg -w 640 -h 480 -q 5
-
Set embossed image effects
raspistill -t 1000 -o image.jpg -ifx emboss
-
Get a photo and send it to a standard output device (such as a monitor)
raspistill -t 1000
Raspivid related commands:
-
Take a video: the default video length is 5s, resolution is 1920*1080, frame rate: 17
raspivid -o myvideo.h264
-
Take a video: the resolution is 640*480 and the time is 10s
raspivid -o myvideo.h264 -t 10000 -w 640 -h 480
Note : raspivid outputs an uncompressed H.264 video stream. In order to let our ordinary video player play, we need to install the gpac package.
sudo apt-get install -y gpac
Then use the MP4Box application in the gpac package to convert the H.264 format video stream to 10 frames per second MP4 format video
MP4Box -fps 10 -add myvideo.h264 myvideo.mp4
Method 2: Other devices in the LAN access the camera through the web page
1. Connect the camera to our Raspberry Pi
2. Upgrading the system
To use the camera module, you must use a newer operating system, which can recognize that the camera module is connected. The easiest way is to download a Raspbian system image directly from the Raspberry Pi official website and install it on a brand new SD card.
No matter what version of the Raspbian system you are using, it is strongly recommended that you use the following command to update the system:
sudo apt-get update
sudo apt-get upgrade
3. Enable SSH and camera services in raspi-config
sudo raspi-config
Select the fifth one and press enter to enter the configuration.
First select the second SSH: enable SSH service (if SSH is already enabled, please ignore this step).
Next, select the first Camera: enable camera service.
Restart our Raspberry Pi.
sudo reboot
4. Operate the camera
Transfer the video captured by the Raspberry Pi to the web
4.1. Log in to the WinSCP software and upload the master.zip file to the pi directory of the Raspberry Pi (you can also use a U disk to copy the installation package directly to the pi directory of the Raspberry Pi).
For the method of transferring files between the Raspberry Pi and the win computer, please refer to the document at the end of the article: Environment preparation before the development of the Raspberry Pi camera.
4.2. Execute decompression instructions:
unzip master.zip
At this time, use the ls command to view, you can see the following uncompressed folder
4.3. To compile this project, you need to use cmake: perform the following installation and download.
(Apt-get belongs to network installation, so you need Raspberry Pi to ensure successful connection to the network)
sudo apt-get install cmake
Middle prompt: Just enter Y.
After completion as follows:
4.4. Before compiling, you also need to install the support library:
sudo apt-get install libjpeg8-dev
After completion as follows:
4.5. Start to compile,
enter the /home/pi/mjpg-streamer-master/mjpg-streamer-experimental/ folder and use the ls command to view the files in the folder
cd /home/pi/mjpg-streamer-master/mjpg-streamer-experimental/
Run the following command directly
sudo make clean all
After compiling, the following interface will appear
4.6. Then restart the system:
sudo reboot
4.7. Enter the system after restarting
Command line to enter the mjpg-streamer-experimental
directory
cd /home/pi/mjpg-streamer-master/mjpg-streamer-experimental/
启动树莓派摄像头
The instructions are:
./mjpg_streamer -i "./input_raspicam.so" -o "./output_http.so -w ./www"
The following prompt is successful:
Note : If you want to modify the resolution of the captured video, you need to run the following command:
./mjpg_streamer -i "./input_raspicam.so -x 320 -y 240 -fps 10" -o "./output_http.so -w ./www"
4.8. Test results
Open the browser on the PC. The PC must be in the same local area network as the Raspberry Pi. Enter the following URL to see the static screenshot:
http://树莓派IP:8080/?action=snapshot
Here is my address:http://192.168.1.200:8080/?action=snapshot
You can also use the following URL to 获取动态图像
:
http://树莓派IP:8080/javascript_simple.html
Here is the address of the Raspberry Pi:
http://192.168.1.200:8080/javascript_simple.html
PS: When using the Raspberry Pi camera, the dynamic image will be very stuck, about 1.4 frames per second, it is recommended to use static capture.
Note : After running the camera web service, the camera will be occupied, causing other camera commands to fail. Please terminate the process before running other camera commands.
View camera process number:
ps a
Kill the PID process number of the program
sudo kill -9 1033
Reference
- [1] Raspberry Pi wide-angle camera (data extraction password: 7koy)
- [2] Data download Extraction code: z0zk