Security monitoring project—mjpeg-streamer video image display (real-time video streaming implementation)

Article directory

  • Preface
  • 1. Hardware preparation and hardware equipment inquiry
  • 2. Transplantation of jpeg library
  • 2.1 Source code download
  • 2.2 Transplantation of jpeg library
  • 3. Transplantation of mjpeg-stream
  • 4. Test results
  • Summarize

Foreword

Continuing from the previous issue, we have implemented many functions, but the real-time upload of video streams has not yet been implemented. This issue mainly shares how to implement the real-time display of the video collected by the camera on the web page, thereby realizing the monitoring function in security. This After the function is completed, there is only one functional requirement left, which is the GPRS module, which can realize the function of danger alarm and can also call the alarm; only when these functions are fully realized can we complete this project! Let’s take a look at how the video stream information is uploaded to the web page step by step?

1. Hardware preparation and hardware device query

First of all, you must prepare a camera, hahaha, no! Next, I will teach you how to check the basic information of the camera. If you are under Windows, you only need to plug the USB camera into the USB interface of the computer. The information displayed is as follows:

You can check the property information of the camera here, mainly to check the hardware ID, including VID and PID, and you can check whether the camera is supported on the UVC official website;
If you plug it directly into the A9 board, then you have to check whether the board’s kernel supports it. First, we must make sure that USB must be supported, and then check whether there is the device node in the device node directory;
When the camera is plugged in, the following information is displayed:


And you can also see that the ID number here is consistent with the ID number under Windows!

Then view the device node:

Hahaha, do you still want to see what happens when you pull it out, to meet your needs:

If the above operations are normal for everyone, it means that our hardware environment has been set up. The next thing we need to do is to implement the software to upload the video stream;
Everyone must pay attention to that the kernel of the board must support the USB interface, otherwise the information will not be displayed when we plug in the camera. Configure the kernel first, compile the kernel and put it in the tftp directory, and then insert it after the board is started;

2. Transplantation of jpeg library

It’s time to transplant again. This project is now the third transplant. From the first two transplants, we basically know that transplantation is actually taking the ready-made interface standard library and adding it to your own project framework. , make reasonable use;

2.1 Source code download

To download the source code, you can click on the following website: http://sourceforge.net/apps/mediawiki/mjpg-streamer/index.php?title=Main_Page

2.2 Transplantation of jpeg library

Still download it first, http://www.ijg.org/files/jpegsrc.v8b.tar.gz
Then decompress, the command is

tar -xvf jpegsrc.v8b.tar.gz

Next, configure the source code. It should be noted that ./configure here needs to be followed by parameters:

cd jpeg-8b
./configure --prefix=Specify a directory yourself --host=arm-none-linux-gnueabi
Note: --prefix indicates the directory where the final generated libraries and header files are stored. You can just specify an existing path yourself.
It will be used later when compiling mjpeg-streamer. The absolute path must be used here. --host=arm-none-linux-gnueabi --host indicates the running platform of the generated library.
Note that there are two -, and - cannot be added at the end. There is a line of commands after ./configure

Absolute paths are mentioned here. Generally, we use absolute paths during the transplantation process to ensure that there will be no errors; because it is transplantation after all, if it is set to a relative path, the transplanted directory has changed, which means that the relative path The relative baseline has changed; remember the transplantation of the boa server? If it is not transplanted to the root directory, but to a certain path, then the boa.conf file must be set to an absolute path when configuring it; this is Advantages of setting an absolute path!

Next, compile and make will do;
Finally copy the library file to the file system:

sudo cp /home/fengjunhui/securitymonitor/mjpeg streamer/video/jpegarm/lib/* /home/fengjunhui/source/rootfs/lib

3. Transplantation of mjpeg-stream

First download the source code; svn cohttps://mjpg-streamer.svn.sourceforge.NET/svnroot/mjpg-streamermjpg-streamer
After downloading the source code, unzip it:

The functions of these directory files are as follows:

doc mjpg-streamer udp_client
mjpeg-client mjpg-streamer-experimental uvc-streamer
mjpg-streamer: The directory provides execution programs and various input and output device components
uvc-streamer: The executable directory of uvc-streamer is provided under the directory
mjpeg-client: : There are clients for linux and windows respectively.
  1. Enter the mjpg-stream directory
  2. Modify source code
vi ./plugins/input_uvc/Makefile
CFLAGS += -O1 -DLINUX -D_GNU_SOURCE -Wall -shared -fPIC
change into
CFLAGS + = -O1 -DLINUX -D_GNU_SOURCE -Wall -shared -fPIC -I /home/secure/mjpeg-streamer/video/jpegarm/include (You can type this command according to your own path)

Will (CC)(CFLAGS) -o @inputuvc.cv4l2uvc.lojpegutils.lodynctrl.lo(LFLAGS)
change into
(CC)(CFLAGS) -L /home/fengjunhui/securitymonitor/mjpeg-streamer/video/jpegarm/lib –o @inputuvc.cv4l2uvc.lojpegutils.lodynctrl.lo(LFLAGS)
  1. In the mjpg-streamer-code-182/mjpg-streamer directory
Compile: make CC=arm-linux-gcc
Generated in mjpg-streamer
input*.so output*.so and mjpg_streamr executables
piece of cake:
make CC=arm-linux-gcc
make: svnversion: Command not found
  Solution: sudo apt-get install subversion
  Before installation, update the source and dependencies of the software package:
  Sudo apt-get update updates software sources
  Sudo apt-get -f install update dependencies
Compile again:
make
Nothing to be done for `all'.
First
make clean,
after that
make CC=arm-linux-gcc
View the generated libraries and executable files:
fengjunhui@ubuntu:~/securitymonitor/mjpeg-streamer/mjpg-streamer-code-182/mjpg-streamer$ ls *.so
input_file.so input_uvc.so output_http.so
input_testpicture.so output_file.so output_udp.so
ls mjpg_streamer
mjpg_streamer
  1. Ported to development board
mkdir /home/fengjunhui/source/rootfs/mjpg-streamer (your root file system directory)
cp *.so /home/fengjunhui/source/rootfs/mjpg-streamer -arf
cp mjpg_streamer /home/fengjunhui/source/rootfs/mjpg-streamer -arf

Copy start.sh and the directory www in the source directory to the ~/source/rootfs/mjpg-streamer/ directory, and then you can test it.
sudo cp start.sh www/ ~/source/rootfs/mjpg-streamer/ -arf

4. Test results

First open the development board and run the kernel. The kernel must support USB and also has certain requirements for the camera. I need to tell you carefully here. The device number mentioned above must be at http://www.ideasonboard.org/uvc/ In the website, but after my actual testing, I found that if there are no problems in other transplantation processes, and there is no problem in running the start.sh script, or there are the following problems:

ERROR opening V4L interface: No such file or directory
 Init v4L2 failed !! exit fatal
 i: init_VideoIn failed
MJPG-streamer [1296]: init_VideoIn failed

Then everyone can open the start.sh file and make changes in the following places:
Please add a picture description
Then run the BOA server on the A9 development board, directly enter the video stream folder and run the start.sh script, then you can observe the following phenomena:
Please add image description

The above two pictures are screenshots of the video displayed on the webpage at noon. The video is still relatively blurry, but in actual testing, it will be clearer if you get closer. The camera is still relatively cheap!

Summary

The sharing in this issue ends here. If you follow these processes in this issue step by step, you will find that there are still many problems encountered, but problems will always exist. Sometimes the hardware equipment does not match. Sometimes the software does not support it, so selection is a very important process; I hope you can still find a suitable selection according to your own project; Finally, if you have gained something, you can like it and save it, you guys The recognition is the motivation for my creation, let’s work together!