|
|
|
% Testscript um ein Bild aus den Daten durch die Netze laufen zu lassen
|
|
|
|
|
|
|
|
close all;
|
|
|
|
clear;
|
|
|
|
|
|
|
|
%die netze mit besserer Erkennung _2
|
|
|
|
RCCN_NET = 'netDetectorResNet50_2.mat';
|
|
|
|
inputSize = [224 224 3];
|
|
|
|
|
|
|
|
% first we need the data...
|
|
|
|
dataDir = 'Picturedata'; % Destination-Folder for provided (img) Data
|
|
|
|
zippedDataFile = 'PicturesResizedLabelsResizedSignsCutted.zip'; %Data provided by TA
|
|
|
|
grDataFile = 'signDatasetGroundTruth.mat';
|
|
|
|
func_setupData(dataDir, zippedDataFile, grDataFile);
|
|
|
|
|
|
|
|
%load data
|
|
|
|
grdata = load(grDataFile);
|
|
|
|
traficSignDataset = grdata.DataSet;
|
|
|
|
|
|
|
|
%Random Index
|
|
|
|
%shuffledIndices = randperm(height(traficSignDataset));
|
|
|
|
%testindx = shuffledIndices(1)
|
|
|
|
testindx = 7
|
|
|
|
|
|
|
|
% Bild einlesen
|
|
|
|
imgname = traficSignDataset.imageFilename{testindx}
|
|
|
|
I = imresize(imread(imgname),inputSize(1:2));
|
|
|
|
|
|
|
|
|
|
|
|
%RCCN-Detector laden
|
|
|
|
pretrained = load(RCCN_NET);
|
|
|
|
detector = pretrained.detector;
|
|
|
|
|
|
|
|
[bboxes,scores] = detect(detector,I);
|
|
|
|
|
|
|
|
sfigTitle = ""
|
|
|
|
bdetected = height(bboxes) > 0;
|
|
|
|
if bdetected
|
|
|
|
I = insertObjectAnnotation(I,'rectangle',bboxes,scores);
|
|
|
|
sfigTitle = "Detected";
|
|
|
|
else
|
|
|
|
sfigTitle = "Not Detected";
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
figure;
|
|
|
|
imshow(I);
|
|
|
|
annotation('textbox', [0.5, 0.2, 0.1, 0.1], 'String', sfigTitle)
|
|
|
|
|
|
|
|
%ggf. bild zuschneiden
|
|
|
|
if bdetected
|
|
|
|
icrop = imcrop(I , bboxes);
|
|
|
|
figure;
|
|
|
|
imshow(icrop);
|
|
|
|
|
|
|
|
alex_test(icrop);
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|