abewley / sort

Simple, online, and realtime tracking of multiple objects in a video sequence.
GNU General Public License v3.0
3.82k stars 1.07k forks source link

Linear_assignment... What is it... #152

Closed ehdrndd closed 2 years ago

ehdrndd commented 2 years ago

In

def linear_assignment(cost_matrix):
  try:
    import lap
    _, x, y = lap.lapjv(cost_matrix, extend_cost=True)
    return np.array([[y[i],i] for i in x if i >= 0]) #
  except ImportError:
    from scipy.optimize import linear_sum_assignment
    x, y = linear_sum_assignment(cost_matrix)
    return np.array(list(zip(x, y)))

image

above image is output of

import lap
_, x, y = lap.labjv(cost_matrix, extend_cost=True)

First, i understood variables as minimum_cost index of rows, cols. But, x[5]=-1, x[6]=4, y[4]=7. ?? I can't understand those values...

Second, there are differences lap.labjv with linear_sum_assignment

from scipy.optimize import linear_sum_assignment
x2, y2 = linear_sum_assignment(cost_matrix)

image

image

Can you help me?

ehdrndd commented 2 years ago

I understood linear_sum_assignment!!

https://brc2.com/the-algorithm-workshop/

and my second question is trivial question. because rows 6,7 are all zeros..