1. USB camera test
OrangePi Zero 2 official user manual download link (3.13.6. USB camera test):
https://pan.baidu.com/s/1beIF5FMjWi2jw6nD83GYGg?pwd=himu
1) First insert the USB camera into the USB interface of the Orange Pi development board
2) Then through the lsmod command you can see that the kernel automatically loads the following modules
orangepi@orangepi:~$ lsmod
3) Through the v4l2-ctl command, you can see that the device node information of the USB camera is /dev/video0
orangepi@orangepi:~$ sudo apt update orangepi@orangepi:~$ sudo apt install -y v4l-utils orangepi@orangepi:~$ v4l2-ctl --list-devices
Note that the l in v4l2 is the lowercase letter l, not the number 1.
In addition, the serial number of the video is not necessarily all video0, please refer to what you actually see (the video serial number can be measured through the fourth step)
4) Use fswebcam to test the USB camera
a. Install fswebcam
orangepi@orangepi:~$ sudo apt-get install -y fswebcam
b. After installing fswebcam, you can use the following command to take pictures
a) The -d option is used to specify the device node of the USB camera
b) –no-banner is used to remove watermarks from photos
c) The -r option is used to specify the resolution of the photo
d) The -S option is used to skip the previous number of frames
e) ./image.jpg is used to set the name and path of the generated photo
orangepi@orangepi:~$ sudo fswebcam -d /dev/video0 \ --no-banner -r 1280x720 -S 5 ./image.jpg
Apparently my video serial number is /dev/video1
c. In the server version of Linux system, after taking the photo, you can use the scp command to transfer the photo to the Ubuntu PC for mirror viewing
scp image.jpg [email protected]:/home/test (modify the IP address and path according to the actual situation)
d. In the desktop version of Linux system, you can directly view the captured pictures through an HDMI display
You can also drag the .jpg file to the Windows desktop to view it
5) Use mjpg-streamer to test the USB camera
a. Download mjpg-streamer a (choose one of the methods below)
Github download address:
orangepi@orangepi:~$ git clone https://github.com/jacksonliam/mjpg-streamer
The mirror download address of Gitee is:
orangepi@orangepi:~$ git clone https://gitee.com/leeboby/mjpg-streamer
b. Install dependent software packages
Ubuntu system
orangepi@orangepi:~$ sudo apt-get install -y cmake libjpeg8-dev
Debian system
orangepi@orangepi:~$ sudo apt-get install -y cmake libjpeg62-turbo-dev
c. Compile and install mjpg-streamer
orangepi@orangepi:~$ cd mjpg-streamer/mjpg-streamer-experimental orangepi@orangepi:~/mjpg-streamer/mjpg-streamer-experimental$ make -j4 orangepi@orangepi:~/mjpg-streamer/mjpg-streamer-experimental$ sudo make install
d. Then enter the following command to start mjpg_streamer
Note that the serial number of the video is not necessarily video0, please refer to what you actually see.
In the current directory, you can see the start.sh script file, vi start.sh
Add -d /dev/video0 -u -f 30 to the location shown below
After saving, enter ./start.sh in the terminal
e. Then browse on Ubuntu PC or Windows PC or mobile phone on the same LAN as the development board
Enter [the IP address of the development board: 8080] into the device to see the video output by the camera (if the image is not clear, you can adjust the focus through the lens)
Take photos (You need to open another SSH window and run the ./start.sh command in the previous step)
orangepi@orangepizero2:~$ wget http://172.20.10.11:8080/?action=snapshot -O /tmp/garbage.jpg
6) Write a script to start automatically at boot
Under the root directory:
touch mjp.sh
vi mjp.sh
Paste the following content into the mjp.sh script
#!/bin/bash
cd /home/orangepi/mjpg-streamer/mjpg-streamer-experimental
./start.sh
chmod + x mjp.sh
Paste the following content in mjp.desktop
[Desktop Entry]
Name=mjp
Exec=/home/orangepi/mjp.sh
Type=Application
NoDisplay=true
After restarting, enter ps ax | grep mjp
Successfully started!