Halcom 发表于 2016-12-25 17:54:58

人脸检测

GML AdaBoost Matlab Toolbox:
**** Hidden Message *****
1、人脸检测---基于肤色检测的实现
2、人脸检测-基于模板匹配的实现
这两种方法都是基于肤色特征实现的,是比较经典的人脸检测实现的算法,

MATLAB工具箱函数使用如下:
**** Hidden Message *****

Adaboost的几个人脸检测网站
**** Hidden Message *****

基于adaboost的人脸检测算法的matlab实现过程
http://www.ilovematlab.cn/forum.php?mod=viewthread&tid=122887
http://www.ilovematlab.cn/thread-34196-1-1.html
http://www.ilovematlab.cn/thread-474554-1-1.html
http://www.thinkface.cn/forum-73-1.html





Halcom 发表于 2016-12-25 17:56:32

       最基本的整个流程框架:整个task被看作是模式识别,或者说机器学习的一个task因此分成learning和detecting的过程,前者学习出人脸模型,后者使用这个模型进行监测;
       learning阶段:使用人脸区域和非人脸区域,每个区域是一张图,对每张图提取特征,比如haar-like特征,这个很经典,提取完了再reshape一下,所有reshape过的特征塞给adaboost分类器进行训练;
       测试阶段就是滑窗法进行检测了:在测试图像的空间尺度金字塔的每一层上,每一个可能的位置都提取haar-like特征,然后塞给分类器(也就是加载了刚刚训练好的模型的分类器),它会算出一个response值,根据阈值将这个response划分为人脸和非人脸。

Halcom 发表于 2016-12-25 20:54:41

创建gabor滤波下的ffnn神经网络,进行人脸预测
net = network;
net.numInputs = 1;
net.numLayers = 2;

net.biasConnect = ;
net.inputConnect = [1 ;...
                  0 ];
net.layerConnect = [0 0 ;...
                  1 0 ];               
net.outputConnect = ;               
net.targetConnect = ;

netInputs = ones (2160,2);
netInputs (1:2160,1)= -1;
net.inputs{1}.range = netInputs;
net.layers{1}.size = 100;
net.layers{2}.size = 1;
net.layers{1:2}.transferFcn = 'tansig';
net.layers{1:2}.initFcn = 'initnw';

net.initFcn = 'initlay';
net.performFcn = 'msereg';
net.trainFcn = 'trainscg';
net = init(net)
save net net然后再分块预测
% Version : 5.4
% Date : 12.26.2010
% Author: Omid Sakhi
% <a href="http://www.facedetectioncode.com" target="_blank">http://www.facedetectioncode.com</a>

function im_out = imscan (net,im)

close all

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% PARAMETERS
SCAN_FOLDER = 'imscan/';
UT_FOLDER = 'imscan/under-thresh/';
TEMPLATE1 = 'template1.png';      
TEMPLATE2 = 'template2.png';      
Threshold = 0.5;
DEBUG = 0;
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


warning off;
delete ();
delete ();
if (DEBUG == 1)
    mkdir (UT_FOLDER);
    mkdir (SCAN_FOLDER);
end

=size(im);

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% First Section
C1 = mminmax(double(im));
C2 = mminmax(double(imread (TEMPLATE1)));
C3 = mminmax(double(imread (TEMPLATE2)));
Corr_1 = double(conv2 (C1,C2,'same'));
Corr_2 = double(conv2 (C1,C3,'same'));
Cell.state = int8(imregionalmax(Corr_1) | imregionalmax(Corr_2));
Cell.state(1:13,:)=-1;
Cell.state(end-13:end,:)=-1;
Cell.state(:,1:9)=-1;
Cell.state(:,end-9:end)=-1;
Cell.net = ones(m,n)*-1;
= find(Cell.state == 1);
imshow(im);
hold on
plot(LUTn,LUTm,'.y');pause(0.01);

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% Second Section
while (1==1)
    = find(Cell.state==1,1);
    if isempty(i)
      break;
    end
    imcut = im(i-13:i+13,j-9:j+8);
    Cell.state(i,j) = -1;
    Cell.net(i,j) = sim(net,im2vec(imcut));   
    if Cell.net(i,j) < -0.95
      for u_=i-3:i+3
            for v_=j-3:j+3
                try
                  Cell.state(u_,v_)=-1;
                end
            end
      end      
      plot(j,i,'.k');pause(0.01);
      continue;
    elseif Cell.net(i,j) < -1*Threshold
      plot(j,i,'.m');pause(0.01);
      continue;
    elseif Cell.net(i,j) > 0.95
      plot(j,i,'.b');pause(0.01);
      for u_=i-13:i+13
            for v_=j-9:j+9
                try
                  Cell.state(u_,v_)=-1;
                end
            end
      end
    elseif Cell.net(i,j) > Threshold
      plot(j,i,'.g');pause(0.01);
    elseif Cell.net(i,j) < Threshold      
      plot(j,i,'.r');pause(0.01);                        
    end      
    for i_=-1:1
      for j_=-1:1
            m_=i+i_;                  
            n_=j+j_;            
            if (Cell.state(m_,n_) == -1 || Cell.net(m_,n_)~=-1)
                continue;
            end            
            imcut = im(m_-13:m_+13,n_-9:n_+8);
            Cell.net(m_,n_) = sim(net,im2vec(imcut));
            if Cell.net(m_,n_) > 0.95
                plot(n_,m_,'.b');pause(0.01);
                for u_=m_-13:m_+13
                  for v_=n_-9:n_+9
                        try
                            Cell.state(u_,v_)=-1;
                        end
                  end
                end
                continue;
            end         
            if Cell.net(m_,n_) > Threshold
                Cell.state(m_,n_) = 1;
                plot(n_,m_,'.g');pause(0.01);
                if (DEBUG == 1)
                  imwrite(imcut,);                     
                end
            else
                Cell.state(m_,n_) = -1;
                plot(n_,m_,'.r');pause(0.01);
                if (DEBUG == 1)
                  imwrite(imcut,);                     
                end
            end
      end
    end
end

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% Third Section
hold off
figure;imshow (Cell.net,[]);
xy_ = Cell.net > Threshold;
xy_ = imregionalmax(xy_);
xy_ = imdilate (xy_,strel('disk',2,4));
= bwlabeln(xy_,4);
CentroidMatrix = regionprops(LabelMatrix,'centroid');
xy_ = zeros(m,n);
for i = 1:nLabel
    xy_(fix(CentroidMatrix(i).Centroid(2)),...
         fix(CentroidMatrix(i).Centroid(1))) = 1;
end
xy_ = drawrec(xy_,);
im_out (:,:,1) = im;
im_out (:,:,2) = im;
im_out (:,:,3) = im;
for i = 1:m
    for j=1:n
      if xy_(i,j)==1
            im_out (i,j,1)=0;
            im_out (i,j,2)=255;
            im_out (i,j,3)=0;            
      end
    end
end

老马825 发表于 2018-6-26 19:49:05

太好了,谢谢

zqz921 发表于 2018-11-22 10:13:05

111111111111111111111111111111111111

183731577 发表于 2019-3-13 11:17:37

666666666666666666666666666
页: [1]
查看完整版本: 人脸检测