资源简介

HoG SVm 人脸识别方法, 做人脸识别的同学,可以研究一下

资源截图

代码片段和文件信息

function [ped] = classify_region(row col size img)
%UNtitleD2 Summary of this function goes here
%   Detailed explanation goes here
%disp(‘Classifying region... r c s‘);

region = zeros(14);
ped_ratio = 0.5;
h = size;
w = h*ped_ratio;

file = fopen(‘classifiers/svm_classifier.txt‘ ‘r‘);
ped = 0;
res = 0;
neg = 0;

region(11) = str2double(fscanf(file‘%s‘ 1));

    while (~feof(file) && neg==0)
       
        region(12) = str2double(fscanf(file‘%s‘ 1));
        region(13) = str2double(fscanf(file‘%s‘ 1));
        region(14) = str2double(fscanf(file‘%s‘ 1));

        SVM_name = fscanf(file ‘%s‘ 1);
        a = str2double(fscanf(file ‘%s‘ 1));
        structSVM = load (SVM_name);
        
        %DESNORMALIZE BLOCK in relation to REGION
        region(11)=region(11)*h;
        region(12)=region(12)*w;
        region(13)=region(13)*w;

        if(size>128)
           region(13) = ceil(region(13));
           if(mod(region(13)2) ~= 0)
               region(13) = region(13)-1;
           end
           region(12) = floor(region(12));
           region(11) = floor(region(11));
        elseif(size<128)
           region(13) = ceil(region(13));
           if(mod(region(13)2) ~= 0)
               region(13) = region(13)-1;
           end
           region(12) = ceil(region(12));
           region(11) = ceil(region(11));
        end

        % Feature block coordinates: r c s.
        r = (row-1)+region(11);
        c = (col-1)+region(12);
        s1 = region(13);
        s2 = region(13)*region(14);
        
       
        %Select only the image region / block we want to evaluate --> (r1:r2 c1:c2)
        I = img((r:(r+s1-1)) (c:(round(c+s2-1))));
                               
        plot=0;
        if(plot) 
            imshow(img);
            rectangle(‘Position‘[col row size*ped_ratio size] ‘LineWidth‘ 1 ‘EdgeColor‘ ‘b‘);
            rectangle(‘Position‘ [c r s2 s1] ‘LineWidth‘ 1 ‘EdgeColor‘ ‘r‘);
            pause()
            imshow(I)
            pause()
        end
        
        switch (region(14))
            case 1
                HOG = extractHOGFeatures(I ‘CellSize‘ [floor(length(I)/2) floor(length(I)/2)]);
            case 0.5
                HOG = extractHOGFeatures(I ‘CellSize‘ [floor(length(I)/2) floor(length(I)/4)]);
            case 2
                HOG = extractHOGFeatures(I ‘CellSize‘ [floor(length(I)/4) floor(length(I)/2)]);
            otherwise
                disp(‘WRONG ASPECT RATIO!‘)
        end
        
        %HOG = extractHOGFeatures(I ‘CellSize‘ [round(length(I)/2) round(length(I)/2)]); % 36-D vector
        %HOG = extractHOGFeatures(I ‘NumBins‘ 6 ‘BlockSIze‘ [3 3] ‘CellSize‘ [floor(length(I)/3) floor(length(I)/3)]

        weak_res = (svmclassify (structSVM.weak_svm HOG))*a; 
        res = res + weak_res;

        aux = str2double(fscanf(file ‘%s‘ 1));
        if(aux==999999)
            %disp(‘END OF STAGE‘);
            t = 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-06-10 09:16  hogsvm-master\
     目录           0  2014-06-10 09:16  hogsvm-master\HOG+TREE\
     目录           0  2014-06-10 09:16  hogsvm-master\HOG+TREE\classifiers\
     文件        1116  2014-06-10 09:16  hogsvm-master\HOG+TREE\classifiers\svm_classifier.txt
     文件        2548  2014-06-10 09:16  hogsvm-master\HOG+TREE\classifiers\training_results.txt
     文件      758449  2014-06-10 09:16  hogsvm-master\HOG+TREE\classifiers\weak_tree_11.mat
     文件      760158  2014-06-10 09:16  hogsvm-master\HOG+TREE\classifiers\weak_tree_12.mat
     文件      758437  2014-06-10 09:16  hogsvm-master\HOG+TREE\classifiers\weak_tree_21.mat
     文件      767419  2014-06-10 09:16  hogsvm-master\HOG+TREE\classifiers\weak_tree_22.mat
     文件      764484  2014-06-10 09:16  hogsvm-master\HOG+TREE\classifiers\weak_tree_31.mat
     文件      794183  2014-06-10 09:16  hogsvm-master\HOG+TREE\classifiers\weak_tree_32.mat
     文件      775521  2014-06-10 09:16  hogsvm-master\HOG+TREE\classifiers\weak_tree_41.mat
     文件      790006  2014-06-10 09:16  hogsvm-master\HOG+TREE\classifiers\weak_tree_42.mat
     文件      786421  2014-06-10 09:16  hogsvm-master\HOG+TREE\classifiers\weak_tree_51.mat
     文件      802000  2014-06-10 09:16  hogsvm-master\HOG+TREE\classifiers\weak_tree_52.mat
     文件      778448  2014-06-10 09:16  hogsvm-master\HOG+TREE\classifiers\weak_tree_61.mat
     文件      768193  2014-06-10 09:16  hogsvm-master\HOG+TREE\classifiers\weak_tree_62.mat
     文件        3414  2014-06-10 09:16  hogsvm-master\HOG+TREE\classify_region.m
     文件         823  2014-06-10 09:16  hogsvm-master\HOG+TREE\count_blocks.m
     文件        4375  2014-06-10 09:16  hogsvm-master\HOG+TREE\feature_extraction.m
     文件        3244  2014-06-10 09:16  hogsvm-master\HOG+TREE\learning.m
     文件        7567  2014-06-10 09:16  hogsvm-master\HOG+TREE\prepare_samples.m
     文件        1600  2014-06-10 09:16  hogsvm-master\HOG+TREE\runtime.m
     文件        2998  2014-06-10 09:16  hogsvm-master\HOG+TREE\sample_negatives.m
     文件        4063  2014-06-10 09:16  hogsvm-master\HOG+TREE\select_tree.m
     文件        1189  2014-06-10 09:16  hogsvm-master\HOG+TREE\test.m
     文件        1612  2014-06-10 09:16  hogsvm-master\HOG+TREE\test_neg.m
     文件        1193  2014-06-10 09:16  hogsvm-master\HOG+TREE\test_pos.m
     文件         917  2014-06-10 09:16  hogsvm-master\HOG+TREE\testing.m
     文件        4798  2014-06-10 09:16  hogsvm-master\HOG+TREE\train_cascade_ilevel.m
     文件        3402  2014-06-10 09:16  hogsvm-master\classify_region.m
............此处省略9个文件信息

评论

共有 条评论