I am using a matlab function block in simulink. Im trying to detect lines in a simulation. When I tried to use "houghlines" directly, it said that I need to use dynamic memory allocation. So I added coder.extrinsic command. Now I can see lines structure and print it. However, when I try to use it it gives error in the title. Here is the code:
function masked_image = fcn(image)
[r,g,b]=imsplit(image);
masked_image=r==255 & g==0 & b==0;
masked_image=edge(masked_image);
%imshow(masked_image);
[H,T,R]=hough(masked_image);
peaks = houghpeaks(H)
assert(length(peaks) < 100);
coder.extrinsic("houghlines");
lines=houghlines(masked_image,T,R,peaks);
if ~isempty(lines)
disp(lines(1).point1)
end
The error is
Attempt to extract field 'point1' from 'mxArray'.
Function 'Image Processing System/detectColorBox' (#27.338.346), line 19, column 10:
"lines(1)"
Launch diagnostic report.
I tried to create a structure before defining lines with "houghlines" command. I dont know why but I think since the size of lines is changing continuously, it gives error about sizes.