Why does my system object get an assertion failure error
Hello all
I am kinda new in MATLAB/Simulink,and learning the multi-object tracking task based on simulink by Track Closely Spaced Targets Under Ambiguity in Simulink. I want to finish image tracking task. I already have the target detection result based on YOLO. When I was writing based on the HelperDataLogReader class in the example, an assertion failure occurred. But I have looked up a lot of relevant materials but can’t solve it, and I hope someone can help me. Here is my code and the target detection result of YOLO, thank you so much!
classdef (StrictDefaults)HelperDataReader < …
matlabshared.tracking.internal.SimulinkBusUtilities
% This is a helper block for example purposes and may be removed or
% modified in the future.
%
% Copyright 2019 The MathWorks, Inc.
properties(Constant, Access=protected)
pBusPrefix = ‘BusDataLogReader’
end
properties(Access = public, Nontunable)
Data
end
properties(Nontunable)
Frame = fusionCoordinateFrameType.Rectangular
end
properties(Access = private)
%pCurrentIndex
pCurrentIndex = 0
%pMaxIndex Saved the maximum time step index in the data file
pMaxIndex
end
methods
function obj = HelperDataReader(varargin)
% Constructor
setProperties(obj,nargin,varargin{:});
end
end
methods(Access=protected)
function [out, argsToBus] = defaultOutput(obj)
objAtt = struct(‘Score’,double(1));
out = struct(‘Time’,double(1),…
‘Measurement’,double(zeros(1, 4)),…
‘MeasurementNoise’,double(zeros(4)),…
‘SensorIndex’,double(0),…
‘ObjectClassID’,double(0),…
‘ObjectClassParameters’, [],…
‘ObjectAttributes’,objAtt);
argsToBus = {out};
end
% Currently only support simulink environment, so nothing to do
% here
function y = sendToBus(~,x,varargin)
[newx,num] = objDet2Struct(x);
y = struct(‘Detections’,newx,’NumDetections’,num);
end
function [det, time] = stepImpl(obj)
if ~obj.isEndOfData()
obj.pCurrentIndex = obj.pCurrentIndex + 1;
end
newDet = obj.Data.detections{obj.pCurrentIndex};
det = sendToBus(obj,newDet);
time = newDet(1).Time;
end
function setupImpl(obj, varargin)
obj.Data = load(‘PedestrianTrackingYOLODetections.mat’);
obj.pMaxIndex =numel(obj.Data.detections);
end
function loadObjectImpl(obj,s,wasLocked)
% Set properties in object obj to values in structure s
% Set public properties and states
loadObjectImpl@matlab.System(obj,s,wasLocked);
end
function status = isEndOfData(obj)
% Return true if end of data has been reached
status = (obj.pCurrentIndex == obj.pMaxIndex);
end
function s = saveObjectImpl(obj)
% Set properties in structure s to values in object obj
% Set public properties and states
s = saveObjectImpl@matlab.System(obj);
end
% function varargout = getOutputDataTypeImpl(obj)
% varargout{1} = getOutputDataTypeImpl@matlabshared.tracking.internal.SimulinkBusUtilities(obj);
% varargout{2} = "double";
% end
function str = getIconImpl(~)
str = sprintf(‘HelpernDataLognReader’);
end
function varargout = getOutputNamesImpl(~)
varargout{1} = sprintf(‘Detections’);
varargout{2} = sprintf(‘Time’);
end
function varargout = getInputNamesImpl(~)
varargout{1} = sprintf(‘In’);
end
function [out1,out2] = isOutputFixedSizeImpl(~)
out1 = true;
out2 = true;
end
function [out1,out2] = getOutputSizeImpl(~)
out1 = [1 1];
out2 = [1 1];
end
function [out1,out2] = isOutputComplexImpl(~)
out1 = false;
out2 = false;
end
end
methods(Static, Hidden)
function flag = isAllowedInSystemBlock
flag = true;
end
end
methods(Static, Access=protected)
function header = getHeaderImpl
% Define header panel for System block dialog
header = matlab.system.display.Header(…
‘Title’, ‘DataLogReader’, …
‘Text’, getHeaderText());
end
function simMode = getSimulateUsingImpl
% Return only allowed simulation mode in System block dialog
simMode = ‘Interpreted execution’;
end
function flag = showSimulateUsingImpl
% Return false if simulation mode hidden in System block dialog
flag = false;
end
end
end
function str = getHeaderText
str = sprintf(‘The DataLog reader reads a struct file and it outputs the detection and time.’);
end
function [yDet,num] = objDet2Struct(det)
num = numel(det);
for i =1:num
yDet(i) = struct(‘Time’,det(i).Time,…
‘Measurement’,det(i).Measurement,…
‘MeasurementNoise’,det(i).MeasurementNoise,…
‘SensorIndex’,det(i).SensorIndex,…
‘ObjectClassID’,det(i).ObjectClassID,…
‘ObjectClassParameters’, [],…
‘ObjectAttributes’,det(i).ObjectAttributes); %#ok<AGROW>
end
endHello all
I am kinda new in MATLAB/Simulink,and learning the multi-object tracking task based on simulink by Track Closely Spaced Targets Under Ambiguity in Simulink. I want to finish image tracking task. I already have the target detection result based on YOLO. When I was writing based on the HelperDataLogReader class in the example, an assertion failure occurred. But I have looked up a lot of relevant materials but can’t solve it, and I hope someone can help me. Here is my code and the target detection result of YOLO, thank you so much!
classdef (StrictDefaults)HelperDataReader < …
matlabshared.tracking.internal.SimulinkBusUtilities
% This is a helper block for example purposes and may be removed or
% modified in the future.
%
% Copyright 2019 The MathWorks, Inc.
properties(Constant, Access=protected)
pBusPrefix = ‘BusDataLogReader’
end
properties(Access = public, Nontunable)
Data
end
properties(Nontunable)
Frame = fusionCoordinateFrameType.Rectangular
end
properties(Access = private)
%pCurrentIndex
pCurrentIndex = 0
%pMaxIndex Saved the maximum time step index in the data file
pMaxIndex
end
methods
function obj = HelperDataReader(varargin)
% Constructor
setProperties(obj,nargin,varargin{:});
end
end
methods(Access=protected)
function [out, argsToBus] = defaultOutput(obj)
objAtt = struct(‘Score’,double(1));
out = struct(‘Time’,double(1),…
‘Measurement’,double(zeros(1, 4)),…
‘MeasurementNoise’,double(zeros(4)),…
‘SensorIndex’,double(0),…
‘ObjectClassID’,double(0),…
‘ObjectClassParameters’, [],…
‘ObjectAttributes’,objAtt);
argsToBus = {out};
end
% Currently only support simulink environment, so nothing to do
% here
function y = sendToBus(~,x,varargin)
[newx,num] = objDet2Struct(x);
y = struct(‘Detections’,newx,’NumDetections’,num);
end
function [det, time] = stepImpl(obj)
if ~obj.isEndOfData()
obj.pCurrentIndex = obj.pCurrentIndex + 1;
end
newDet = obj.Data.detections{obj.pCurrentIndex};
det = sendToBus(obj,newDet);
time = newDet(1).Time;
end
function setupImpl(obj, varargin)
obj.Data = load(‘PedestrianTrackingYOLODetections.mat’);
obj.pMaxIndex =numel(obj.Data.detections);
end
function loadObjectImpl(obj,s,wasLocked)
% Set properties in object obj to values in structure s
% Set public properties and states
loadObjectImpl@matlab.System(obj,s,wasLocked);
end
function status = isEndOfData(obj)
% Return true if end of data has been reached
status = (obj.pCurrentIndex == obj.pMaxIndex);
end
function s = saveObjectImpl(obj)
% Set properties in structure s to values in object obj
% Set public properties and states
s = saveObjectImpl@matlab.System(obj);
end
% function varargout = getOutputDataTypeImpl(obj)
% varargout{1} = getOutputDataTypeImpl@matlabshared.tracking.internal.SimulinkBusUtilities(obj);
% varargout{2} = "double";
% end
function str = getIconImpl(~)
str = sprintf(‘HelpernDataLognReader’);
end
function varargout = getOutputNamesImpl(~)
varargout{1} = sprintf(‘Detections’);
varargout{2} = sprintf(‘Time’);
end
function varargout = getInputNamesImpl(~)
varargout{1} = sprintf(‘In’);
end
function [out1,out2] = isOutputFixedSizeImpl(~)
out1 = true;
out2 = true;
end
function [out1,out2] = getOutputSizeImpl(~)
out1 = [1 1];
out2 = [1 1];
end
function [out1,out2] = isOutputComplexImpl(~)
out1 = false;
out2 = false;
end
end
methods(Static, Hidden)
function flag = isAllowedInSystemBlock
flag = true;
end
end
methods(Static, Access=protected)
function header = getHeaderImpl
% Define header panel for System block dialog
header = matlab.system.display.Header(…
‘Title’, ‘DataLogReader’, …
‘Text’, getHeaderText());
end
function simMode = getSimulateUsingImpl
% Return only allowed simulation mode in System block dialog
simMode = ‘Interpreted execution’;
end
function flag = showSimulateUsingImpl
% Return false if simulation mode hidden in System block dialog
flag = false;
end
end
end
function str = getHeaderText
str = sprintf(‘The DataLog reader reads a struct file and it outputs the detection and time.’);
end
function [yDet,num] = objDet2Struct(det)
num = numel(det);
for i =1:num
yDet(i) = struct(‘Time’,det(i).Time,…
‘Measurement’,det(i).Measurement,…
‘MeasurementNoise’,det(i).MeasurementNoise,…
‘SensorIndex’,det(i).SensorIndex,…
‘ObjectClassID’,det(i).ObjectClassID,…
‘ObjectClassParameters’, [],…
‘ObjectAttributes’,det(i).ObjectAttributes); %#ok<AGROW>
end
end Hello all
I am kinda new in MATLAB/Simulink,and learning the multi-object tracking task based on simulink by Track Closely Spaced Targets Under Ambiguity in Simulink. I want to finish image tracking task. I already have the target detection result based on YOLO. When I was writing based on the HelperDataLogReader class in the example, an assertion failure occurred. But I have looked up a lot of relevant materials but can’t solve it, and I hope someone can help me. Here is my code and the target detection result of YOLO, thank you so much!
classdef (StrictDefaults)HelperDataReader < …
matlabshared.tracking.internal.SimulinkBusUtilities
% This is a helper block for example purposes and may be removed or
% modified in the future.
%
% Copyright 2019 The MathWorks, Inc.
properties(Constant, Access=protected)
pBusPrefix = ‘BusDataLogReader’
end
properties(Access = public, Nontunable)
Data
end
properties(Nontunable)
Frame = fusionCoordinateFrameType.Rectangular
end
properties(Access = private)
%pCurrentIndex
pCurrentIndex = 0
%pMaxIndex Saved the maximum time step index in the data file
pMaxIndex
end
methods
function obj = HelperDataReader(varargin)
% Constructor
setProperties(obj,nargin,varargin{:});
end
end
methods(Access=protected)
function [out, argsToBus] = defaultOutput(obj)
objAtt = struct(‘Score’,double(1));
out = struct(‘Time’,double(1),…
‘Measurement’,double(zeros(1, 4)),…
‘MeasurementNoise’,double(zeros(4)),…
‘SensorIndex’,double(0),…
‘ObjectClassID’,double(0),…
‘ObjectClassParameters’, [],…
‘ObjectAttributes’,objAtt);
argsToBus = {out};
end
% Currently only support simulink environment, so nothing to do
% here
function y = sendToBus(~,x,varargin)
[newx,num] = objDet2Struct(x);
y = struct(‘Detections’,newx,’NumDetections’,num);
end
function [det, time] = stepImpl(obj)
if ~obj.isEndOfData()
obj.pCurrentIndex = obj.pCurrentIndex + 1;
end
newDet = obj.Data.detections{obj.pCurrentIndex};
det = sendToBus(obj,newDet);
time = newDet(1).Time;
end
function setupImpl(obj, varargin)
obj.Data = load(‘PedestrianTrackingYOLODetections.mat’);
obj.pMaxIndex =numel(obj.Data.detections);
end
function loadObjectImpl(obj,s,wasLocked)
% Set properties in object obj to values in structure s
% Set public properties and states
loadObjectImpl@matlab.System(obj,s,wasLocked);
end
function status = isEndOfData(obj)
% Return true if end of data has been reached
status = (obj.pCurrentIndex == obj.pMaxIndex);
end
function s = saveObjectImpl(obj)
% Set properties in structure s to values in object obj
% Set public properties and states
s = saveObjectImpl@matlab.System(obj);
end
% function varargout = getOutputDataTypeImpl(obj)
% varargout{1} = getOutputDataTypeImpl@matlabshared.tracking.internal.SimulinkBusUtilities(obj);
% varargout{2} = "double";
% end
function str = getIconImpl(~)
str = sprintf(‘HelpernDataLognReader’);
end
function varargout = getOutputNamesImpl(~)
varargout{1} = sprintf(‘Detections’);
varargout{2} = sprintf(‘Time’);
end
function varargout = getInputNamesImpl(~)
varargout{1} = sprintf(‘In’);
end
function [out1,out2] = isOutputFixedSizeImpl(~)
out1 = true;
out2 = true;
end
function [out1,out2] = getOutputSizeImpl(~)
out1 = [1 1];
out2 = [1 1];
end
function [out1,out2] = isOutputComplexImpl(~)
out1 = false;
out2 = false;
end
end
methods(Static, Hidden)
function flag = isAllowedInSystemBlock
flag = true;
end
end
methods(Static, Access=protected)
function header = getHeaderImpl
% Define header panel for System block dialog
header = matlab.system.display.Header(…
‘Title’, ‘DataLogReader’, …
‘Text’, getHeaderText());
end
function simMode = getSimulateUsingImpl
% Return only allowed simulation mode in System block dialog
simMode = ‘Interpreted execution’;
end
function flag = showSimulateUsingImpl
% Return false if simulation mode hidden in System block dialog
flag = false;
end
end
end
function str = getHeaderText
str = sprintf(‘The DataLog reader reads a struct file and it outputs the detection and time.’);
end
function [yDet,num] = objDet2Struct(det)
num = numel(det);
for i =1:num
yDet(i) = struct(‘Time’,det(i).Time,…
‘Measurement’,det(i).Measurement,…
‘MeasurementNoise’,det(i).MeasurementNoise,…
‘SensorIndex’,det(i).SensorIndex,…
‘ObjectClassID’,det(i).ObjectClassID,…
‘ObjectClassParameters’, [],…
‘ObjectAttributes’,det(i).ObjectAttributes); %#ok<AGROW>
end
end multi-object tracking, sensor fusion and tracking toolbox, system object MATLAB Answers — New Questions