Viola–Jones object detection[1][7]
包含下列四個步驟
- 1. Haar Feature Selection
- 2. Creating an Integral Image
- 3. Adaboost Training
- 4. Cascading Classifiers
MATLAB File Exchange有Viola-Jones的改良版,
主要增加Haar Like Feature的核心(kernel)選擇不同
請先下載
Objects/Faces Detection Toolbox
>> mex -setup
Welcome to mex -setup. This utility will help you set up
a default compiler. For a list of supported compilers, see
http://www.mathworks.com/support/compilers/R2012b/win64.html
Please choose your compiler for building MEX-files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler:
[1] Microsoft Visual C++ 2010 in C:\Program Files (x86)\Microsoft Visual Studio 10.0
[0] None
Compiler: 1
Please verify your choices:
Compiler: Microsoft Visual C++ 2010
Location: C:\Program Files (x86)\Microsoft Visual Studio 10.0
Are these correct [y]/n? y
--------------------------------------------------------------------
>> setup_fdt
Unzipping negatives picts ...
Compile mex files ...
compiling chlbp
compiling chlbp_adaboost_binary_train_cascade
compiling chlbp_adaboost_binary_predict_cascade
compiling chlbp_gentleboost_binary_train_cascade
compiling chlbp_gentleboost_binary_predict_cascade
compiling detector_haar
compiling detector_mblbp
compiling eval_chlbp
compiling eval_haar
compiling eval_haar_subwindow
compiling eval_mblbp
compiling eval_mblbp_subwindows
compiling haar
compiling haar_ada_weaklearner
compiling haar_adaboost_binary_train_cascade
compiling haar_adaboost_binary_predict_cascade
compiling haar_featlist
compiling haar_gentle_weaklearner
compiling haar_gentleboost_binary_train_cascade
compiling haar_gentleboost_binary_predict_cascade
compiling haar_scale
compiling imresize
compiling area
compiling homkermap
compiling homkertable
compiling eval_hmblbp_spyr_subwindow
compiling detector_mlhmslbp_spyr
compiling eval_hmblgp_spyr_subwindow
compiling detector_mlhmslgp_spyr
compiling mblbp
compiling mblbp_ada_weaklearner
compiling mblbp_adaboost_binary_train_cascade
compiling mblbp_adaboost_binary_predict_cascade
compiling mblbp_featlist
compiling mblbp_gentle_weaklearner
compiling mblbp_gentleboost_binary_train_cascade
compiling mblbp_gentleboost_binary_predict_cascade
compiling rgb2gray
compiling fast_rotate
compiling haar_ada_weaklearner_memory
compiling haar_adaboost_binary_predict_cascade_memory
compiling haar_adaboost_binary_train_cascade_memory
compiling haar_gentle_weaklearner_memory
compiling haar_gentleboost_binary_predict_cascade_memory
compiling haar_gentleboost_binary_train_cascade_memory
compiling int8tosparse
compiling fast_haar_ada_weaklearner
compiling fast_haar_adaboost_binary_train_cascade
compiling train_dense
Failed to compile mex-files, unzip precompiled mex64
Error using checkfilename>validateFilename (line 166)
Function UNZIP was unable to find file ''mexw64.zip''.
Error in checkfilename (line 50)
[fullfilename, fid] = validateFilename( ...
Error in parseUnArchiveInputs (line 82)
[archiveFilename, url] = checkfilename(archiveFilename, validExtensions, ...
Error in unzip (line 58)
[zipFilename, outputDir, url, urlFilename] = parseUnArchiveInputs( ...
Error in setup_fdt (line 80)
unzip('mexw64.zip' , conf.path);
--------------------------------------------------------------------
demo_haar.m
clear, close all,clc,drawnow
load viola_24x24
載入後觀察X, y毫無頭緒,
根據兩者維度推測, 嘗試 imshow(X(:,:,1))
原來裡面塞了一堆faces
imshow(X(:,:,2))
>> plot(y)
各位看了這個下面這張圖想必猜得出來1~4915筆前的資料是一群,
4916~12788筆的資料是另一群
>> imshow(X(:,:,4917))
真的是non-face, BINGO!!!
特徵擷取
A: Dims=1x2, kernelA=[-1, 1];
B: Dims=2x1, kernelB=[1; –1];
C: Dims=1x3, kernelC=[-1, 1, –1];
D: Dims=2x2, kernelD=[-1, 1; 1 –1];
private static int CalCounts(int frameSize)
{
const int features = 5;
// All five feature types:
// { width, height} for each set
int[,] feature = new int[features, 2]{ { 2, 1 }, { 1, 2 }, { 3, 1 }, { 1, 3 }, { 2, 2 } };
int count = 0;
int i, sizeX, sizeY, x, y, width, height;
// Each feature:
for (i = 0; i < features; i++) {
sizeX = feature[i,0];
sizeY = feature[i,1];
// Each position:
for (x = 0; x <= frameSize-sizeX; x++) {
for (y = 0; y <= frameSize-sizeY; y++) {
// Each size fitting within the frameSize:
for (width = sizeX; width <= frameSize-x; width+=sizeX) {
for (height = sizeY; height <= frameSize-y; height+=sizeY) {
count++;
}
}
}
}
}
return count;
}
Integral Image
An Extended Set of Haar-like Features for Rapid Object Detection[6]
增加特徵提高準確率!
特徵長度加總竟然比Viola-Jones還少 117, 941 < 162,336
-----------------------------------------------------------------------------------
參考資料
1. Rapid Object Detection using a Boosted Cascade of Simple Features
2. integral
3. MATLAB Objects/Faces Detection Toolbox
4. MATLAB traincascadeobjectdetector
5. Viola-Jones' face detection claims 180k features
6. An Extended Set of Haar-like Features for Rapid Object Detection
留言列表