Patch and square detector program

조회 수: 1 (최근 30일)
Daniel Hernández
Daniel Hernández 2021년 8월 16일
Hello good afternoon I hope you can help me with this
I want to detect taches and squares using matlab vision, but the square is not detected yet.
Can someone support me with that?
clear all;
close all;
clc;
%Parametros de configuracion de la camara
cam=ipcam('http://192.168.68.102:8080/videofeed')
preview(cam)
%pause(5)
%Tomamos foto
E = snapshot(cam);
EG = rgb2gray(E);
EGF = medfilt2(EG);
BW = im2bw(EGF);
BW1 = edge(EGF,'sobel');
BW2 = edge(EGF,'canny');
stats = regionprops(BW,'Perimeter','Area','Centroid','BoundingBox');
figure(1);
imshow (BW);
%Deteccion de formas
hold on
for k=1: length(stats)
thisboundingbox=stats(k).BoundingBox;
if stats(k).Area <0
rectangle('Position',[thisboundingbox(1),thisboundingbox(2),thisboundingbox(3),thisboundingbox(4)], 'EdgeColor', 'b','LineWidth',2);
else
rectangle('Position',[thisboundingbox(1),thisboundingbox(2),thisboundingbox(3),thisboundingbox(4)], 'EdgeColor', 'r','LineWidth',2);
end
if stats(k).Perimeter^2/stats(k).Area < 15
text(stats(k).Centroid(1),stats(k).Centroid(2), '* Ciculo','Color', 'r');
end
end
pause (10)
%Mostramos imagen
figure(2)
subplot(1,3,1); imshow(E);
title('Imagen Original');
subplot(1,3,2); imshow(BW);
title('Imagen blanco y negro');
%subplot(1,3,3); imshow(BW1);
%title('Contornos de las figuras');
subplot(1,3,3); imshow(BW2);
title('Contono suaves');
clear all

답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by