繁体   English   中英

我是 Matlab 的新手,目前正在研究图像中的武器检测,但我在这里得到了误报。我该怎么办?

[英]I m new to Matlab and currently working of weapon detection in images but i m getting false positives here.What should i do?

我如何使用 matlab 计算 F1 分数。这段代码在负样本中也给出了积极的结果。我认为这是因为 datset 中图像的动态背景。 我应该更改数据集以获得更好的准确性还是更改方法。请帮助

谢谢

数据集: http : //kt.agh.edu.pl/~matiolanski/KnivesImagesDatabase/KnivesImagesDatabase.rar

代码:`

TrainingSet = imageSet('Trainingset','recursive');

testSet= imageSet('TestSet','recursive');



img=read(TrainingSet(1),1);
[hog_4x4, vis4x4] = extractHOGFeatures(img,'CellSize',[4 4]);
cellSize = [4 4];
hogFeatureSize = length(hog_4x4);


trainingFeatures= [];
trainingLabels   = [];

x=  TrainingSet(1).Count;
y=  TrainingSet(2).Count;
for digit = 1:numel(TrainingSet)-1

    numImages = TrainingSet(digit).Count;           
    for i = 1:numImages-1

    img = rgb2gray(read(TrainingSet(digit), i));

    %Apply pre-processing steps


    features(i,:) = extractHOGFeatures(img, 'CellSize', cellSize);

end

%labels = repmat(TrainingSet(digit).Description, numImages, 1);


trainingFeatures = [trainingFeatures; features];   
%trainingLabels = [trainingLabels;   labels  ];   


end
negativeSize = size(trainingFeatures,1);
trainingLabels = zeros(size(trainingFeatures,1),1);

for digit = 2:2

    numImages= TrainingSet(digit).Count;           
    for i = 1:numImages-1

        img = rgb2gray(read(TrainingSet(digit), (i)));




        features1(i,:) = extractHOGFeatures(img, 'CellSize', cellSize);

    end

    %labels = repmat(TrainingSet(digit).Description, numImages, 1);


    trainingFeatures = [trainingFeatures; features1];   
    %trainingLabels  = [trainingLabels;   labels  ];   


end

 positiveLabels = ones(size(trainingFeatures,1) - negativeSize,1);
trainingLabels = [trainingLabels ; positiveLabels];

classifier = fitcsvm(trainingFeatures, trainingLabels);
classOrder =classifier.ClassNames;

img=read(testSet(1),1);


img = rgb2gray(img);
[testFeatures, testLabels] = extractHOGFeatures(img, 'CellSize', cellSize);

%Make class predictions using the test features.
predictedLabels = predict(classifier, testFeatures);
if(predictedLabels==1)

    warndlg('Object Detected','!! Warning !!');

else

     warndlg('Object Not Detected','!! Warning !!');

end 

我强烈建议使用 Faster-rcnn 来解决这个问题。 它是广泛用于对象检测任务的最先进的卷积神经网络架构之一。 是相同的matlab实现。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM