我想使用支持向量机来分类图像中是否包含汽车。
我用HOG训练支持向量机分类器。然后我尝试使用分类器,所以我查阅了一些Mathworks教程。我找不到任何有用的使用svm分类器的教程。
我使用来自http://cogcomp.org/Data/Car/的数据集
这是我的支持向量机分类器代码。
imgPos = imread(strrep(file, '*', int2str(0)));
[hog_4x4, vis4x4] = extractHOGFeatures(imgPos,'CellSize',[4 4]);
cellSize = [4 4];
hogFeatureSize = length(hog_4x4);
temp(1:500) = 1;
temp(501:1000) = 0;
trainingLabels = categorical(temp);
trainingFeatures = zeros(fileNum*2, hogFeatureSize, 'single');
for n = 1:500
posfile = strrep(posFile, "*", int2str(n-1));
imgPos = imread(posfile);
trainingFeatures(n, :) = extractHOGFeatures(imgPos, 'CellSize', cellSize);
negfile = strrep(negFile, "*", int2str(n-1));
imgNeg = imread(negfile);
trainingFeatures(n+500, :) = extractHOGFeatures(imgNeg, 'CellSize', cellSize);
end
classifier = fitcecoc(trainingFeatures, trainingLabels);我想用分类器来检测汽车物体。如果可能的话,我想用帧包围每个检测到的汽车对象。
任何帮助都是非常感谢的。
发布于 2019-04-11 14:04:55
您正在寻找predict方法。获取您的测试数据特性并运行以下命令:
predictions = predict(classifier, testFeatures);https://stackoverflow.com/questions/55624452
复制相似问题