
All the time that we were engaged in the development of video analytic modules, we were not bothered by the train. Our developments have been successfully used for a long time at various sites, including railway stations, railway interchanges, and the
subway . And we managed to achieve very high accuracy in our algorithms, for example, when detecting a fall of an object (person, object) on the rail space or “sticking” a car at a crossing, or
detecting a fight on a subway platform. But the task is complicated by the fact that, as a rule, it is not the detection of the train that is required, but its complete ignoring in the frame. Agree, it is difficult to ignore an object that occupies half of the screen. So our usual motion detector did not do well: when a moving train appeared, we received false alarms due to the many artifacts that appeared with it. More specifically, the false objects are detected both in the train itself and around it, due to the emerging shadows, light and other distortions that “move” along with the composition ...
It turned out and not very
Naturally, with false alarms when tracking objects while the train was moving, we fought and repeatedly. So to speak, suppressed as they could. The most obvious and simple solution was to turn off the usual motion detector while the train was traveling. For this, on the one hand, it was necessary to accurately determine the moment of its appearance in the frame - to avoid false positives provoked by it. On the other hand, it was critical to determine in time and when he would leave the frame or stop in it - to know when the usual motion detector can be turned on again. We used both algorithmic and hardware methods for detecting a train.
Unfortunately, the algorithmic approach based on the use of the same
motion detector as for ordinary objects, as it turned out, has a number of fundamental flaws. Yes, we have learned how to accurately determine an object with physical or screen dimensions exceeding a certain threshold, and also to record the moment when this object leaves the stage or stops. But the train won: it had such a strong and long-lasting effect on the adaptive background that it managed to significantly “spoil” it. This hampered its own segmentation as a single entity. Attempting to prohibit or reduce the background adaptation rate during a train travel significantly increased the likelihood that the algorithm would “get stuck” in this mode (for example, during an abrupt change in illumination) and our normal motion detector would lose its operation. Well, along the way, we found out that the crowd, tightly assembled on the platform of the metro, is also perceived as a train because of its large size.
“Let's try the hardware method!” - we decided. And succeeded, because the closure of contacts under the rails by train gave us an accuracy of 100%. Here is just the embodiment of this method everywhere turned out to be a problem, and we again thought about the algorithmic solution.
In short, to achieve the final goal, we had to solve two subtasks: first, reliably detect the train, and then in a certain way "suppress" both the train itself and the associated artifacts.
')
Eureka!
Do not take into account the train can not take into account the train is difficult. What distinguishes it from other objects in the frame, except for dimensions? That's right, driving on rails!
After this seemingly uncomplicated discovery, the decision came by itself: we set the area (or areas) in which the train can pass. Taking into account the fact that the train moves strictly along the rails, it is enough for the operator to specify rectangles on both sides of the train’s possible entry-exit, approximately coinciding (more or equal) with the dimensions of the train in the necessary parts of the scene.
The so-called region of repression is built along these rectangles. Of course, it can be increased, if necessary, capturing and the neighborhood of a moving train. Here is how the setting looks on the operator's screen:
Then the specified area is divided using an adaptive algorithm into several subdomains, for each of which the movement - the displacement between frames is determined by the correlation method. And since the train can move at a very different speed (and fly at all pairs, and drag on a caterpillar), to improve the accuracy of detection, we determine the offset for frames with different time intervals, and not only between the current and previous frames. In the picture, offsets are marked with red stripes.
But that's not all. We included in the calculation not only the approximate dimensions of the train and its location, but also the direction of travel. This condition eliminates false positives in cases when a large object moves in a frame (for example, when vehicles are moving through a railway crossing) and its trajectory does not coincide with the direction of train movement.
The resulting set of displacements in space is analyzed in time for different subregions and to reduce false positives that may occur due to random distortion or movement of small objects (people / work crew) along the rail or on the apron: based on the analysis, the decision on the presence / absence moving train in a given region.
Accordingly, if the train enters the region (or starts moving, if it was present in the frame initially), an event “train moved” occurs and the state of the region switches to “train inside” (meaning exactly the moving train). When the train leaves the region or stops there, the event “train left” occurs, and the state of the region switches to “no train”. It is clear that the suppression of the train and its surroundings (when setting the appropriate parameter) is carried out by imposing a mask only for those regions in which the current state is listed as “train inside”.
Hooray, we won! Here, in fact, looks like the work of the detector:
Thank you for your attention, we will be happy to answer your questions!