Why is the rectangle() function not recognized?
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
CHINTALA NIRMAL SRINIVAS
el 11 de Mayo de 2020
Comentada: CHINTALA NIRMAL SRINIVAS
el 11 de Mayo de 2020
I have a 2D floor plan image. I want to have bounding boxes around the rooms in it. When I use rectangle function to draw rectangles, error 'Unrecognised function of variable 'rectangle' '. Can somebody help me please?
Here is my code:
BW1=imread('wallimage_withnodoor.jpg');
BW1=im2bw(BW1);
Rooms = regionprops(BW1,'BoundingBox');
imshow(BW1); hold on
for k=1:length(Rooms)
currbb=Rooms(k).BoundingBox;
rectangle('Position',[currbb(1),currbb(2),currbb(3),currbb(4)], 'EdgeColor','r','LineWidth',2);
end
hold off
This is the error which I am getting:
Unrecognized function or variable 'rectangle'.
Error in classify_objects_test1 (line 46)
rectangle('Position',[currbb(k),currbb(2),currbb(3),currbb(4)], 'EdgeColor','r','LineWidth',2);
Here is the image I used:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/291998/image.jpeg)
I want to have the bounding boxes around each room in the image.
8 comentarios
Walter Roberson
el 11 de Mayo de 2020
Is it possible that you are running scripts (instead of calling functions), and at the same time you call load without any output arguments, and one of the .mat files being loaded includes a variable named rectangle ?
When there are potentially conflicts between variable names load()'d, and function names that are the same as the variable names, there are some cases where MATLAB can make arbitrary decisions about whether the name refers to a function or a variable.
Respuestas (1)
madhan ravi
el 11 de Mayo de 2020
built-in (/MATLAB/toolbox/matlab/graphics/primitive/rectangle)
If you see other than the above after using
which rectangle -all
Y ou need to remove or rename those file/s.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!