Matlab coder with system objects - size of expression error
    5 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
Hello,
I am trying to generate C code (static library) from a computer vision system toolbox object called vision.BoundaryTracer. I can generate the code just fine with variable-sizing (dynamic memory allocation etc) ticked in the coder options but I want to generate more compact cleaner code so I don't want variable-sizing, however if I un-tick this option, I then get an error: Could not determine the size of the expression..
Here is the code:
function [boundary_xy_vec] = label_trace(grey_thres_erode) %#codegen
maximum_pixel_count = 5000;
y = 200;
x = 200;
boundary_xy = zeros(5000,2,'double');
persistent hboundtrace;
if isempty(hboundtrace)
    hboundtrace = vision.BoundaryTracer ('MaximumPixelCount',  maximum_pixel_count, 'NoBoundaryAction', 'Fill with last point found'); 
      boundary_xy = step(hboundtrace, grey_thres_erode, [x(1) y(1)]);
  end
boundary_xy_vec = boundary_xy(:);
Now, it is having trouble allocating memory for boundary_xy the output of the step function (if you follow the error it is with the step function). This is understandable to a degree as boundary_xy could be ?*2 in size, however I set the maximum boundary size to 5000, and I setup the output variable beforehand to be 5000*2, so I'm expecting the code generation to accept that I want a 5000*2 out i.e. a static array. I have also set the necessary properties to deal with the extra values. Am I missing something here do I need to do something else to force to system preallocate the output at a certain size. For example do I have to allocate a pointer for the output..?
Any help in this matter would be greatly appreciated.
Cheers,
Gary
0 Commenti
Risposte (2)
  Wayne King
    
      
 il 7 Feb 2013
        Have you tried using the following codegen command on your M-file
codegen label_trace -args {logical(zeros(500,2))} -o label_trace
  Mohammad Khan
 il 25 Feb 2013
        The output size of this System Object (vision.BoundaryTracer) is determined at run-time and so the output buffer size is variable-sized in nature. That's why this object does not work when 'EnableVariableSizing' is disabled. To generate code from this object, it must be used with VariableSizing feature turned on.
Thanks, Mohammad
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!