Cannot generate code for indexing expression where the index has unknown size and underlying cell array is not homogeneous.

1 view (last 30 days)
Vimal Prasath
Vimal Prasath on 17 Jul 2020
Commented: Vimal Prasath on 25 Nov 2020
Hi,
I am trying to generate code for clusterDetections algorithms. But i'm getting errors for unknown size.
Please someone guide mw how to solve this. i'm attaching the screenshots of the error for reference
  3 Comments
Walter Roberson
Walter Roberson on 20 Jul 2020
It appears that updateTracks does expect a cell array of detections, so you will have to switch back to that.
I also see that for code generation, "All the detections used with a multi-object tracker must have properties with the same sizes and types".
I am far from sure, but it looks to me as if the detections you were creating might be different sizes -- you are generating your meas2D based upon the content of the image, and maybe the number of pixels covered need to be the same for each of the objects ??
This is speculation, something you could try; I have never used that toolbox.

Sign in to comment.

Answers (1)

Prasanth
Prasanth on 24 Nov 2020
Hi Vimal,
I understand that the function 'updateTracker' is not accepting arguments of type struct array during code generation.
Since C/C++ are statically typed languages, the fields, their types and sizes of the structure variables/arguments should be known at compile time for code generation to succeed.
In your case, the fields of the structure you are passing into the function is unknown at compile time, since it is dependent on the output of the 'clusterDetections' function that is known at run time.
If the fields of the structure is known and do not change, try predefining the variable 'detectionClusters' as an struct array and pass it as an argument into the function 'updateTracker'.
The following documentation page gives more insights on implementing the same.
Hope this helps.
  1 Comment
Vimal Prasath
Vimal Prasath on 25 Nov 2020
Thanks Prasanth,
We have solved that particular issue long back but we are having problem concatenating the cell array during the code generation. Is there any we can code generation can support cell array concatenation. Attaching the screenshot for your reference. Please let me know how to solve this

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by