Error by deploying Simulink model with variable size arrays to hardware (Raspberry Pi 3 Model B)

조회 수: 2 (최근 30일)
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!
  댓글 수: 2
Elias
Elias 2018년 4월 13일
I solved my problem by modifying my model to use the 'Rotate' block instead of the imrotate() function. As a result I saw that the output of the Rotate block reserves an array size which belongs to the maximum dimensions emerged from rotating. (logical in hindsight)

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Run on Target Hardware에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by