Object legacy and removal detection

Source: Internet
Author: User

In the intelligent video surveillance system, the detection of remnants is a very important application. The detection of remnants is basically based on the background area corresponding to the foreground mask, this often leads to other problems, such as the robustness of the background model and adaptability to the environment. In addition, if an object in the background is removed, the background area of the object to be removed is updated. This section describes a detection algorithm used to determine whether an object is left behind or removed.Moving Object detection, tracking and Classification
For smart video survleillance
".

For a foreground area marked as a left-over or removed area, take the background area corresponding to its external rectangle as R and extend the area to the periphery, take a region s that contains the R region in the background, calculate the color mean AR and as of the two regions, and then calculate the ratio of the two mean values to further determine whether the object is left or removed. The judgment criteria are as follows:

If the mean ratio of the two regions meets the above formula, the region is considered to be the removal of objects, and the background model corresponding to the region needs to be further updated; otherwise, it is the legacy of objects, the background model corresponding to the region is not updated. Why is the criterion valid? In practice, the background tends to be the same in the scenario, that is, the adjacent areas in the same scenario are similar (especially in indoor scenarios). if the background is left behind by an object, this will cause a large change in the background of the scenario, resulting in a change in the mean value, which further directly affects a large change in the mean ratio, the mean value of the removed object is very similar to that of the area near the adjacent area. In this way, you can further judge the remaining and removed objects in the scene.

The implementation code is as follows:

// Returns 2, indicating that the data is left behind. 1 indicates that int detectleftremove (MAT & background, rect & rect) is removed {int returnval =-1; rect surroundrect; surroundrect. X = STD: max (0, rect. x-15); // 10 pixels surroundrect. y = STD: max (0, rect. y-15); If (surroundrect. Y + rect. height + 30)> background. rows) surroundrect. height = background. rows-surroundrect. y; elsesurroundrect. height = rect. height + 30; If (surroundrect. X + rect. width + 30)> background. cols) surroundrect. width = background. cols-surroundrect. x; elsesurroundrect. width = rect. width + 30; scalar S1 = mean (background (rect); scalar S2 = mean (background (surroundrect); double dist1 = norm (S1 ); double dist2 = norm (S2); double ratio = 0.0; If (dist1> = dist2) ratio = dist2/dist1; elseratio = dist1/dist2; if (ratio> = 0.85 & ratio <= 1.0) // close indicates exit (remove) returnval = 1; else // otherwise it indicates left returnval = 2; return returnval ;}

In addition, a practical matrix scaling function is introduced:

Rect scale_rect(const Rect& r, float scale){   Point2f m=centerRect(r);   float width  = r.width  * scale;   float height = r.height * scale;   int x=cvRound(m.x - width/2);   int y=cvRound(m.y - height/2);   return Rect(x, y, cvRound(width), cvRound(height));}

 

 

 

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.