Issues for code generation of trackerPHD and trackingSensorConfiguration using Matlab Coder
Show older comments
Hello,
I was trying to generate C++ for the following function codegenTracker. After a careful study of the extended capabilities section of the trackerPHD document and a lot of experiments, I was able to generate the code successfully.
However, I found that I have to set the number of sensors, which is n in the code below expectily ( to 3, in mycase), so that it does not give me the error: 'Loop unrolling failed because the number of iterations is unknown' during 'Check for Run-Time Issues'. From an application point of view, I prefer n to be specified in a configuration file, so that I could load n like the tempConfig struct in the code below, instead of set it to a number expectily. For example, if I want to change the ClutterDensity property of trackingSensorConfiguration, I can just change it in my configuration file without the need to change it in my matlab code and regenerate the entire code.
Similarly, for trackerPHD, I have to specify the properties expectily. If I try to set a property of trackerPHD,say, BirthRate, through the configuration file, I got the following error: 'Failed to compute constant value for nontunable property 'BirthRate'. In code generation, nontunable properties can only be assigned constant values'.
How do I modify my code so that I do not need to specify all the parameters expectily and it still supports code generation? Thanks in advance. I have attach my code for code generation, which is based on the matlab project 'Asynchronous Angle-only Tracking with GM-PHD Tracker'.
function tracks = codegenTracker(detections, configs, time) %#codegen
tracks = repmat(DummyTracks(),0,1);
coder.varsize('tracks',[Inf,1],[1,0]);
persistent tracker;
if isempty(tracker)
% read parameters from the configuration file, tempConfig is a struct that
% contains these parameters.
tempConfig = config.readSensorConfig();
% Prefer Load n from a configuration file instead of set it to a number
% expectily
%
n = 3;
sensorConfigs = cell(n,1) ;
for i = 1 : n
sensorConfigs{i,1} = trackingSensorConfiguration("SensorIndex",single(i), ...
"IsValidTime",true, ...
"SensorLimits", tempConfig.SensorLimits,...
"SensorResolution", tempConfig.SensorResolutions,...
"SensorTransformFcn",'cvmeas', ...
"SensorTransformParameters", DummyMps(),...
"ClutterDensity", tempConfig.ClutterDensity, ...
"MinDetectionProbability", tempConfig.MinDetectionProbability,...
"FilterInitializationFcn", 'initcvAngleOnlyGMPHD',...
"MaxNumDetsPerObject", uint32(1), ...
"MaxNumDetections", uint32(100));
end
tracker = trackerPHD(SensorConfigurations = sensorConfigs, ...
BirthRate = 0.1, ...
DeathRate = 1e-6, ...
AssignmentThreshold = 25 , ...
ExtractionThreshold = 0.85, ...
ConfirmationThreshold = 0.95, ...
DeletionThreshold = 1e-3, ...
MergingThreshold = 25, ...
LabelingThresholds = [1.1 1 0.8], ...
HasSensorConfigurationsInput = true, ...
MaxNumSensors = 20, ...
MaxNumTracks = uint32(1000), ...
MaxNumComponents = uint32(5000));
end
if tracker.isLocked() || ~isempty(detections)
tracks = tracker(detections, configs, double(time));
end
end
Loop unrolling failed because the number of iterations is unknown.
Accepted Answer
More Answers (0)
Categories
Find more on Multi-Object Trackers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!