Rectangle on the detected class's position in an image using a trained cnn
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
camera = webcam;
camera.Resolution = '640x480';
net = googlenet;
h = figure;
while ishandle(h)
im = snapshot(camera);
image(im)
I1 = imcrop(im, [ 1 1 160 479]);
[label1,score1] = classify(trainNet,I1);
I2 = imcrop(im, [ 161 1 160 479]);
[label2,score2] = classify(trainNet,I2);
I3 = imcrop(im, [ 321 1 160 479]);
[label3,score3] = classify(trainNet,I3);
I4 = imcrop(im, [ 480 1 160 479]);
[label4,score4] = classify(trainNet,I4);
if label1=='door'
rectangle('Position',[ 1 1 160 480],'EdgeColor','b','LineWidth',3)
end
if label2=='vrata'
rectangle('door',[ 161 1 160 479],'EdgeColor','b','LineWidth',3)
end
if label3=='vrata'
rectangle('door',[ 321 1 160 479],'EdgeColor','b','LineWidth',3)
end
if label4=='vrata'
rectangle('door',[ 480 1 160 479],'EdgeColor','b','LineWidth',3)
end
end
I created a CNN with 2 classes 'door' and 'no door' and i'm using it to detect a door with this code that devides the screen from the camera into 4 parts and it uses rectangle on the the parts it detects a door, but i really want for the rectangle to appear on the exact position of the detected door, is there a way to do that?
4 commentaires
Image Analyst
le 16 Juin 2019
What did you do to train the network that you DO have right now? It should be pretty similar. Replace the last layer with your ground truth and feed in your labeled training images. What did you do to create your existing trainNet?
Réponses (0)
Voir également
Catégories
En savoir plus sur Image Data Workflows dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!