Preallocating Tracks or Parallel Processing in a Multi Object Tracking Script

1 回表示 (過去 30 日間)
Jacob Mevorach
Jacob Mevorach 2017 年 4 月 5 日
I'm working on a multi-object tracking script and I'd like to get things running as fast as possible. The way the script is currently set up a new track is created in the track structure every time a new object is detected. What I'd like to do is preallocate tracks much like I'd preallocate an array so that things run quicker. I was wondering if anyone knew any code I might use to preallocate tracks, any code I might use to clear empty tracks that were unused at the end of my run and how I might modify the function below to work with a set of preallocated tracks rather than a growing number of tracks. I would greatly appreciate any help with this. Equally helpful would be some way I might be able to implement parfor in the loop provided all the centroids, bboxes, tracks and unassigned detections were unique.
%
function [tracks_Out, nextId_Out] = createNewTracks(tracks, centroids, bboxes, unassignedDetections, nextId)
centroids = centroids(unassignedDetections, :);
bboxes = bboxes(unassignedDetections, :);
tracks_Out=tracks;
nextId_Out=nextId;
for i = 1:size(centroids, 1)
centroid = centroids(i,:);
bbox = bboxes(i, :);
% Create a Kalman filter object.
kalmanFilter = configureKalmanFilter('ConstantVelocity', ...
centroid, [200, 50], [100, 25], 100);
% Create a new track.
newTrack = struct(...
'id', nextId_Out, ...
'bbox', bbox, ...
'kalmanFilter', kalmanFilter, ...
'age', 1, ...
'totalVisibleCount', 1, ...
'consecutiveInvisibleCount', 0);
% Add it to the array of tracks.
tracks_Out(end + 1) = newTrack;
% Increment the next id.
nextId_Out = nextId_Out + 1;
end
end

回答 (0 件)

カテゴリ

Help Center および File ExchangeComputer Vision with Simulink についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by