Welcome to USB Microphone Camera repository
1.2 Camera webpage access tutorial
Part 1--Connect camera into Raspberry Pi board
1. User must ensure that the camera is properly inserted into the Raspberry Pi board before supplying power to the Raspberry Pi board.
2. There are two kinds of commands that the Raspberry Pi terminal can use to detect external camera devices: "lsusb" and "ls/dev/video*". (In some cases, you may be able to use the camera without seeing video0 service)
After we input following command, we can detect camera service.
As shown below.
Part 2 -- Upgrading the system
You must to install a new operating system before use camera, which can can identify if the camera module is connected. The simplest method is download Raspbain system from Raspberry Pi website, and install it to new SD card.
Regardless of the version of the Raspbian system you are using, I recommend that you update the system with the following command:
sudo apt-get update
sudo apt-get upgrade
Part 3 -- Open the camera service of Raspberry Pi
1. If you use Raspberry Pi official system image, you need to open the camera service. Input sudo raspi-config command to enter following interface.
2. Choose fifth option [Interfacing Options] and click [Enter] key to enter next interface.
3. ChoOse [Camera] to enable camera.
4. Finally, we need to reboot Raspberry Pi.
Input sudo reboot command.
Part 4 -- Using camera
1.You can transfer the video which captured by the Raspberry Pi to the web page.
You need to log in to the WinSCP software and transfer the master.zip file to the pi directory of the Raspberry Pi.
2.You should input: #unzip master.zip
(This command to unzip mater.zip)
After complete unzip, input ls, you can see migp-streamer-master folder. As shown in the figure below.
3.Compiling this project requires cmake: perform the following command to install download.
(apt-get is a networked installation, so you need make Raspberry Pi successfully connect to the network.)
You should input:
#sudo apt-get install cmake
A prompt will appear when installing, you need to enter Y.
After completion, As shown in the figure below.

4. You need to install library
You should input:
#sudo apt-get install libjpeg8-dev
After completion, As shown in the figure below.

5.Compiling
Note: we possess two formats of camera (JPEG/YUYV )
2-degree-of-freedom camera: YUYV/JPEG
If we want to change to the YUYV format, we need to modify the relevant files and compile:
Specific steps as shown below:
You should enter the input_uvc.c file in the /home/pi/mjpg-streamer-master/mjpg-streamer-experimental/plugins/input_uvc/ directory.
You should input:
cd /home/pi/mjpg-streamer-master/mjpg-streamer-experimental/plugins/input_uvc/
You should input:
ls
Just modify the format of 135 lines to V4L2_PIX_FMT_YUYV (The default is format=V4L2_PIX_FMT_MJPEG)
You should input command
nano -c input_uvc.c
If you want to change the resolution and frame rate of the USB camera, you can change it here.
After the modification is completed, press ctrl+X, press Y to save, and then press the Enter key.
Then return to the mjpg-streamer-experimental folder to compile
Then return to mjpg-streamer-experimental:
cd /home/pi/mjpg-streamer-master/mjpg-streamer-experimental
And input make clean all to complete the compilation.
You can wait for the compilation to complete, you can see the interface shown below.
6.Restart system
You need to input: sudo reboot to reboot system
Plug in the camera and restart the system.
7. After rebooting, enter the system.
You need to enter the mjpg-streamer-experimental directory by command. And use the following command to start the normal USB camera (for 2-DOF cameras):
#./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -w ./www"
Some cameras will report an error when executing this command. If they do not return to the command prompt and display "Starting Camera", it means success.
As shown in the figure below, the camera is successfully turned on:
8. Testing
View the image, open the browser on the PC side, you need to enter the following URL to see the static screenshot:
http://<RaspberryPi IP>:8080/?action=snapshot
My URL is:http://192.168.0.179:8080/?action=snapshot
As shown below.
You should input the following URL to see the dynamic image:
http://<RaspberryPi IP>:8080/javascript_simple.html
My URL is:http://192.168.1.179:8080/javascript_simple.html
Note: After running the camera web page service, this process will occupy the camera, causing other camera commands to fail to run. Please end the process before running other camera commands.
View camera process number:
ps a
Input following command to kill PID
sudo kill -9 1118
Different Raspberry Pi process numbers are different. Please refer to the process shown in your own system.