"This System object method does not support input of unbounded size" error for vision.BlobAnalysis

Hello,
I am trying to convert vision.BlobAnalysis function in MATLAB to C code by using Coder.
step function of vision.BlobAnalysis throws an error as "This System object method does not support input of unbounded size".
The inputs of the step function are a system object (i.e., blobAnalyzer) that is returned by the vision.BlobAnalysis function and a logical matrix (i.e., BW) that stores a black&white photo.
Two lines of code are given inline as follows:
blobAnalyzer = vision.BlobAnalysis('MinimumBlobArea', minsizeofcentroid);
[Area, centroid] = step(blobAnalyzer, BW);
My goal is to find the centroids of the connected objects in a given photo.
Best regards,
Yagiz

 Accepted Answer

Add an assert() on the size() of BW
assert(size(BW,1) <= 1024 & size(BW,2) <= 1024)
Change the 1024 here to whatever is appropriate for your purposes. The exact values do not matter: what matters is that they are bounded. The exact sizes you choose might influence whether variables are put on the stack or in the heap.
The exact sizes you choose will influence any HDL that might be generated, if you happen to be headed to FPGA / HDL, in that the HDL code generation system has to keep track of the sizes of objects in order to be sure that you do not exceed the limited amount of memory available on the FPGA. For HDL / FPGA purposes it is best to choose sizes as limiting as you are willing to put up with.

More Answers (2)

Walter,
Thank you for your fast response.
I've just tried to assert the size of each dimension of BW matrix before I create vision.BlobAnalysis object as you proposed. Unfortunately, "This System object method does not support input of unbounded size." error persists. The size of BW variable is still shown as "inf x inf" in the issue resolver of Coder. However, BW's size is defined as 329 x 330 when I debug the code using the Matlab's debugger.
Best regards,
Yagiz
Hello Walter,
I commented out some unnecessary parts in my code and I re-run the Coder. It worked this time.
Thank you for your help.
Yagiz

Community Treasure Hunt

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

Start Hunting!