introduction
Digital video systems have been widely used in the fields of intelligent transportation, image recognition, and security monitoring. As an important part of digital video systems, motion target detection is the basis for subsequent applications such as target recognition and target tracking. This paper proposes a real-time motion target detection system solution based on DM642 . Relying on the powerful computing power of the DM642 chip, the data throughput and real-time performance of target detection are guaranteed. This solution is reasonably designed, highly scalable, and has practical application value.
1 Moving Target Detection Algorithm
There are many algorithms for realizing moving target detection, generally including optical flow method, background difference method, adjacent frame difference method, etc. The optical flow method realizes motion detection by solving the optical flow equation. Its algorithm is complex, the amount of calculation is large, and it is difficult to meet the real-time requirements; while the adjacent frame difference method has a simple algorithm and a small amount of calculation, but its anti-interference ability is very poor, and the detection effect is not ideal; while the background difference method has a simple algorithm, a small amount of calculation, and a strong anti-interference ability. Therefore, this paper adopts this method to realize moving target detection. The specific steps are as follows: first, obtain the digital image for preprocessing, then use the background difference method to realize motion detection, and then use the Otsu method to perform adaptive threshold segmentation on the obtained image, and finally obtain the detected moving target through filtering. Figure 1 is the flow chart of moving target detection in this paper.
1.1 Image acquisition and preprocessing
Configure the system's video input and video output FVID drivers in CCS, obtain the digital YUV video stream corresponding to the video stream captured by the camera from the VPORT port of TMS320DM642, and store it in the cache IMG_CURRENT, IMG_PREVIOUS, and IMG_BACKGROUND. IMG CURRENT stores the current image, IMG_PREVIOUS stores the last stored image, and IMG BACKGROUND stores the image as the background image. The image resolution is 720×576, and each component is 8 bits. Since the acquired video image inevitably contains noise, these noises must be suppressed. This article uses Gaussian filtering to perform Gaussian filtering on the obtained YUV video information. The filtered image is saved in the IMG_CURRENT cache.
1.2 Background subtraction processing
After the video image is preprocessed, the background difference method is used to detect the moving image. The steps are as follows:
(1) Get a frame of image as the initial background Bg(x,y,tk);
(2) Get the next image again after 4 frames, and use it as the current image Curr(x,y,tk);
(3) According to the background difference method, the difference image Sub(x,y,tk)=|Curr(x,y,tk,)-Bg(x,y,tk) is obtained;
(4) Count all sums
(5) Repeat steps (2) to (3) above.
In the above background difference method, a frame of image at the time of power-on can be randomly obtained as the initial background image. In order to make the difference between images more obvious, the next image is obtained as the current image at intervals of 4 frames, and background difference is performed to obtain the difference image. The sum of the grayscale of the difference image is compared with the set threshold FF to determine whether the current background needs to be updated. The threshold FF is an empirical value, and this paper takes 20000. The coefficient a in the background update formula reflects the speed of background update, and its value range is between [0, 1]. The larger a is, the faster the background update speed is, and the smaller a is, the slower the background update speed is.
1.3 Binarization of difference image
The difference image is binarized according to the following formula:
The threshold TR in the formula is obtained by Otsu method. In actual testing, it is found that when the threshold TR obtained by Otsu method is directly used to process the differential image binarization, if there is no object movement, the binarized image is a noisy binary image. It is difficult to completely eliminate the binary noise image directly processed in the subsequent morphological filtering. By analyzing the histogram of the differential image, it is found that when there is no object movement, the histogram of the differential image is mainly distributed between 0 and 10, and the threshold obtained by Otsu method is between 1 and 6; when there is object movement, the histogram of the differential image is distributed between 0 and 255, and the threshold obtained by Otsu method is above 20.
Based on the above analysis, this paper adopts an improved method. If the threshold obtained by the Otsu method is less than 10, it means that there is no object movement, otherwise it means that there is object movement. When the threshold is less than 10, the binarization is performed according to the following formula:
f(x,y,tk)=0 when TR<10
That is, when there is no object movement, the obtained binary image should be completely black, so that the subsequent morphological processing only needs to process the binary image when there is object movement. Figure 2 shows the results of direct binarization when there is no object movement and binarization using the improved method. Among them, a) is the result of the difference image when there is no object movement when the threshold is directly obtained by Otsu's method. It can be seen that the image is full of noise; b) is the result of the difference image segmentation when there is no object movement after judging the threshold obtained by Otsu's method. It can be seen that the image is completely black at this time, that is, there is no moving object, which is consistent with the actual situation and simplifies the subsequent morphological processing.
2 TMS320DM642 Implementation of Algorithm
2.1 Hardware Platform
The hardware platform uses TMS320DM642 as the CPU, and the main frequency of the chip is 600MHz. The video codec chip uses SAA7115H and SAA7105H. In addition, two SDRAM chips (4M×64bit) are used as storage media for temporary image storage, and a FLASH is used to achieve self-starting. The hardware platform block diagram is shown in Figure 3.
This hardware platform obtains analog images from the camera, and obtains standard YUV4:2:2 digital image code stream in BT.656 format through SAA7115 decoding, and then temporarily stores the code stream in SDRAM through the EDMA function of DM642, and then processes it with the algorithm, and then sends it to SAA7105 for decoding through the EDMA function of DM642, and outputs it through the CVBS pin, so that the processing results of the system can be displayed in real time on the monitor.
2.2 DM642 Implementation of the Algorithm
The system software is completed in the integrated development environment CCS provided by TI. The programming is implemented in C language and assembly language. The software adopts the RF-5 architecture recommended by TI and uses three threads tsk_inpu-t, tsk_process, and tsk_output.
The execution flow of the software is as follows:
(1) Initialization of TMS320DM642. Including initializing BIOS, CSL, and setting CACKE;
(2) Initialize the RF-5 module. Use CHAN_init, ICC_init, and SCOM_init to initialize the CHAN module, ICC module, and SCOM module respectively;
(3) DSP/BIOS schedules the execution of three threads, tsk_input, tsk_process, and tsk_output, according to the scheduling rules of the operating system. Among them, tsk_inpufi calls the FVID driver by calling the FVID_create, FVID_control, and FVID_aUoc functions in sequence, opens the input channel, and obtains the YUV422 digital video code stream in BT.656 format obtained by SAA7ll5. tsk_process is responsible for processing the digital image obtained by the tsk_input thread using the motion image detection algorithm, which calls the algorithm function described in the previous section. After processing, the moving target is segmented. tsk-output is responsible for calling the FVID_create, FVID_control, and FVID_alloc functions, opening the output channel to output the segmented digital video stream through SAA7105 and display it on the monitor. These three threads run in parallel under the scheduling of DSP/BIOS, and data exchange between the three threads is realized through the SCOM module.
In the above program, the core program is the tsk_process thread, and its main code is as follows:
While(1)
{……
Background(): //Get the background and update it according to the conditions
Diff_picture(): //Difference between background and current image
Otsu_binary(): //Threshold segmentation and binarization using the improved Otsu method
Filter_obitct(): //Filter the binary image to obtain the moving object, which is the detection result.
…
}
2.3 Software Optimization
When using TMS320DM6425 to develop a moving target detection system, software code optimization is particularly important to ensure efficient and real-time detection results. When programming based on TMS320DM642, we refer to the characteristics of the chip and make the following optimizations when writing the algorithm:
(1) Use pipeline technology. Use the compilation options -o2 and -o3 to make full use of software pipeline technology to improve operating efficiency.
(2) Optimize registers. Use the performance analysis tool Profiler provided by CCS to rewrite frequently called C language code in assembly language and use the assembly optimizer to optimize it to maximize the execution efficiency of the code.
2.4 Experimental Results
The experimental results of the moving target detection system based on DM642 are shown in Figure 3.
3 Conclusion
This paper uses TI's dedicated image processing chip TMS320DM642 to build a hardware platform, uses background difference method to detect moving objects, uses Otsu's method to obtain adaptive threshold, and judges whether there is object movement according to the threshold value, which simplifies the subsequent morphological processing, and then binarizes the differential image, and finally uses morphological processing to eliminate isolated points. After experiments, the motion detection system in this paper has strong adaptability, can avoid background deadlock, and can minimize the occurrence of ghosting and voids.
Previous article:Reliability Design Based on MC68HC376 Single Chip Microcomputer
Next article:What is visual programming of microcontrollers?
- Popular Resources
- Popular amplifiers
- Image acquisition and processing system for panoramic map applications
- Research on plant disease image monitoring system based on DSP
- Starting from scratch - TMS320C6000 series DSP principle and application system design
- Chip Manufacturing: A Practical Tutorial on Semiconductor Process Technology (Sixth Edition)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- GD32VF103V EVAL NucleiStudio CAN Test Project
- This circuit doesn't seem to work!
- Notes on using wireless instead of wired devices with modbus RTU protocol
- TI Texas Instruments CCD
- Design scheme based on embedded processor PowerPC7447
- [Xiao Meige SoC] How to turn off the LED flashing when AC501-SoC development board is turned on in the default Linux system
- 【GD32F310G-START】Unboxing pictures
- 8-channel 5G ADC and 8-channel 10G DAC PCIe card based on RFSOC
- State Council: my country's chip self-sufficiency rate will reach 70% by 2025
- Output problem of triode common emitter amplifier circuit