Patch and square detector program

1 vue (au cours des 30 derniers jours)
Daniel Hernández
Daniel Hernández le 16 Août 2021
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

Réponses (0)

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by