📄 findfaces.asv
字号:
function [pos,facesamples] = findfaces(im)
pic = getpic(double(im),1,1);
pos=[];% pos=[y x scale]
facesamples=[];
binpic = ones(size(pic));
% finds "facelike" pictures and saves their positions along with scale in pos
for i= [1.9 2.3 2.8 3.5 4.3 5.1 6 7 8]
nom=10; den=10*i;
cur_pic=getpic(pic,nom,den);
cur_bin = getpic(binpic,nom,den);
cur_bin = cur_bin>0.5;
if (i<5)
cur_bin(:,2:2:size(cur_bin,2))=0;
cur_bin(2:2:size(cur_bin,1),:)=0;
end;
% if picture is too small go to bigger size (next loop)
if ((size(cur_pic,1)<20)|(size(cur_pic,1)<20))
continue;
end
% identifie "small face" with facepos]
[p,s]=facepos(cur_pic,cur_bin);
% choosing the most likly to be faces (we can fet positive results from facepos for images 2 pixels apart
% for example, will pick only one from them
if (size(p,1) == 0)
continue;
end
[p,s]=facelocation(p,s);
facesamples = [facesamples s];
for xx=1:size(p,1)
starty = (p(xx,1)-10)*i;
if (starty<1) starty=1;end;
endy = p(xx,1)*i+15*i;
startx = (p(xx,2)-5)*i;
if (startx<1) startx=1; end;
endx = (p(xx,2)+15)*i;
% binpic(starty:endy,startx:endx)=0;
end
if size(p,1) > 0
tmp = [p i*ones(size(p,1),1)];
pos = [pos;tmp];
end
end
% a face can be recognized in several scales, order to get the picture in the "best" scale
% we list them in a descending order by the SVM
posScore=[];
for j=1:size(pos,1)
load FC;
[l,sc] = osuSVMclass(facesamples(:,j),FC.n, FC.alpha, FC.sv,FC.b, FC.params);
posScore=[posScore;sc];
clear FC;
end
[dummy,newPos]=sort(posScore);
newPos=newPos(size(newPos,1):-1:1,:);
newPos=newPos';
pos=pos(newPos,:);
facesamples=facesamples(:,newPos);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -