Using a Matlab tracking algorithm from Java

48 views Asked by At

I am trying to use one of Matlab's trackingalgorithms from a Java code. I am having trouble with the Library Compiler. When I try to use a persistent variable, it gives me an error:

Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-0.

The function I want to generate the Java Library from:

function tracks = vfusion(detections,time) 
    persistent tracker;
    if isempty(tracker)
          tracker = trackerGNN( ...
              'TrackerIndex', 0, ...
              'FilterInitializationFcn', @initcvkf, ...
              'Assignment', 'MatchPairs', ...
              'AssignmentThreshold', 15*[1 Inf], ...
              'TrackLogic', 'History', ...  % History|Score
              'ConfirmationThreshold', [2 3], ...
              'DeletionThreshold', [5 5], ...
              'DetectionProbability', 0.9, ...
              'FalseAlarmRate', 1e-6, ...
              'Beta', 1, ...
              'Volume', 1, ...
              'MaxNumTracks', 100, ...
              'MaxNumSensors', 20, ...
              'StateParameters', struct(), ...
              'HasDetectableTrackIDsInput', false, ...
              'HasCostMatrixInput', false ...
              );
    end    
    d = { ...
        objectDetection( ...
            time, ...  % Time
            detections(1).measurement, ...  % Measurement
            'MeasurementNoise', [1.0,0.0,0.0;0.0,1.0,0.0;0.0,0.0,1.0], ...
            'SensorIndex', uint32(1), ...
            'ObjectClassID', detections(1).objectClassId, ...
            'MeasurementParameters', struct(), ...  % sensor frame transformation
            'ObjectAttributes', struct('valid', true) ...
        ), ...
        objectDetection( ...
            time, ...  % Timetracks
            detections(2).measurement, ...  % Measurement
            'MeasurementNoise', [1.0,0.0,0.0;0.0,1.0,0.0;0.0,0.0,1.0], ...
            'SensorIndex', uint32(1), ...
            'ObjectClassID', detections(2).objectClassId, ...
            'MeasurementParameters', struct(), ...  % sensor frame transformation
            'ObjectAttributes', struct('valid', false) ...
        ), ...
        objectDetection( ...
            time, ...  % Time
            detections(3).measurement, ...  % Measurement
            'MeasurementNoise', [1.0,0.0,0.0;0.0,1.0,0.0;0.0,0.0,1.0], ...
            'SensorIndex', uint32(2), ...
            'ObjectClassID',detections(3).objectClassId, ...
            'MeasurementParameters', struct(), ...  % sensor frame transformation
            'ObjectAttributes', struct('valid', true) ...
        ) ...
    };
    [confirmedTracks] = tracker(d, time);
    for i = 1:length(confirmedTracks)
        tracks(i).State = confirmedTracks(i).State;
    end

end

And the example script:

time = 43.0;
d0.measurement = [0.2, 0.0, 0.3];
d1.measurement = [1.2, 2.0, 3.3];
d2.measurement = [1.4, 2.5, 3.1];

d0.objectClassId = uint32(10);
d1.objectClassId = uint32(10);
d2.objectClassId = uint32(10);

detections = [d0, d1, d2];

for i = 1:100
    time = (time+i/10.0)
    tracks = vfusion(detections, time);
end

Anyone have any ideas? Have you used persistent variables with this Library Compiler?

0

There are 0 answers