70
University of Ioannina - Department of Computer Science Christophoros Nikou [email protected] Image Analysis Images taken from: D. Forsyth and J. Ponce. Computer Vision: A Modern Approach, Prentice Hall, 2003. Computer Vision course by Kristen Grauman, University of Texas at Austin. Computer Vision course by Svetlana Lazebnik, University of North Carolina at Chapel Hill. Window-based face detection: The Viola-Jones algorithm

Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

University of Ioannina - Department of Computer Science

Christophoros [email protected]

Image Analysis

Images taken from:D. Forsyth and J. Ponce. Computer Vision: A Modern Approach, Prentice Hall, 2003.Computer Vision course by Kristen Grauman, University of Texas at Austin.Computer Vision course by Svetlana Lazebnik, University of North Carolina at Chapel Hill.

Window-based face detection:The Viola-Jones algorithm

Page 2: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

2

C. Nikou – Image Analysis (T-14)

Face detection and recognition

Page 3: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

3

C. Nikou – Image Analysis (T-14)

Face detection and recognition

Detection Recognition “Sally”

Page 4: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

4

C. Nikou – Image Analysis (T-14)

Consumer application: iPhoto 2009

http://www.apple.com/ilife/iphoto/

Page 5: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

5

C. Nikou – Image Analysis (T-14)

Consumer application: iPhoto 2009

It can be trained to recognize pets!

http://www.maclife.com/article/news/iphotos_faces_recognizes_cats

Page 6: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

6

C. Nikou – Image Analysis (T-14)

Consumer application: iPhoto 2009

iPhoto decides that this is a face

Page 7: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

7

C. Nikou – Image Analysis (T-14)

Outline

• Face recognition– Eigenfaces

• Face detection– The Viola and Jones algorithm.

P. Viola and M. Jones. Robust real-time face detection. International Journal of Computer Vision, 57(2), 2004. Also in CVPR 2001.

M. Turk and A. Pentland. "Eigenfaces for recognition". Journal of Cognitive Neuroscience, 3(1):71–86, 1991. Also in CVPR 1991.

Page 8: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

8

C. Nikou – Image Analysis (T-14)

Recognition by finding patterns

• We have seen very simple template matching methods (using filters).

• Some objects behave like quite simple templates – Frontal face images.

• Strategy:– Build/train model (supervised classifier).– Find image windows.– Correct lighting.– Pass them to a statistical test (a classifier) that

accepts faces and rejects non-faces with respect to the model.

Page 9: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

9

C. Nikou – Image Analysis (T-14)

Basic ideas in classifiers

• Loss: some errors may be more expensive than others

– e.g. a fatal disease that is easily cured by a cheap medicine with no side-effects

• false positives in diagnosis are better than false negatives

– We discuss two class classification: L(1 2) is the loss caused by calling 1 a 2.

• Total risk of strategy s is the total expected loss:

( ) Pr{1 2 | } (1 2) Pr{2 1| } (2 1)R s s L s L= → → + → →

• The optimal classifier minimizes the total risk.

Page 10: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

10

C. Nikou – Image Analysis (T-14)

Basic ideas in classifiers (cont.)

• Generally, we should classify as 1 if the expected loss of classifying as 2 is larger than calling a 2 a 1:

(1/ ) (1 2) (2 / ) (2 1)p x L p x L→ > →

• Equivalently, we should classify as 2 if(1/ ) (1 2) (2 / ) (2 1)p x L p x L→ < →

• Using Bayes rule:( /1) (1) (1 2) ( / 2) (2) (2 1)p x p L p x p L→ > →

( /1) (1) (1 2) ( / 2) (2) (2 1)p x p L p x p L→ < →

Page 11: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

11

C. Nikou – Image Analysis (T-14)

Basic ideas in classifiers (cont.)

• Crucial notion: Decision boundary– points where the average loss is the same for

either case.

(1 2) (2 1) 1,(1 1) (2 2) 0L LL L

→ = → =→ = → =

Page 12: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

12

C. Nikou – Image Analysis (T-14)

Basic ideas in classifiers (cont.)

• Some loss may be inevitable:− the total risk (shaded area) is called the

Bayes risk.

(1 2) (2 1) 1,(1 1) (2 2) 0L LL L

→ = → =→ = → =

Page 13: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

13

C. Nikou – Image Analysis (T-14)

Basic ideas in classifiers (cont.)

• Example: Gaussian class densities, p-dimensional measurements with common covariance Σ and different means μ1, μ2and class priors πk:

( ) ( ) ( )2 1 121 1/ exp

2 2

pT

k kp x k x xμ μπ

−− −⎛ ⎞ ⎡ ⎤= Σ − − Σ −⎜ ⎟ ⎢ ⎥⎝ ⎠ ⎣ ⎦

Page 14: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

14

C. Nikou – Image Analysis (T-14)

Basic ideas in classifiers (cont.)

• Ignoring a common factor in the posteriors:

( ) ( ) ( )2 1 121 1/ exp

2 2

pT

k k kp k x x xπ μ μπ

−− −⎛ ⎞ ⎡ ⎤∝ Σ − − Σ −⎜ ⎟ ⎢ ⎥⎝ ⎠ ⎣ ⎦

• The classifier boils down to choose the class minimizing

( ) ( )1 2logTk k kx xμ μ π−− Σ − −

• The common covariance simplifies the resulting expression.

Page 15: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

15

C. Nikou – Image Analysis (T-14)

Basic ideas in classifiers (cont.)

• Cross validation to estimate the total risk.−Split the data set and average over all possible

splits.− Leave-one-out, 10-fold,…

• Bootstrapping to estimate better the decision boundary.−Retrain the classifier with the false positives

(FP) and false negatives (FN).−They are the most significant in the

configuration of the decision boundary.

Page 16: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

16

C. Nikou – Image Analysis (T-14)

Histogram based classifiers

• Use a histogram to represent the class-conditional densities p(x|1), p(x|2),…

• Advantage: estimates become quite good with enough data.

• Disadvantage: Histogram becomes big with high dimension.

– we may assume feature independence.

Page 17: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

17

C. Nikou – Image Analysis (T-14)

Example: finding skin pixels

• Skin has a very small range of (intensity independent) colours and little texture.

• Get class conditional densities p(x|skin)and p(x|not skin) from examples.

• Get priors p(skin) and p(not skin) from examples

– count the number of face/non face pixels.• The classifier becomes:

Page 18: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

18

C. Nikou – Image Analysis (T-14)

• We can represent a class-conditional density using a histogram (a “non-parametric” distribution)

Feature x = Hue

P(x|skin)

Feature x = Hue

P(x|not skin)

Kristen Grauman

Example: finding skin pixels (cont.)

Page 19: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

19

C. Nikou – Image Analysis (T-14)

• We can represent a class-conditional density using a histogram (a “non-parametric” distribution)

Feature x = Hue

P(x|skin)

Feature x = Hue

P(x|not skin)Now we get a new image, and want to label each pixel as skin or non-skin.

Kristen Grauman

Example: finding skin pixels (cont.)

Page 20: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

20

C. Nikou – Image Analysis (T-14)

posterior priorlikelihood

Where does the prior come from?

Why use a prior?

Example: finding skin pixels (cont.)

Page 21: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

21

C. Nikou – Image Analysis (T-14)

For every pixel in a new image, we can estimate the probability that it is generated by skin.

Classify pixels based on these probabilities

Brighter pixels higher probability of being skin

Kristen Grauman

Example: finding skin pixels (cont.)

Page 22: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

22

C. Nikou – Image Analysis (T-14)

Using skin color-based face detection and pose estimation as a video-based interface. Open CV, Gary Bradski, 1998.

Kristen Grauman

Example: finding skin pixels (cont.)

Page 23: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

23

C. Nikou – Image Analysis (T-14)

Example: finding skin pixels (cont.)

• Parameter θ encapsulates the relative loss. There is a family of classifiers for each value of θ.

– Each one has different FP and FN rates described by the Receiver Operating Characteristic (ROC) curve.

Page 24: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

24

C. Nikou – Image Analysis (T-14)

Window-based generic object detection framework

• Build/train object model– Choose a representation.

– Learn or fit parameters of model / classifier.

• Generate candidates in new image.

• Score the candidates.

Page 25: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

25

C. Nikou – Image Analysis (T-14)

Simple holistic descriptions of image contentgrayscale / color histogramvector of pixel intensities

Window-based models:building a model

Page 26: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

26

C. Nikou – Image Analysis (T-14)

• Pixel-based representations sensitive to small shifts.

• Color or grayscale-based appearance description can be sensitive to illumination and intra-class appearance variation.

Window-based models:building a model (cont.)

Page 27: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

27

C. Nikou – Image Analysis (T-14)

• Consider edges, contours, and (oriented) intensity gradients.

Window-based models:building a model (cont.)

Page 28: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

28

C. Nikou – Image Analysis (T-14)

• Consider edges, contours, and (oriented) intensity gradients.

• Summarize local distribution of gradients with histogramLocally orderless: offers invariance to small shifts and rotationsContrast-normalization: try to correct for variable illumination

Window-based models:building a model (cont.)

Page 29: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

29

C. Nikou – Image Analysis (T-14)

Car/non-car Classifier

Yes, car.No, not a car.

• Given the representation, train a binary classifier.

Window-based models:building a model (cont.)

Page 30: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

30

C. Nikou – Image Analysis (T-14)

106 examples

Nearest neighbor

Shakhnarovich, Viola, Darrell 2003Berg, Berg, Malik 2005...

Neural networks

LeCun, Bottou, Bengio, Haffner 1998Rowley, Baluja, Kanade 1998 …

Support Vector Machines Conditional Random Fields

McCallum, Freitag, Pereira 2000; Kumar, Hebert 2003…

Guyon, VapnikHeisele, Serre, Poggio, 2001,…

Boosting

Viola, Jones 2001, Torralba et al. 2004, Opelt et al. 2006,…

Discriminative classifiers

Page 31: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

31

C. Nikou – Image Analysis (T-14)

Window-based generic object detection framework

• Build/train object model

– Choose a representation

– Learn or fit parameters of model / classifier

• Generate candidates in new image

• Score the candidates

Page 32: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

32

C. Nikou – Image Analysis (T-14)

Car/non-car Classifier

Window-based models:generating and scoring candidates

Page 33: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

33

C. Nikou – Image Analysis (T-14)

Car/non-car Classifier

Feature extraction

Training examples

Training:1. Obtain training data2. Define features3. Define classifier

Given new image:1. Slide window2. Score by classifier

Window-based models:Summary

Page 34: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

34

C. Nikou – Image Analysis (T-14)

106 examples

Nearest neighbor

Shakhnarovich, Viola, Darrell 2003Berg, Berg, Malik 2005...

Neural networks

LeCun, Bottou, Bengio, Haffner 1998Rowley, Baluja, Kanade 1998 …

Support Vector Machines Conditional Random Fields

McCallum, Freitag, Pereira 2000; Kumar, Hebert 2003…

Guyon, VapnikHeisele, Serre, Poggio, 2001,…

Boosting

Viola, Jones 2001, Torralba et al. 2004, Opelt et al. 2006,…

Discriminative classifiers

Page 35: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

35

C. Nikou – Image Analysis (T-14)

Boosting

• Boosting is a classification scheme that works by combining weak learners into a more accurate ensemble classifier

– A weak learner need only do better than chance.• Training consists of multiple boosting rounds

– During each boosting round, we select a weak learner that does well on examples that were hard for the previous weak learners.

– “Hardness” is captured by weights attached to training examples.

Y. Freund and R. Schapire, A short introduction to boosting, Journal of Japanese Society for Artificial Intelligence, 14(5):771-780, September, 1999.

Page 36: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

36

C. Nikou – Image Analysis (T-14)

Boosting intuition

Weak Classifier 1

Slide credit: Paul Viola

Page 37: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

37

C. Nikou – Image Analysis (T-14)

Boosting illustration

WeightsIncreased

Page 38: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

38

C. Nikou – Image Analysis (T-14)

Boosting illustration

Weak Classifier 2

Page 39: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

39

C. Nikou – Image Analysis (T-14)

Boosting illustration

WeightsIncreased

Page 40: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

40

C. Nikou – Image Analysis (T-14)

Boosting illustration

Weak Classifier 3

Page 41: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

41

C. Nikou – Image Analysis (T-14)

Boosting illustration

Final classifier is a combination of weak classifiers

Page 42: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

42

C. Nikou – Image Analysis (T-14)

• Initially, weight each training example equally.

• In each boosting round:– Find the weak learner that achieves the lowest weighted training error.

– Raise weights of training examples misclassified by current weak learner.

• Compute final classifier as linear combination of all weak learners (weight of each learner is directly proportional to its accuracy).

• Exact formulas for re-weighting and combining weak learners depend on the particular boosting scheme (e.g. AdaBoost).

Slide credit: Lana Lazebnik

Boosting: training

Page 43: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

43

C. Nikou – Image Analysis (T-14)

Boosting pros and cons

• Advantages of boosting– Integrates classification with feature selection.– Complexity of training is linear instead of quadratic in

the number of training examples.– Flexibility in the choice of weak learners, boosting

scheme.– Testing is fast.– Easy to implement.

• Disadvantages– Needs many training examples.– Often doesn’t work as well as SVM (especially for

many-class problems).

Page 44: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

44

C. Nikou – Image Analysis (T-14)

Challenges of face detection

• Sliding window detector must evaluate tens of thousands of location/scale combinations.

– PCA is slow for real time face detection.• Faces in images are rare: 0–10 per image

– For computational efficiency, we should try to spend as little time as possible on the non-face windows.

– A megapixel image has ~106 pixels and a comparable number of candidate face locations.

– To avoid having a false positive in every image, the false positive rate has to be less than 10-6.

Page 45: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

45

C. Nikou – Image Analysis (T-14)

The Viola/Jones Face Detector

• A seminal approach to real-time object detection.• Training is slow but detection is very fast.• Key ideas

– Represent local texture with efficiently computed rectangular features (integral images) within the window of interest.

– Select discriminative features as weak classifiers.– Boosting for classification.– Attentional cascade for fast rejection of non-face

windows.

P. Viola and M. Jones. Robust real-time face detection. International Journal of Computer Vision, 57(2), 2004. Also in CVPR 2001.

Page 46: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

46

C. Nikou – Image Analysis (T-14)

“Rectangular filters”

Output = ∑ (pixels in white area) – ∑ (pixels in black area)

Image features

Page 47: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

47

C. Nikou – Image Analysis (T-14)

Image features (cont.)

• For real problems, the result depends strongly on the features used.

• Do not employ pixel values.• Use a very large set of

simple functions• sensitive to edges and other

critical features• multiple scales.

Page 48: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

48

C. Nikou – Image Analysis (T-14)

Example

Page 49: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

49

C. Nikou – Image Analysis (T-14)

Fast computation with integral images

• The integral image computes a value at each pixel (x,y) that is the sum of the pixel values above and to the left of (x,y) inclusive.

• This can be quickly computed in one pass.

(x,y)

Page 50: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

50

C. Nikou – Image Analysis (T-14)

Computing the integral image

Page 51: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

51

C. Nikou – Image Analysis (T-14)

Computing the integral image

Cumulative row sum: s(x, y) = s(x–1, y) + i(x, y) Integral image: ii(x, y) = ii(x, y−1) + s(x, y)

ii(x, y-1)

s(x-1, y)

i(x, y)

MATLAB: ii = cumsum(cumsum(double(i)), 2);

Page 52: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

52

C. Nikou – Image Analysis (T-14)

Computing sum within a rectangle

• Let A,B,C,D be the values of the integral image at the corners of a rectangle.

• The sum of original image values within the rectangle can be computed as:

sum = A – B – C + D

• Only 3 additions are required for any size of rectangle!

D B

C A

Page 53: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

53

C. Nikou – Image Analysis (T-14)

Example

Integral Image

• Feature output is different between adjacent regions.

Page 54: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

54

C. Nikou – Image Analysis (T-14)

Feature selection

• The integral image significantly reduces the number of computations.

• However, for a base resolution of 24x24 detection region, the number of possible rectangle features is ~160,000! (scale, size, type, position,…)

• It is impractical to evaluate the entire feature set for training.

• Can we create a good classifier using just a small subset of all possible features?

• How to select such a subset?

Use AdaBoost both to select the informative features and to form the classifier.

Page 55: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

55

C. Nikou – Image Analysis (T-14)

• We seek to select the single rectangle feature and threshold that best separates positive (faces) and negative (non-faces) training examples, in terms of weighted error.

Outputs of a possible rectangle feature on faces and non-faces.

Resulting weak classifier:

For next round, reweight the examples according to errors, choose another filter/threshold combo.

Kristen Grauman

Boosting for face detection

Page 56: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

56

C. Nikou – Image Analysis (T-14)

AdaBoost AlgorithmStart with uniform weights on training examples

Evaluate weighted error for each feature, pick best.

Re-weight the examples:Incorrectly classified -> more weightCorrectly classified -> less weight

Final classifier is combination of the weak ones, weighted according to error they had.

Freund & Schapire 1995

{x1,…xn}For T rounds

Page 57: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

57

C. Nikou – Image Analysis (T-14)

Boosting for face detection (cont.)

• The first two features selected by boosting.

• This feature combination can yield 100% detection rate and 50% false positive rate.

Page 58: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

58

C. Nikou – Image Analysis (T-14)

Boosting for face detection

• A 200-feature classifier can yield 95% detection rate and a false positive rate of 1 over 14084.

Not good enough!

Page 59: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

59

C. Nikou – Image Analysis (T-14)

Attentional cascade

• Even if the filters are fast to compute, each new image has a lot of possible windows to search.

• How to make the detection more efficient?• There is no need to compute the linear

combination of all of the features in a window that is clear to be negative from the first features.

• Define a computational risk hierarchy.• The goal of the training process is different

– instead of minimizing classification errors minimize the false positive rate.

Page 60: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

60

C. Nikou – Image Analysis (T-14)

• Form a cascade with low false negative rates early on.

• Apply less accurate but faster classifiers first to immediately discard windows that clearly appear to be negative

Attentional cascade (cont.)

Page 61: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

61

C. Nikou – Image Analysis (T-14)

• Train with 5K positives, 350M negatives (10k non face images).

• Real-time detector using 38 layer cascade.• Implemented in OpenCV.

Faces

Non-faces

Train cascade of classifiers with

AdaBoost

Selected features, thresholds, and weights

New image

Viola-Jones detector: summary

Page 62: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

62

C. Nikou – Image Analysis (T-14)

Output of face detector on test images

Page 63: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

63

C. Nikou – Image Analysis (T-14)

Other detection tasks

Facial Feature Localization

Male vs. female

Profile Detection

Page 64: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

64

C. Nikou – Image Analysis (T-14)

Profile Detection

Page 65: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

65

C. Nikou – Image Analysis (T-14)

Profile Features

Page 66: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

66

C. Nikou – Image Analysis (T-14)

Application: Naming characters in TV video

M. Everingham, J. Sivic, and A. Zisserman."Hello! My name is... Buffy" - Automatic naming of characters in TV video.Proceedings of the 17th British Machine Vision Conference (BMVC 2006).

Page 67: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

67

C. Nikou – Image Analysis (T-14)

Application of sliding windows: pedestrian detection

C. Papageorgiou and T. Poggio. A Trainable System for Object Detection. International Journal of Cmputer Vision, Vol. 38, No 1, pp. 15-22, 2000.

SVM on Haar wavelets.

Page 68: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

68

C. Nikou – Image Analysis (T-14)

Application of sliding windows: pedestrian detection (cont.)

P. Viola, M. Jones and D. Snow. Detecting pedestrians using patterns of motion and appearance. International Journal of Computer Vision, Vol. 63, No 2, pp. 153-161, 2005.

Space-time rectangle features.

Page 69: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

69

C. Nikou – Image Analysis (T-14)

Application of sliding windows: pedestrian detection (cont.)

N. Dalal and B. Triggs. Histograms of oriented gradients for human detection. IEEE Conference on Computer Vision and Pattern Recognition (CVPR 2005).

SVM on histogram of oriented gradients.

Page 70: Image Analysis Window-based face detection: The Viola-Jones …cnikou/Courses/Image_Analysis/09_Face... · 2011. 5. 25. · −Split the data set and average over all possible splits

70

C. Nikou – Image Analysis (T-14)

Summary: Viola-Jones detector

• Rectangle features.• Integral images for fast computation.• Boosting for feature selection.• Attentional cascade for fast rejection of

negative windows.