Hungary's algorithm and its applications in computer vision

Multi-Abst Tracking (MOT) It's a job where algorithm must find and follow many things in the video. Many known algorithms are based on simple use (eg yolo) designed to process individual images. The perfect method includes separately using the detector in consecutive video frames and compare compatible boxes related to different frames that are not in the same.
An important part that makes the MOTs different algoriths how to do the same between video frames. They can check several things to do the same:
- Buyball box positions;
- OChisibions (when binding several pieces of objects combined with each other);
- the item movement;
- the objective thing;
In some cases, in all consecutive consecutive frames A and B, these features are integrated with a single number that describes the likelihood of the binding boxes found in the Based fraction.
These treasures include all pairs of binding boxes for a B. Then, Mot Algorithm tried to identify the best matches between all the binding boxes. Additionally, given boxes found by the FRAMES A and B, the purpose to create a map between the entire binding box from B-bound only once.
Hungary algorithm
Hungarithm of Hungarithm is usually read in algorithms and data structure. However, and it contains applications in the same system, and, in particular, it is often used to solve the problem match the track mentioned above.
We will learn how to move to Hungarithm's algorithm in simple settings. When we understand how to use it, we will be able to use it in the MOT problems easily.
The algorithm is called Hungary because “the most from previous two mathematical projects, dénings kőnig and jenő jenő” – Hungary's algorithm | Wikipedia
Construction
There are many examples of showing Hungarian algorithm. I love one with the workers and jobs. Here is the makeup:
There are available workers, and jobs n needs to be filled with them. There are details about the income that everyone works. As for the Company Director, the problem contains the functions that are given to the services provided by the following situations:
- All work is started only by one job;
- All activities are eliminated;
- Salary used should be reduced.
We will solve this problem through the following 4 x 4 The cost of the matrix as an example:

Usually, you are given a matrix above, the purpose contains the selection of the N Matrix items in such a way that there are no repeated items in any line or column, and the total number of selected items.
Plan
Hungary approach includes the first matrix into a new form that makes the solution search. In this case, we will use several matrix changes. Even though the matrix will be changed, the problem will remain equal, meaning the solution will still be the same.
To keep things simple, we will not show here in mathematically why or the matrix modification keeps the problem constantly lasting. Instead, we will provide reasonable thoughts to explain why the solution is always so.
Illustration
1. Three & Redulnation
The first step consists of identifying a low object in all matrix lines and removes it from each line. The concept here to get at least one zero on the entire line. In operation, having many zeros makes the problem easier.
Suppose that a number m is removed from a given line. While the purpose of the purpose (reduced salary) changes during the change (decreases by M), the related costs between the same work assignments remain unchanged. Therefore, the level of solutions remained unchanged.
Analogous process is made in columns: The lowest item in all column is issued to that column.

After two first changes, we find matrix and other zeros representing potential assignments.
The next step consists of drawing a small amount of horizontal lines and vertical as they passed through all zeros in the matrix. In the picture below, we can draw K = 3 total lines to cover all zeros.

If the number of lines are drawn equal to matrix size, and we find a solution. The only step left in such situation is to choose such n zero that no zero in a straight or vertical line as one zero.
Since, in our example, n ≠ K, (Matrix Limit n = 4; the number of lines dragged in K = 3), it means that we should do the correction action.
2. The correction action
So far, we draw several lines, and we can distinguish matrix materials in three sections:
- Things that are not rewarded;
- Materials covered (once);
- Things in the corner (double-covered items – directly and directly).
The idea of the maintenance step contains to identify a small object between unprotected things and remove it from all unlocked items. At the same time, this number is added to all the core items.
In our example, a little ripe thing is 2. As a result, we remove 2 in all unbroken items (red) and 2 from all items from all (green) items.

Although it may not be obvious why the problem is always stored after the correctional action, it can prove statistically calculated in all its costs twice, which keep the correct solution similarly.
This change was one of the correctional action, which resulted in the same matrix situation. As before, we make a check to find out if we can combine all zeros using only ni the lines.

As we can see, this time we have to draw k = n = 4 rows to cover all zeros. It means that we can finally bring back our solution!
Besides, if we could be drawn under the small K <4 lines, we should have repeated the correction action until the rows number became K = 4.
3. Recovery of solutions
The only step left to get N zeros in different and direct lines. If you do it manually, it is best to start with a few young men.
After receiving zeros ranks in the matrix, we can return to the original matrix and select the first things in the same positions with zeros found. And that's going to be the last assignment!

Hungarithm's algorithm is the O (N ³), where n dimotry of matrix.
The newly known allocation problem can be solved in direct planning ways.
Dogs
One of the most obvious Hungarithm applications containing problems, where, is given jobs, the aim is to make good association with others or things (eg equipment) that will complete them.
There is a particular application in a computer vision. Most video trailms are based on the usual unusual algorithms (eg '
Let's take an easy example for two-line video frames:

We use the MOT Following algorithm with yolo-based object. Yolo predictions are shown below in gray boxes.

The purpose is to compile binding boxes between the last trend of things. One possible way to do this includes analyzing changes in the distance between the boxing boxes between two structures. It is reasonable to think that the binding boxes are the same thing if their position has not changed many between two frames.
Here's where Hungary's algorithm enter. We can build a mattrix representing the same distances (which will be cost-based functions) between the links of different binding boxes in both frameworks. We can find such map that reduces the full grade between the binding boxes.

By using Hungarithy algorithm, we receive the following mappings:
(A₁, C₂), (B₁, A₂), (C₁, B₂).
We can ensure that they result in the absolute perfection of 8 + 1 + 5 = 14 Which of the low job expenses of this matrix. Therefore, the mappings are found correct.

Certainly, modern algorithms look at other things when comparing the tissue boxes, including the analysis of the trajectory, the speed and directory, and physical resources, among others. For convenience, we only looked at one thing: the distance between the binding boxes. However, literally, many things are considered many.
Store
In this article, we look at Hungarian algorithm used to solve the problems of the assigned work. By doing simple tasks in the first data matrix, Hungarian algorithm changes it in other formats while keeping the problem attack.
Despite its cubic difficulties, Hungary algorithm has a variety of applications for matching problems and computer problems where the number of things are too big.
Resources
All photos unless noted in another way is a writer.



