0

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.

2
  • Please copy-paste the full error message into your post, including the stack trace. Commented Aug 14, 2023 at 19:54
  • Done. Do you know any solution for that problem? Commented Aug 14, 2023 at 20:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.