Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 基于surf特征和knn搜索树的人脸识别_Matlab_Face Recognition_Surf_Knn_Matlab Cvst - Fatal编程技术网

Matlab 基于surf特征和knn搜索树的人脸识别

Matlab 基于surf特征和knn搜索树的人脸识别,matlab,face-recognition,surf,knn,matlab-cvst,Matlab,Face Recognition,Surf,Knn,Matlab Cvst,我一直在从事一个使用surf特征和knn搜索树的人脸识别项目,使用matlab 2014A。我面临的问题是,我无法将knn搜索树的结果与数据库中的每个文件手动匹配,因此我可以指定哪张脸最像样本。有谁能帮我在数据库中找到三个最近的邻居吗? 这是我的密码 %将所有要素合并到数据集中 我有128冲浪功能,为每个面在数据库中 featureDataset=doublevertcatimageCollection.featureVectors % instantiate a kd tree imageFe

我一直在从事一个使用surf特征和knn搜索树的人脸识别项目,使用matlab 2014A。我面临的问题是,我无法将knn搜索树的结果与数据库中的每个文件手动匹配,因此我可以指定哪张脸最像样本。有谁能帮我在数据库中找到三个最近的邻居吗? 这是我的密码

%将所有要素合并到数据集中 我有128冲浪功能,为每个面在数据库中 featureDataset=doublevertcatimageCollection.featureVectors

% instantiate a kd tree
imageFeatureKDTree = KDTreeSearcher(featureDataset);

query.wholeImage = imread('F\:trio.jpg');

faceDetector = vision.CascadeObjectDetector();
bbox            = step(faceDetector, query.wholeImage)
Out=query.wholeImage;
for k = 1:size(bbox,1)

figure; axesHandle=axes; imshow(query.wholeImage); title('Query Image');
rectangleHandle=imrect(axesHandle,bbox(k,:)) ;

% Consider only selected region
query.image=imcrop(query.wholeImage,getPosition(rectangleHandle));
query.image=rgb2gray(query.image);
% Detect SURF features
query.points = detectSURFFeatures(query.image);
% Extract SURF descriptors
[query.featureVectors,query.points] = ...
    extractFeatures(query.image,query.points,'SURFSize',128);


[matches, distance] = knnsearch(imageFeatureKDTree,query.featureVectors,'Distance','euclidean','K',3);
indexIntervals = [0, cumsum([imageCollection.featureCount])] + 1;
counts = histc(matches(:, 1), indexIntervals);
counts1=histc(matches(:, 2), indexIntervals);
counts2=histc(matches(:, 3+), indexIntervals);
if max(counts)==0
    disp('No Features Matched')
else
    for i = 1:numel(imageCollection) % Scale each image

if (counts(i)==max(counts))        
name=srcFiles(i).name;

end
if (counts(i)==max(counts1))        
name1=srcFiles(i).name;

end
if (counts(i)==max(counts2))        
name2=srcFiles(i).name;
end
    end
    t1 = strcmpi(name(1:10),name1(1:10));t2=strcmpi(name(1:10),name2(1:10));
t3=strcmpi(name1(1:10),name2(1:10));
if((t1==1)||(t2==1)||(t3==1))
Out = insertObjectAnnotation(Out,'rectangle',bbox(k,:),name(1:length(name)-1));
else if (t3==1)

Out = insertObjectAnnotation(Out,'rectangle',bbox(k,:),name1(1:length(name)-1));
    else
Out = insertObjectAnnotation(Out,'rectangle',bbox(k,:),'not matched');
    end
end
end
end
imshow(Out)