With the growth of population and the increasing traffic pressure, intelligent transportation system has become a hot topic in recent years. Vehicle flow detection is the basic part of intelligent transportation and plays an important role in the system. At present, there are many methods to detect traffic flow, such as electromagnetic induction device method and ultrasonic detection method of traffic flow information. In fact, the speed and type of moving vehicles are always changing, so there are many problems such as unstable reflected signals and large measurement errors. Compared with the above methods, the video-based traffic flow detection method has many advantages: 1, extracting reliable information from video images, completing road traffic monitoring, and improving the automation degree of roads and vehicles. 2. The camera installed in the traffic monitoring system is more economical and less destructive than other sensors. 3. Many cameras are installed in the actual road traffic system for road traffic monitoring, which can kill two birds with one stone.
The existing traditional video detection method is based on industrial computer, and its algorithm has matured and related products have been formed. However, it also has some disadvantages: 1, because the general CPU has no special hardware multiplier, it is difficult to realize real-time image processing. 2, it is a general industrial computer, running Windows system, and the cost is high. Always be concerned about whether the machine crashes, whether the system is infected with viruses, and how to control the patch upgrade of the system. Based on the above two points, this paper proposes an embedded image recognition scheme based on TMS320DM642 (hereinafter referred to as DM642), which solves the existing problems.
2. The principle and composition of traffic flow detection system.
2. 1 Working principle of traffic flow detection system
The traffic flow detection system consists of video acquisition, traffic flow digital video signal processing, traffic flow detection algorithm in different environments and traffic flow detection result output. The core chip of digital image acquisition is TVP5 150, which can convert analog video signals into digital video signals. DM642 runs an image algorithm to digitally process the collected images. The traffic flow digital video detection algorithm mainly uses the improved frame difference method for motion detection during the day and the lamp detection method at night. According to the lane, the collected expressway image is divided into four parts, each part corresponds to a lane. Virtual coils (referred to as rectangular detection areas in the image, collectively referred to as virtual coils) are set in each channel. When the car runs over the virtual coil, the pixel value in the virtual coil will change. According to this change, the I/O port is controlled to generate corresponding pulses for each lane, and then the pulses are sent to the expressway traffic signal to control the traffic lights, thus achieving the purpose of intelligent transportation. Meanwhile, the traffic flow information can be transmitted to the monitoring center through the network.
2.2 hardware of traffic flow detection system
DM642 is a digital signal processing chip specially designed by Texas Instruments for multi-channel video input and output. Its powerful computing function is based on the second-generation high-performance very long instruction word structure, and it can execute eight instructions in parallel, which makes the chip very suitable for digital image processing. Considering the requirements of practical work and the stability of the system, the main frequency of DM642 is set to 600MHz. According to the actual application environment and the needs of embedded system, the system not only expands the necessary storage part and video acquisition and playback part, but also mainly expands the functions of multi-channel digital I/O, asynchronous serial port and network interface, which facilitates the communication between the system and the outside world. The specific hardware objects are shown in figure 1. The explanation is as follows: 1, external SDRAM with a capacity of 4M×64 bits; 2. Expand Flash with a capacity of 4M×8 bits; 3. 2 channels of PAL/NTSC standard analog video input (CVBS or S terminal) and 1 channel PAL/NTSC standard analog video output; 4. Expand 8 digital I/O ports through CPLD to output the information of traffic flow in the driveway; 5. Two UART interfaces, which can be configured with standard RS232/RS422/RS485 interfaces; 6, real-time clock RTC+ watchdog circuit; 7.10m/100mbase-tx standard Ethernet interface.
The system composition is shown in Figure 2. In the figure, TMS320DM642 extends the external memory part through the 64-bit wide EMIF bus, including 32 MB synchronous DRAM, which is used to store user codes and image data during actual operation. 4M FLASH is used to store bootloader and user's applications. At startup, the code and data in FLASH are loaded into SDRAM, and the configuration parameters of the user's virtual coil can also be stored in Flash. The data width of SDRAM is 64 bits, and the data width of FLASH is 8 bits, corresponding to CE0 and CE 1 space of TMS320DM642 respectively. Similarly, UART and CPLD are also connected to DM642 through EMIF bus. UART is used to expand serial port, and can be used to expand RS232 interface in this system. CPLD is used to realize the binding logic between FLASH and UART, and to expand the general digital I/O. For the convenience of software implementation, these two parts are also connected to the CE 1 space of DM642, and their internal registers are part of the CE 1 storage space.
2.3 Video acquisition and output part
In order to count the traffic information at intersections, this system designs two analog video inputs. The system converts the analog video signal collected by the camera from TVP 5/KOOC-0/50 into digital video stream according to ITU-RBT.656 standard, and sends the embedded synchronization signal to VP/KOOC-0/and VP2 of DM642. The line synchronization and field synchronization signals of the image are embedded in the EAV and SAV time base signals in the video data stream, and the video port only needs the video sampling clock and the sampling enable signal. DM642 can realize the continuous acquisition of three digital video images through FIFO. While processing one image, the other two buffers can also realize the cyclic acquisition of images, which solves the contradiction between constant-speed video acquisition and variable-speed image processing. This system extends a video output for local playback, and this part of the function can be omitted after system debugging. The video output is realized by SAA7 12 1 chip of Philips. SAA7 12 1 converts the digital video signal from VP0 port of DM642 into PAL(50Hz) or NTSC(60Hz) analog signal, and sends it to the external video port for output.
3. Software part
3. 1 traffic statistics algorithm
Because the road illumination intensity changes greatly during the day and night, higher requirements are put forward for the adaptability of the algorithm. In order to get all-day traffic flow information, the whole algorithm treats day and night separately. The program automatically switches between the two algorithms according to the different lighting conditions at that time, thus ensuring the running environment of the whole algorithm.
Select 3. 1. 1 virtual coil;
The choice of virtual coil is related to the accuracy and speed of the detection algorithm, and is influenced by the installation height and inclination of the camera and the depth of field of the camera. In general, the virtual coil is close to the bottom of the image, and the distance between vehicles is large, which is convenient for detection. The larger the virtual coil, the higher the relative detection accuracy, and the longer the corresponding algorithm takes. Because the whole system has to adapt to all kinds of intersections and roads, the choice of virtual coil is given to users. We developed PC software with VC6.0, and users used this software to set the size and position of virtual coil in each channel through serial port.
3. 1.2 Time interval between adjacent detection frames:
Because the whole system has to communicate with signals, it is required that the total time for us to process images on each road should not exceed 0.25 seconds. Here, choose a frame interval of 0. 125 seconds.
3. 1.3 Traffic flow detection algorithm www.51kaifa.com/html/jswz.
Because the daytime traffic flow detection algorithm is very mature on the industrial computer, I won't go into details here. The visibility of roads at night is relatively low, and the algorithm is mainly to identify car lights. At night, the brightness of the headlights is very strong. As long as the headlights can be detected correctly, the vehicle can be detected. The interference of the algorithm comes from the reflection of the road surface on the light emitted by the headlights. After the simulation test with Matlab, it is found that the bright spot in the binarized image is basically the shape of the lamp, while the reflective area of the road diverges forward. Accordingly, by detecting the shape characteristics of the bright spots on the window, the reflective areas of the car lights and the road surface can be identified. Otsu method is used to select the threshold of image binarization. Compared with the empirical method, Otsu method obtains the threshold by calculating the variance, which has strong adaptability to the environment, but it also increases the time and space complexity of the algorithm. Image denoising uses 3 * 3 median filter, and we improve its fast algorithm, and only for virtual coils.
The original gray image of the road surface is shown in Figure 3, and Figure 4 is a binary image. The rectangular area in the figure is a virtual coil with two white areas in it. According to the maximum aspect ratio (in pixels) of the white area, it is judged whether it is a car light. The length of the white area corresponding to the lamp is usually less than or equal to the width, as shown in fig. 5. The white area corresponding to road reflection is longer than the width. As shown in Figure 8, the white area in the virtual coil is road reflection.
3.2 System software framework based on DSP/BIOS
The system software development environment is CCS, using the DSP/BIOS kernel provided by TI and the RF5 software reference framework advocated by TI. Input, processing, output and other threads are configured by DSP/BIOS, and the synchronization between these threads is carried out by semaphore. Using DSP/BIOS kernel, DSP/BIOS configuration is simple and easy to change, which has many advantages over traditional methods. Using DSP software architecture RF5(ReferenceFramework5) greatly shortens the development time, and at the same time ensures the portability and robustness of the code to the maximum extent. The software architecture consists of CSL (Chip Support Library), DSP/BIOS and driver layer, signal processing library layer and algorithm standard layer from bottom to top. These three layers constitute RF5, and the top layer is the user application layer. It is convenient for users to modify the maintenance code, and only the upper layer needs to modify it.
The input driver adopts FVID class driver provided by TI company. The driver realizes the configuration of the DM642 video port by IIC module and the configuration of the A/D conversion chip TVP5 150 through the configuration parameters of the structure, so that TVP5 150 can output the digital video stream in PAL format, and write the collected images into the designated storage area through the FIFO of the video port. When the image acquisition is completed, a message is sent to the processing module through the semaphore, and the message structure stores the first address of the storage space where the image data is located. The input module waits for a reply from the output module to continue processing the image of the next frame. The processing module is responsible for executing the statistical algorithm of traffic flow. The image data address is extracted from the message structure sent by the input module for image algorithm processing, and the operation result is output through the extended I/O port of CPLD, and the monitoring information of traffic flow is transmitted to the signal machine.
3.3 code optimization
The program is mainly written in C language, and some core codes are compiled and optimized to meet the real-time requirements. C language program optimization directly affects the efficiency of the program. The method of exchanging space for time is widely used in the program to improve the running efficiency of the code. There are many ways to optimize code. The main methods are 1, compiler optimization, and different compilation optimization options are selected during compilation, such as-pm–OE option. 2. Optimize the code written in C language and add instruction information. Commonly used indicative information such as #PragmaMUST_ITERATE, etc. 3. Write a linear assembler to improve the running speed of the program. 4. Write assembler to realize software pipelining. Many technical means can be used in the pipeline, such as dependency graph, iteration interval schedule and so on. It is described in the technical documents provided by TI and will not be described here.
4. Experimental results and analysis
In order to verify the reliability of the traffic flow detection system, the algorithm is transplanted into the detection system, and the actual detection experiments are carried out on several expressway overpasses with tripods installed with cameras. Because there are a certain number of pedestrians on the overpass, the overpass shakes slightly, which has a certain impact on the stability of the camera. In addition, the phenomenon of vehicle riding causes some errors in the detection results, but the detection effect is still good. See table 1 for a set of tests. In the natural environment, the size of the collected image is 720×576. Among them, the measurement time during the day is 3: 27 pm and the time at night is 6: 50 pm. The weather is fine, and the test site is two lanes of Xueyuan Road, Haidian District, Beijing. The size of CCD is 1/3 inches. The focal length of the lens is 3.5-8mm, and the maximum aperture ratio 1: 1.4.
Table 1 Traffic Flow Test Results
From the traffic flow detection results of table 1, it can be seen that the video detection results during the day are slightly better, and the appearance and brightness of the lights at night are quite different, with certain errors, but the recognition accuracy of the system is above 80%. Experiments show that this method has high detection accuracy, low implementation cost and reliable system operation.
The author's innovation: 1. In the past, the hardware of traffic flow detection based on vision was industrial computer. This paper puts forward a new solution and introduces an embedded traffic flow detection system based on TMS320DM642. Experiments show that the system is small, low cost, stable and reliable. 2. This paper introduces the detection algorithm of traffic flow at night. The algorithm has low complexity and fast processing speed, which can not only ensure the real-time detection of traffic flow, but also meet the accuracy requirements.
For more information about project/service/procurement bidding, and to improve the winning rate, please click on the bottom of official website Customer Service for free consultation:/#/? source=bdzd