Design and Implementation of Video Surveillance System Based on ARM
“An implementation scheme of video surveillance based on ARM embedded development platform is proposed. Build video image capture and Display under Linux through V4L2, and then use servfox and spcaview to build video server, the system can perform video monitoring and image capture through windows or web pages under Linux and Windows operating systems. The test shows that the monitoring image of the system is clear, and has the advantages of small size, low cost and strong reliability.
An implementation scheme of video surveillance based on ARM embedded development platform is proposed. Build video image capture and display under Linux through V4L2, and then use servfox and spcaview to build video server, the system can perform video monitoring and image capture through windows or web pages under Linux and Windows operating systems. The test shows that the monitoring image of the system is clear, and has the advantages of small size, low cost and strong reliability.
At present, embedded systems are more and more widely used in video surveillance. With the powerful functions of the network, video surveillance focuses more on network monitoring solutions, requiring small size, remote control, low cost, low power consumption, and user-friendly operation interface. Based on the embedded Linux platform, the system uses USB camera to collect video images, and transmits video images through video image compression and combined with the network, making remote monitoring possible.
1 System overview
The video image monitoring system consists of 4 parts, namely video image acquisition, video image processing, video image transmission, and video image display. The video image acquisition part is composed of a digital camera, a USB channel and an embedded processor. The video image processing is mainly video image compression, which is realized by algorithms. The video image transmission is mainly realized by the video server, and the video image display is mainly on the remote host. The browsing, saving and processing of video images are realized by the application program on the Linux host, and the JAVA program on the browser is realized on the Windows host. The principle block diagram of the system is shown in Figure 1.
Figure 1 System block diagram
2 System Hardware
The CPU processor uses Samsung S3C2440A, the main frequency is 400 MHz, the highest is 533 MHz; 64 M SDRAM, 32 bit data bus, SDRAM clock frequency 100 MHz; 256 M/1 GB Nand Flash, non-volatile when power off, 2 M NorFlash, off Electrical non-volatile; Topo 3.5 true color LCD, the screen integrates 4-wire resistive touch screen, the screen resolution can reach 1024 × 768 pixels; 100 M Ethernet RJ-45 interface (using DM9000 network chip), serial port, USB Host, USB Slave B-type interface, SD card storage interface, stereo audio output interface, microphone interface, JTAG interface, 4 USER Leds, 6 USER buttONs (with pinout), I2C bus AT24C08 chip, 20 pin camera interface; camera Using Liangtian, it is compatible with the driver of SN9C20X series chips, which is integrated in the kernel of this system.
3 System software
3.1 Porting of Linux Kernel
The main purpose of transplanting the new kernel is to add corresponding driver support for LCD and camera. Open the kernel directory in Fedora 9 and use the default configuration file for configuration: add V4L support in the kernel, and add the universal USB camera driver GSPCA.
3.2 Image acquisition program based on V4L2
The cross-compilation tool used by the system is arm-linux-gcc-4.3.2. The applications designed and used must be compiled and downloaded to the development board to run. The compiled application V4L2. c Download to the board after cross-compiling.
V4L (Video for Linux) is an audio and video interface specification provided under Linux. All audio and video drivers must use these interfaces.
V4L appeared from the 2.4.1.x kernel version. The Video for Linux2 (V4L2 for short) designed to be used is an improved version of V4L, which fixes some bugs in the first generation.
The designed image acquisition and processing program is mainly based on the V4L2 architecture, and realizes the opening of the video device, the acquisition and processing of the image, and the display of the image by calling some ioctl functions. A brief introduction to several main ioctl functions:
1) ioctl(fd, VIDIOC_S_FMT, &fmt): used to set the format of the image.
2) ioctl (fd, VIDIOC_REQBUFS, &req): apply for buffers from memory, and the number of buffers applied for is stored in count.
3) ioctl (fd, VIDIOC_QUERYBUF, &buf): Query the information about the allocated V4L2 video buffer, including the usage status of the video buffer, the offset address in the kernel space, the buffer length, etc.
4) ioctl (fd, VIDIOC_QBUF, &buf): put an empty video buffer into the video buffer input queue. After the function is executed successfully, the video buffer of the instruction enters the video input queue. When the video device is started to capture an image, the corresponding The video data is saved to the corresponding video buffer of the video input queue.
5) ioctl (fd, VIDIOC_STREAMON, &type): start the video capture command, after the application calls VIDIOC_STREAMON to start the video capture command, the video device driver starts to capture video data, and saves the captured video data to the video buffer of the video driver middle.
The flow chart of image acquisition and processing is shown in Figure 2.
Figure 2 Flow chart of image acquisition and processing
3.3 Web server
The system adopts Boa server. Boa is a very small Web server, its executable code is only about 60 kB. As a single-task Web server, Boa can only complete the user’s request in sequence. Boa supports CGI and can fork a process for the CGI program to execute. The server is transplanted on the board, the Boa server runs automatically when it is powered on by default, and configures the conf file.
The server-side application uses servfox, servfox-R1_1_3 to decompress and modify the Makefile: CC=arm-linux-gcc. After compiling, the executable file servfox is obtained, download it to the board, and enter the command chmod +x servfox to add executable attributes to it.
The client program uses spcawiew, which is used to monitor the server on a Linux host without porting. Compile spcaview on Linux. Since this package depends on libsdl, you need to install SDL-1.2.13 before installing spcaview. After installing spcaview software, there are 3 executable files in the source file directory, spcacat: for simple pictures Crawl tool, cannot be used for network monitoring client, Spcaserv: streaming media server, Spcaview: used to record data stream, can also be used to play data, can also be used as network monitoring client.
4 Monitoring process
4.1 Monitoring on Linux OS
Start and run the development board normally, and run the server-side program servfox: servfox-d /dev/video0-s 320×240-w 7070.
Running on Linux: . /spcaview-gs 320×240-w 10.1.91.230:7070
10.1.91.230 is the IP address of the server, so that the data collected by the USB camera can be seen on the PC.
The system is a fedora 9 linux system installed in a virtual machine, which can smoothly observe the situation of the camera monitoring area.
4.2 Monitoring on Windows OS
For network monitoring clients, the only tools that can cross-platform are browsers, which can be monitored through browsers. Whether it is Linux, Windows, MacOS or other UNIX systems, as long as there is a browser with a graphical interface, it can be used in a desktop environment. Monitor the range “controlled” by the remote camera.
There is already a Boa server available on Mini2440. The http-java-applet folder in Spcaview already contains a web page that can be monitored and used. Copy this folder to the main folder /www of the Boa server.
Since the WEB main page (Index.html) contained in the http-java-applet folder contains JAVA controls, first install the JAVA environment on the host, and let the browser support the JAVA plug-in.
After installing the JRE, enter the server address in the address bar of the browser to realize remote monitoring.
4.3 Remote Capture
Submit the CGI via a web form to run the application.
The Common Gateway Interface (CGI) specification allows Web servers to execute other programs and store their output in text, graphics, and audio sent to Web browsers. The combination of servers and CGI programs can expand the capabilities of the World Wide Web.
CGI programs can be written in popular programming languages such as C, Perl, or UNIX shell scripts.
In this design, the button shoot the picture on the web page submits a CGI file v4l named V4L. cgi, which is written in shell script, is used to run the compiled image acquisition program on the board and return the captured image to the newly opened web page for viewing.
Shell script (v4l.cgi) content is as follows:
echo “Content-type: text/html; charset=gb2312”