mergeDetections
Syntax
Description
merges detections sharing the same cluster labels. By default, the function merges
detections in the same cluster using a Gaussian mixture merging algorithm. The function
assumes that all detections in the same cluster share the same clusteredDetections = mergeDetections(detections,clusterIndex)Time,
SensorIndex, ObjectClassID,
MeasurementParameters, and ObjectAttributes
properties or fields.
specifies the function used to merge the detections in addition to the input arguments from
the previous syntax.clusteredDetections = mergeDetections(___,MergingFcn=mergeFcn)
Examples
Generate two clusters of detections with two false alarms.
rng(2021) % For repeatable results x1 = [5; 5; 0] + randn(3,4); % Four detections in cluster one x2 = [5; -5; 0] + randn(3,4); % Four detections in cluster two xFalse = 30*randn(3,2); % Two false alarms x = [x1 x2 xFalse];
Format these detections into a cell array of objectDetection objects.
detections = repmat({objectDetection(0,[0; 0; 0])},10,1);
for i = 1:10
detections{i}.Measurement = x(:,i);
endDefine the cluster indices according to the previously defined scenario. You can typically obtain the cluster indices by applying a clustering algorithm on the detections.
clusterIndex = [1; 1; 1; 1; 2; 2; 2; 2; 3; 4];
Use the mergeDetections function to merge the detections.
clusteredDetections = mergeDetections(detections,clusterIndex);
Visualize the results in a theater plot.
% Create a theaterPlot object. tp = theaterPlot; % Create two detection plotters, one for unclustered detections and one for % clustered detections. detPlotterUn = detectionPlotter(tp,DisplayName="Unclustered Detections", ... MarkerFaceColor="b",MarkerEdgeColor="b"); detPlotterC = detectionPlotter(tp,DisplayName="Clustered Detections", ... MarkerFaceColor="r",MarkerEdgeColor="r"); % Concatenate measurements and covariances for unclustered detections detArray = [detections{:}]; xUn = horzcat(detArray.Measurement)'; PUn = cat(3,detArray.MeasurementNoise); % Concatenate measurements and covariance for clustered detections clusteredDetArray = [clusteredDetections{:}]; xC = horzcat(clusteredDetArray.Measurement)'; PC = cat(3,clusteredDetArray.MeasurementNoise); % Plot all unclustered and clustered detections plotDetection(detPlotterUn,xUn,PUn); plotDetection(detPlotterC,xC,PC);

Input Arguments
Object detections, specified as an N-element array of objectDetection (Sensor Fusion and Tracking Toolbox) objects, N-element cell array of
objectDetection objects, or an N-element array of
structures whose field names are the same as the property names of the
objectDetection object. N is the number of
detections. You can create detections directly, or you can obtain
detections from the outputs of sensor objects such as fusionRadarSensor (Sensor Fusion and Tracking Toolbox), irSensor (Sensor Fusion and Tracking Toolbox), and
sonarSensor (Sensor Fusion and Tracking Toolbox).
Cluster indices, specified as an N-element vector of positive
integers, where N is the number of detections specified in the
detections input. Each element is the cluster index of the
corresponding detection in the detections input. For example, if
clusterIndex(i)=k, then the ith detection from
the detections input belongs to cluster k.
Function to merge detections, specified as a function handle. You must use one of these syntaxes to define the function:
Syntax with detection input and output:
detectionOut = mergeFcn(detectionsIn)
where:
detectionsInis specified as a cell array ofobjectDetection(Sensor Fusion and Tracking Toolbox) objects (in the same cluster).detectionOutis returned as anobjectDetectionobject.
Syntax with state mean and covariance input and output:
[mergedMean,mergedCovariance] = mergeFcn(means,covariances)
where:
meansis specified as an M-by-Q matrix, representing measurements in the cluster. M is the size of each measurement and Q is the number of measurements in the cluster.covariancesis specified an M-by-M-by-Q matrix, representing the uncertainty covariance matrices corresponding tomeans. M is the size of each measurement and Q is the number of measurements in the cluster.mergedMeanis returned a P-by-1 vector, representing the merged measurement. Note that the size of the merged measurement (P) can be different from the size of the input measurement (M). This enables you to merge detections into parameterized forms, such as rectangular or cuboid detections.mergedCovarianceis returned as a P-by-P matrix, representing the uncertainty covariance in the merged measurement. P is the size of the merged mean.
Tip
You can use built-in functions, such as fusecovint (Sensor Fusion and Tracking Toolbox), fusecovunion (Sensor Fusion and Tracking Toolbox), and fusexcov (Sensor Fusion and Tracking Toolbox), as the merging function.
Example: @mergeFcn
Output Arguments
Clustered detections, returned as an M-element cell array of
objectDetection (Sensor Fusion and Tracking Toolbox) objects, where
M is the number of unique cluster indices specified in the
clusterIndex input.
Extended Capabilities
The function supports non-dynamic memory allocation code generation. For details, see Generate Code with Strict Single-Precision and Non-Dynamic Memory Allocation (Sensor Fusion and Tracking Toolbox).
The function supports strict single-precision code generation. For details, see Generate Code with Strict Single-Precision and Non-Dynamic Memory Allocation (Sensor Fusion and Tracking Toolbox).
Version History
Introduced in R2021bWhen you specify the MergingFcn name-value argument, you can now
also specify measurement means and covariances as inputs to the merging function.
Previously, you could use only objectDetection objects or its equivalent structures as
inputs.
See Also
clusterDBSCAN | objectDetection (Sensor Fusion and Tracking Toolbox)
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)