Error by deploying Simulink model with variable size arrays to hardware (Raspberry Pi 3 Model B)
1 view (last 30 days)
Show older comments
Hello, I would like to do some image processing on the Raspberry Pi. For this I made a Simulink model with MATLAB Functions where another custom .m file is called. In that file some detected objects get cut out of the picture to detect the top and bottom. It seems that the imrotate() function is the cause of the error message.
function [topPos, corrOrientation] = TopOrientation(bw, boundingBox, ...
Centroid, MajorAxis, degOrientations, radOrientation, objCount, objID) %#codegen
assert(objCount < 50);
coder.varsize('cropObj', [720 1280]);
% coder.varsize('imrotate');
corrOrientation = zeros(objCount, 1);
topPos = zeros(objCount, 2);
for i1 = 1:objCount
if ~isempty(boundingBox)
cropObj = imcrop(bw, boundingBox(i1, :));
cropObj = imrotate(cropObj,(-1)*degOrientations(i1));
for x = 1:size(cropObj,1)
if sum(cropObj(x,:)~=0) < 0.4*floor(size(cropObj,2))
cropObj(x,:) = 0;
end
end
cropObj(~any(cropObj, 2), :) = [];
...
end
end
Without
coder.varsize('cropObj', [720 1280]);
it throws 24 errors messages in connection with 'cropObj' which have one of the following shape:
Computed maximum size is not bounded.
Static memory allocation requires all sizes to be bounded.
The computed size is [:? x :?].
This error may be reported due to a limitation of the underlying analysis.
More information
Function 'TopOrientation.m' (#58.1018.1025), line 21, column 9:
"cropObj"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
or
Computed maximum size exceeds maximum allowed number of elements (134217728).
The computed size is [:429496729 x 1].
More information
Function 'TopOrientation.m' (#58.2255.2282), line 49, column 28:
"1:floor(0.2*cropObjSize(1))"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
By applying 'coder.varsize('cropObj', [720 1280]);' it only throws 4 errors with slightly different text:
Computed maximum size of the output of function 'imrotate' is not bounded.
Static memory allocation requires all sizes to be bounded.
The computed size is [:? x :?].
Function 'TopOrientation.m' (#58.1028.1070), line 21, column 19:
"imrotate(cropObj,(-1)*degOrientations(i1))"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
I specified the outputs of the MATLAB function blocks at the Ports and Data Manager and tried different things with assert() and coder.varsize() without success. 'coder.varsize('imrotate');' didn't change anything, too.
Thank you in advance for your tips and hints!
Answers (0)
See Also
Categories
Find more on Run on Target Hardware 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!