主要内容

assignmunkres

Munkres global nearest neighbor assignment algorithm

描述

example

[assignments,unassignedrows,unassignedcolumns] = assignmunkres(Costmatrix,costofnononsignment)返回一张表assignments使用Munkres算法检测到轨道的检测。Munkres算法获得了全局最近邻居(GNN)分配问题的最佳解决方案。最佳解决方案可最大程度地减少任务的总成本。

每个潜在分配的成本都包含在成本矩阵中,Costmatrix。Each matrix entry represents the cost of a possible assignments. Matrix rows represent tracks and columns represent detections. All possible assignments are represented in the cost matrix. The lower the cost, the more likely the assignment is to be made. Each track can be assigned to at most one detection and each detection can be assigned to at most one track. If the number of rows is greater than the number of columns, some tracks are unassigned. If the number of columns is greater than the number of rows, some detections are unassigned. You can set an entry ofCostmatrixtoinf禁止任务。

costofnononsignment表示未分配的轨道或检测的成本。更高的值增加了每个现有对象分配的可能性。

The function returns a list of unassigned tracks,unassignedrows, and a list of unassigned detections,unassignedcolumns

Examples

collapse all

利用分配蒙克to assign three detections to two tracks.

从X-Y坐标中的两个预测的轨道位置开始。

曲目= [1,1;2,2];

Assume three detections are received. At least one detection will not be assigned.

dets = [1.1, 1.1; 2.1, 2.1; 1.5, 3];

Construct a cost matrix by defining the cost of assigning a detection to a track as the Euclidean distance between them. Set the cost of non-assignment to 0.2.

fori = size(tracks, 1):-1:1 delta = dets - tracks(i, :); costMatrix(i, :) = sqrt(sum(delta .^ 2, 2));endcostofnononsignment = 0.2;

利用the Auction algorithm to assign detections to tracks.

[assignments, unassignedTracks, unassignedDetections] =。。。assignmunkres (costMatrix成本ofnonassignment);

Display the assignments.

分配(作业)
1 1 2 2

证明没有未分配的曲目。

disp(unassignedTracks)

显示未分配的检测。

disp(unassignedDetections)
3

绘图检测以跟踪分配。

plot(tracks(:, 1), tracks(:, 2),'*', dets(:, 1), dets(:, 2),'o') 抓住xlim([0, 4]) ylim([0, 4]) legend('tracks','detections') assignStr = strsplit(num2str(1:size(assignments,1))); text(tracks(assignments(:, 1),1) + 0.1,。。。tracks(assignments(:, 1),2) - 0.1, assignStr); text(dets(assignments(:, 2),1) + 0.1,。。。dets(assignments(:, 2),2) - 0.1, assignStr); text(dets(unassignedDetections(:),1) + 0.1,。。。dets(非分配detections(:),2) + 0.1,“未分配”);

Figure contains an axes object. The axes object contains 7 objects of type line, text. These objects represent tracks, detections.

The track to detection assignments are:

  1. Detection 1 is assigned to track 1.

  2. 检测2分配给轨道2。

  3. 检测3未分配。

Input Arguments

collapse all

成本矩阵,指定为M-经过-Nmatrix.Mis the number of tracks to be assigned andNis the number of detections to be assigned. Each entry in the cost matrix contains the cost of a track and detection assignment. The matrix may containinfentries to indicate that an assignment is prohibited. The cost matrix cannot be a sparse matrix.

Data Types:single|double

Cost of non-assignment, specified as a scalar. The cost of non-assignment represents the cost of leaving tracks or detections unassigned. Higher values increase the likelihood that every object is assigned. The value cannot be set toinf

Data Types:single|double

Output Arguments

collapse all

Assignment of detections to track, returned as an integer-valuedL-经过-2 matrix whereLis the number of assignments. The first column of the matrix contains the assigned track indices and the second column contains the assigned detection indices.

Data Types:uint32

Indices of unassigned tracks, returned as an integer-valuedP-1列矢量。

Data Types:uint32

Indices of unassigned detections, returned as an integer-valuedQ-1列矢量。

Data Types:uint32

参考

[1] Samuel S. Blackman和Popoli,R。Design and Analysis of Modern Tracking Systems。Artech House:马萨诸塞州诺伍德。1999。

Extended Capabilities

C/C++ Code Generation
使用MATLAB®CODER™生成C和C ++代码。

Version History

Introduced in R2018b