Detailed description of the components of the opencv motion detection and tracking (BLOB track) Framework

Source: Internet
Author: User

In the. \ opencv \ doc \ vidsurv folder, there are three doc FILES: blob_tracking_modules, blob_tracking_tests, and testseq. Among them, blob_tracking_modules must be read in detail.

 

"FG/BG Detection"Module into msforeground/background segmentation for each pixel.

"Blob entering Detection"Module uses theresult (fg/BG mask) of" fg/BG detection "module to detect new Blob objectentered to a scene on each frame.

"Blob tracking"Module initialized by" Blob entering detection "results and tracks each new entered blob.

"Trajectory Generation"Module performs asaving function. It collects all blobs positions and save each whole blobtrajections to hard disk when it finished (for example tracking is lost ).

"Trajecw.postprocessing"Moduleperforms a blob trajecw.smoothing function. This module is optional and cannot be encoded in specific pipeline.

 

The Motion Object Tracking framework provided by opencv is only a basic framework. developers can customize and expand some modules according to their actual needs to meet specific requirements in practical applications.

 

1. Prospect detection module cvfgdetector: its input data is the current frame image, and the output data is the foreground image (mask) of the current frame image ). The foreground image is a binary image of the same size as the input video frame. That is, if the pixels in the current frame are regarded as the moving foreground, the pixel value in the corresponding position in the foreground mask is 1. Otherwise, the corresponding pixel value is 0.

Developers must inherit the cvfgdetector class and implement pure virtual functions. Write the self-developed Motion Target Detection Algorithm in the virtual void process (iplimage * pimg) {} function. The function virtual iplimage * getmask () is the result image for foreground detection and is responsible for transmitting it to subsequent modules. Function virtual
Void release () is responsible for the release of some dynamically allocated memory.

 

2. New detection module cvblobdetector: This module is used to detect the position and size of new targets entering the monitoring range. The input of the module is the foreground image of the current frame (result of the foreground detection module) and the blocks that have been detected and calibrated. The output result is the new blocks.

Developers can instantiate virtual classes and then write their new block detection algorithms into corresponding functions.

The processing process of the new detection module is as follows: first, all the blocks are detected from the foreground image, and then the smaller blocks (possibly caused by noise) and discarded blocks that overlap with the tracked blocks, and the remaining blocks are arranged in order of size. Only a few of the larger blocks are retained (the default value is 10 ). Finally, use specific rules to filter out non-standard blocks and save the new blocks to the group list.

 

3. Block tracking module cvblobtracker: This module is used to track the Moving Target Based on the detection of the moving target in the previous two modules (foreground detection module and new block detection module. The input of this module is the foreground image and block list of the current frame and the current frame image. The output result is the information of all moving targets in the current video frame, expressed as a block (ID, POs, size ). Use the results of the new detection module to initialize the module and track the new blocks.

When developers develop the corresponding tracing system based on their own algorithms, they can inherit the class, and then use their own algorithms to implement the objective Ural void process (iplimage * pimg, iplimage * pimgfg = NULL) function ). This virtual class also defines many other auxiliary processing function interfaces, such as the function that traces the index or ID to return the specified block pointer, and sets the Parameter Function for the specified block according to the index or ID.

The processing process of the group tracking module is as follows: first, all the group blocks are extracted from the foreground image, and the center, width, and height of the group blocks are calculated. Then, for each track that has been tracked, the Kalman filter is used to predict the position and size of the trajectory in the current frame. At last, each track is processed to find the target block closest to the current frame in the previous frame, add this block to the tracking track.

 

4. trajectory generation module cvblobtrackgen: This module is used to generate a motion track for a sports target. Then, the track will be directed to the specified data warehouse or file (such as the .txt).csv file ). The input of this module is the block that represents each moving target in the current video frame. The output result is the track file stored at the specified position. This module is mainly used for saving operations. It collects the positions of all the blocks and saves them to the hard disk at the end of each track (for example, when the tracking is lost or when the object leaves the scene, you can also compute and save features for each block.

 

5. Trajectory post-processing module cvblobtrackpostproc: This module is used to process the trajectory of the blocks generated by the previous module, for example, Kalman filtering or smooth filtering. This module is optional and may not be included in the processing process. Its input is all the blocks of the currently processed image, and the output result is a list of blocks of the processed image.

 

6. trajectory analysis module cvblobtrackanalysis: when a target tracking ends, a track is generated. The subclass of cvblobtrackanalysis is used to analyze the trajectory data;

 

7. Tracking Process Module cvblobtracterauto: To help developers develop their own systems and to ensure the modular design of the system, opencv designed this virtual class to describe the entire tracking process, this represents the virtual class of the entire tracking process, which associates various modules into an organic whole. This module connects the five modules mentioned above to form a complete processing process.

The function process in this class calls other sub-modules. First, the background image is updated and the foreground image is detected, and the obtained foreground image is saved in the member variable m_pfg. After obtaining the foreground image, call the group tracking module in sequence (Note: instead of the new group detection module, the main purpose of this method is to first execute a trace to pass the tracking result of the current frame to the new detection module to provide the accuracy of the new detection. If the block tracking is completed, the new block tracking module can only be compared with the block list of the previous frame, and the accuracy of the new block detection will be reduced), the track post-processing module, and the block detection module, track generation module and track analysis module.

 

If you want to add your own algorithms to the above modules, it is also convenient. For example, if you want to add the background difference algorithm to the foreground detection module, you only need to inherit the cvfgdetector class, then we can implement our own algorithms in the process function.

 

In the original code, the Moving Target marked in red indicates that the tracking is unstable, while the Green indicates that the tracking is stable.

 

The track generation module saves data in two ways by default. One of the methods is the "rawtracks" method. Each row stores a moving target data in pixels, the start frame of the moving target, the X coordinate of the center of the moving target, the Y coordinate of the center of the moving target, the width of the moving target, the height of the moving target, and the X coordinate of the center of the moving target, Y coordinate of the center of the moving target, the width of the moving target, and the height of the moving target ,.......

 

References:

1. http://www.doc88.com/p-896576154875.html

2. http://blog.csdn.net/wk119911/article/details/7664478

3, http://www.opencv.org.cn/forum/viewtopic.php? T = 11128

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.