1 System Overview
The video image monitoring system consists of four parts: video image acquisition, video image processing, video image transmission and video image display. The video image acquisition part is composed of digital camera, USB channel and embedded processor. The video image processing is mainly video image compression, which is realized by algorithm. The video image transmission is mainly realized by video server. The video image display is mainly realized by browsing, saving and processing of video images on the remote host, and by application programs on the Linux host, On Windows host, it is realized by Java program on browser. The system principle block diagram is shown in Figure 1.
2 system hardware
The CPU processor uses Samsung s3c2440a, with the main frequency of 400 MHz and the maximum frequency of 533 MHz; 64 m SDRAM, 32-bit data bus, SDRAM clock frequency 100 MHz; 256 M / 1 GB NAND flash, power failure nonvolatile, 2 m norflash, power failure nonvolatile; Tongbao 3.5 true color LCD screen integrates 4-wire resistive touch screen, and the screen resolution can reach 1024 Ã 768 pixels; 100M Ethernet RJ-45 interface (using dm9000 network chip), serial port, USB host, USB slave type B interface, SD card storage interface, stereo audio output interface, microphone interface, JTAG interface, 4 user LEDs, 6 user buttons (with outlet seat), I2C bus AT24C08 chip, 20 pin camera interface; The camera uses Liangtian, which is compatible with the driver of sn9c20x series chips. The driver is integrated into the kernel of the system.
3 system software
3.1 Porting Linux kernel
The main purpose of porting the new kernel is to add corresponding driver support to LCD and camera. Open the kernel directory in Fedora 9 and use the default configuration file for configuration: add V4L support to the kernel and add 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 used in the design should be compiled by the compiler and downloaded to the development board for running. Cross compile the compiled application v4l2. C and download it to the board.
V4L (video for Linux) is an audio and video interface specification provided under Linux. These interfaces are used in the writing of all audio and video drivers.
V4L began to appear in the kernel version of 2.4.1. X. video for Linux 2 (v4l2) 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 v4l2 architecture. It realizes the opening of video equipment, image acquisition and processing, image display and so on by calling some IOCTL functions. Introduction to several main IOCTL functions:
1) IOCTL (FD, vidioc_s_fmt, & FMT): used to format images.
2) IOCTL (FD, vidioc_reqbufs, & req): apply for a buffer from memory, and the number of buffers applied is stored in count.
3) IOCTL (FD, vidioc_querybuf, & buf): query the related information of the allocated v4l2 video buffer, including the use 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 images, the corresponding video data is saved into the corresponding video buffer of the video input queue.
5) IOCTL (FD, vidioc_stream, & type): start the video acquisition command, and the application calls vidioc_ After streamon starts the video acquisition command, the video device driver starts to collect video data and save the collected video data to the video buffer of the video driver.
The flow chart of image acquisition and processing is shown in Figure 2.
3.3 network server
The system adopts boa server. Boa is a very small web server with only about 60 KB of executable code. As a single task web server, boa can only complete the user's requests in turn. Boa supports CGI and can fork a process for the CGI program to execute. Transplant the server on the board. The boa server starts up automatically by default and configures the conf file.
The server-side application uses servfox, servfox-r1_ 1_ 3. Unzip and modify the makefile file: CC = arm linux GCC, compile it to get the executable file servfox, 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 the Linux host without porting. Compile spcaview on Linux. Because this software package depends on libsdl, sdl-1.2.13 needs to be installed before installing spcaview. After installing spcaview software, there are three executable files in the source file directory. Spcacat: a simple image capture tool, which cannot be used for network monitoring client, spcaserv: streaming media server, spcaview: used to record data stream, It can also be used to play data, and can also be used as a network monitoring client.
4 monitoring process
4.1 monitoring on Linux operating system
Start the development board normally and run the server-side program servfox: servfox-d / dev / video0-s 320x240-w 7070.
Run on Linux:/ spcaview-g-s 320x240-w 10.1.91.230:7070
10.1.91.230 is the IP address of the server, so you can see the data collected by the USB camera on the PC.
The system is a fedora 9 Linux system installed in the virtual machine, which can smoothly observe the situation of the camera monitoring area.
4.2 monitoring on Windows operating system
For the client of network monitoring, the only tool that can cross platform is the browser. It can monitor through the browser. Whether it is Linux, windows, MacOS or other UNIX systems, as long as the browser with graphical interface can monitor the "control" range of the remote camera in the desktop environment.
The boa server is available on the mini2440. The HTTP Java applet folder in spcaview already contains a web page that can be monitored. Copy the folder to the main folder of the boa server / www.
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 so that the browser supports Java plug-ins.
After installing JRE, enter the server address in the address bar of the browser to realize remote monitoring.
4.3 remote capture
Submit a CGI through 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 server and CGI program can expand the capability of world WideWeb.
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.cgi named V4L, which is written by shell script. It is used to run the compiled image acquisition program on the board and return the captured pictures to the newly opened web page for viewing.
The shell script (V4L. CGI) is as follows:
#ï¼ / bin/sh
echo âContent-typeï¼ text/html; charset=gb2312â
âã ãã src=ââ1.jpgââã
The system adopts open source Linux system, which reduces the development cost, and can arbitrarily cut and formulate the kernel to facilitate transplantation. Compared with the traditional PC monitoring system, this system has the advantages of small volume, low cost and strong reliability. The system also has certain expansibility. Appropriate function expansion can be added to meet the higher requirements of users, such as adding control functions such as intrusion detection or alarm at the image acquisition end.