Why does my system object get an assertion failure error
1 次查看(过去 30 天)
显示 更早的评论
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('Helper\nDataLog\nReader');
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
0 个评论
回答(1 个)
Karan Singh
2025-2-1
I have experienced an assertion failure before. In my case, it occurred while I was using some MEX files. However, I resolved it by reinstalling the MinGW compiler.
That doesn’t seem to be the issue in your case. I tried running the code you provided, but I received an empty result. Since it runs without any errors on my end, it might indicate an incorrect installation on your side as well. You could try reinstalling it once again—I believe that might fix the issue for you.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Tracking and Sensor Fusion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!