Rapid Object Detection using a Boosted Cascade of Simple Features
- Publication
- CVPR 2001Conference
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@inproceedings{objectdetectionviolajones2001,
title = {{Rapid Object Detection using a Boosted Cascade of Simple Features}},
author = {Paul Viola and Michael Jones},
year = {2001},
booktitle = {CVPR},
url = {https://doi.org/10.1109/CVPR.2001.990517},
doi = {10.1109/CVPR.2001.990517}
}
Plenty of people wrote their first face detector with an XML file that ships with OpenCV. Create a cv2.CascadeClassifier, load haarcascade_frontalface_default.xml, call detectMultiScale on a grayscale image, and out comes a list of face boxes.
Open that XML, and the comment at the top reads "Stump-based 24x24 discrete(?) adaboost frontal face detector", signed Rainer Lienhart. The question mark in the parentheses is in the original (even the person who signed it wasn't quite sure). The 24×24 window, the decision tree with a single split (a stump) and AdaBoost all come from this paper by Paul Viola and Michael Jones.
The paper's system processes 15 grayscale images of 384×288 per second on a 700 MHz Pentium III. It doesn't look at skin color, nor does it subtract consecutive frames to find moving regions; a single grayscale image is all it uses. Its detection rate is about the same as the best methods of the time, and it runs roughly 15 times faster than the Rowley neural-network detector, then considered the fastest.
There are three reasons it's fast. A feature that only compares the brightness of rectangles; an image representation that turns the pixel sum of any rectangle into four table lookups; and a cascade of classifiers that knocks the vast majority of background windows out in the first stage or two. All three can be worked through by hand on a single 24×24 window.
Defining the Problem
Hundreds of Thousands of Windows in One Image
The detector in this paper can answer only one question, whether the 24×24 square in front of it is a frontal face. To find faces in a whole photo, you have to place that square at every position and scale it to every size, asking one window at a time. This is the sliding window.
By the paper's scanning rules, how many times do you have to ask for one 384×288 image? The window starts at 24 pixels and grows by 1.25× each time; at 279 pixels it is already close to the image's short side, for 12 scales in total. At the smallest scale the window shifts 1 pixel at a time, and at scale it shifts pixels, rounded. Adding up the positions over the 12 scales gives about 260,000 windows (this note's estimate). The MIT+CMU dataset the paper actually tests on has 130 images; 75,081,800 windows were scanned in total, and they contain just 507 faces.
That's one face in every 150,000 windows. This ratio dictates two things the detector has to be able to do.
First, every window has to be cheap. At 15 images per second, each image gets only 67 milliseconds; split among tens to hundreds of thousands of windows, each window gets time on the order of microseconds.
Second, the false-positive rate has to be absurdly low. Suppose a classifier makes one mistake for every 14,084 background windows. That sounds accurate, but on MIT+CMU it means false positives, 41 per image on average. To get down to just a few dozen false positives on the whole test set, the per-window false-positive rate has to be pushed below .
This 1/14,084 is the result of the paper's own first classifier. That classifier used 200 features, had a detection rate of 95%, and took 0.7 seconds to scan a 384×288 image. The most direct way to make it more accurate is to add features, but every added feature is one more computation for every window.
Other methods of the time were stuck between these two demands as well. The neural network of Rowley, Baluja and Kanade judges every window in turn; to speed it up, they trained a separate, coarser network to screen out some positions first. The statistical model of Schneiderman and Kanade has a high detection rate, but runs at one six-hundredth of this paper's speed. Some systems narrowed the search with skin color or frame differences first, which requires color images or video.
So the paper has to answer two questions at once. How can the features for each window cost almost no time? And since the vast majority of windows are obviously background at a glance, can they be spared from running the whole classifier?
Solving the Problem
Rectangle Features

The detector doesn't look at pixels directly; it looks at differences in brightness between rectangles. A feature's value is the pixel sum inside the gray rectangles (stippled in the figure) minus the pixel sum inside the white rectangles.
- Two-rectangle features (A, B): two rectangles of the same size, adjacent horizontally or vertically. They respond to edges, such as a boundary that is dark above and bright below.
- Three-rectangle features (C): the middle block minus the two sides. They respond to thin bright or dark bars, such as the bridge of the nose.
- Four-rectangle features (D): the sum of two diagonal blocks minus the sum of the other two.
These features resemble the basis functions of Haar wavelets; the paper calls them Haar-like features, later usually shortened to Haar features. Unlike true Haar basis functions, they don't have to be orthogonal to each other, and the rectangles can be any size and sit anywhere in the window.
How many such features fit in a 24×24 window? Let's count the side-by-side two-rectangle features.
Let each small rectangle be wide and tall, so the whole feature is wide and tall. can go from 1 to 12 and from 1 to 24. Something wide has horizontal positions in a window 24 cells wide, and something tall has vertical positions. Adding everything up:
The vertically stacked two-rectangle features also number 43,200. A three-rectangle feature is wide, with from 1 to 8, so the horizontal positions sum to ; times 300, that's 27,600, and the same again for the vertical ones. A four-rectangle feature is wide and tall, giving .
The five shapes add up to 162,336. The paper says over 180,000; Robust Real-Time Face Detection, the journal version the authors published three years later in IJCV 2004, says 160,000, closer to this count. The journal version fills in many details more completely, and it is cited along the way below as well. Whichever number you take, it is far more than the window's 576 pixels; there are two to three hundred times as many features as pixels.
With this many features, each one needs the pixel sums inside its rectangles. A 12×24 rectangle has 288 pixels, and adding them up by brute force takes 288 additions.
The Integral Image: Four Lookups

At each position , the integral image stores the sum of all pixels above and to the left of it, itself included:
is the original image, with going right and going down, both counted from 0. Take on the right of the figure; it is the top-left block, .
The whole integral image can be computed in a single pass. The paper uses two recurrences:
is the sum of column accumulated from the top down to row , with boundary values and . Try it once on . , the cell to its left is , and adding them gives 25, matching the figure. Each pixel takes only two additions.
With the integral image, the sum of any rectangle needs only its four corners. Let the rectangle cover and :
is everything above and to the left of the bottom-right corner. Subtract the strip above the rectangle (, just outside the top-right corner), then the strip to its left (, just outside the bottom-left corner). The block at the top left has now been subtracted twice, so is added back.
The blue box in the figure covers from 1 to 3, and adding its nine pixels directly gives 50. The lookup is . The paper numbers these four corners 1 to 4 and writes it as .
Whether the rectangle is 3×3 or 300×300, it takes four lookups. The two blocks of a two-rectangle feature are adjacent and share two corners, so it needs only 6 lookups; a three-rectangle feature needs 8 and a four-rectangle feature 9.
The integral image brings one more benefit. A feature takes the same number of lookups at any scale, so to find large faces you simply scale up the detector's rectangle coordinates, without shrinking the image. The journal version measured that on the same 700 MHz computer, just shrinking an image into a 12-level pyramid takes 0.05 seconds, about as long as the whole detector takes to process an image.
Lighting has to be handled too. The same face photographed in shadow and in bright light can give rectangle differences several times apart. Every training window is variance-normalized first, and the same has to be done at detection time. The variance of a window is
is the number of pixels in the window and is the mean. The mean can be looked up in the original image's integral image, and the sum of squares comes from the integral image of a second, "squared" image, so scanning keeps two integral images on hand. Normalization doesn't actually have to change every pixel either; once a feature value is computed, it is multiplied by a coefficient determined by .
AdaBoost: One Feature at a Time
The features are fast to compute now, but 160,000 of them are still too many. The paper's hypothesis is that a very small subset of them is enough to make a good classifier; the hard part is finding which ones.
The authors' approach is to restrict AdaBoost's weak classifiers to looking at a single feature, an idea that comes from Tieu and Viola's work on image retrieval in 2000. (In the conference version archived by MERL, that reference still reads "Anonymous. Anonymous. In Anonymous, 2000." from double-blind review; the real names were only filled in in the journal version.)
The single-feature weak classifier is written as
is a 24×24 window, is the value of the -th feature, is a threshold, and sets the direction of the inequality. An output of 1 means "face."
Take a concrete feature (ignoring brightness normalization for now). On a 24×24 face, take two horizontal bands of 18×4 = 72 pixels each, the upper one covering the eyes and the lower one the cheeks; the feature value is the upper band minus the lower band. If a face's eyes average a gray level of 70 and its cheeks 120, the feature value is ; on a uniform wall the two bands are about equally bright, and the value is close to 0. With and , the face falls below the threshold and gets an output of 1, and the wall gets 0. If the feature were defined as the lower band minus the upper band, the sign would flip; change to and the decision is exactly the same.
In each round, AdaBoost finds the best for each of the 160,000 features, then picks the one with the lowest weighted error. The whole procedure goes like this.
Initialization. With negatives and positives, the weights are set to
Positives and negatives each get half of the total weight. With the paper's final training data, the positives are 4,916 faces plus their mirror images, 9,832 in all, each weighted ; the 10,000 negatives are each weighted .
Each round :
-
Normalize the weights into a probability distribution, .
-
For each feature , train a single-feature classifier , with weighted error
-
Pick the with the lowest error, and call its error .
-
Update the weights:
Correctly classified samples have , and their weights are multiplied by ; misclassified ones have , and their weights stay the same.
The final strong classifier is a weighted vote:
where .
The weight update is clearer with numbers. Suppose the feature picked in the first round has error (the paper says the features picked early have errors between 0.1 and 0.3); then .
The correctly classified samples held 0.9 of the total weight, and multiplied by 1/9 they hold 0.1. The misclassified samples stay at 0.1. After normalization, each side holds half.
In other words, under the new weights the feature just picked has an error of exactly 0.5, no better than guessing. The next round won't pick it again; it will look for a feature that gets right the samples this one got wrong. Each round patches the holes the previous one left.
The vote weight is . Suppose the feature picked in the second round has error 0.2, so . The two votes total 3.58, and the threshold is half of that, 1.79:
- if both say face, , and it's a face;
- if only the first says so, , and it's a face;
- if only the second says so, , and it's background.
The more accurate the feature, the louder its voice. (The base of the log doesn't matter, since the threshold is a sum in the same base.)
Each round has to find the best threshold for each of the 160,000 features, and the journal version describes how. Sort all samples by the value of the feature and scan once from smallest to largest, keeping four numbers along the way: the total positive weight , the total negative weight , and the positive weight and negative weight below the current position. With the threshold placed at the current position, the error is
The first term is the error of "everything below is negative, everything above is positive," the second that of the reverse; taking the smaller one also decides . Even so, the journal version's 38-stage detector took weeks to train on a 466 MHz AlphaStation, cut to about a day only after it was later parallelized.
The first two features AdaBoost picks look like this:

The first feature compares the band around the eyes with the cheeks below, relying on the eyes usually being darker than the cheeks. This feature is large relative to the window, so it still registers when the face is a bit off-center or a bit bigger. The second feature compares the two eyes with the bridge of the nose between them; the eyes are darker than the bridge of the nose.
Out of 160,000 features, the algorithm found on its own two rules a person grasps at a glance.
The Attentional Cascade: Most Windows See Only Two Features
The paper says the 200-feature classifier is already "probably faster than any other published system," scanning an image in 0.7 seconds. But as worked out above, its false-positive rate is still about two orders of magnitude short, and adding features makes it slower.
The authors came at it from another angle. If a window is a wall, you don't need 200 features to know it isn't a face; two are enough.
Take the AdaBoost classifier built from the first two features and lower its threshold. AdaBoost's default threshold is set to minimize training error; lowered, it calls more things faces. On a validation set, the paper lowered the threshold until it caught 100% of the faces, at the cost of letting 40% of the background through as well. Seen the other way, 60% of the background windows are thrown out at this stage, at a cost of only about 60 processor instructions per window.
Then many such classifiers are chained together:

Each stage is an AdaBoost classifier with its threshold lowered so that it almost never misses a face. If any stage says "no," the window is out on the spot and the later stages aren't computed at all; only a window every stage says "yes" to is a face. The paper calls this an attentional cascade, because it works like focusing the computation's attention on the few suspicious locations.
Why does this achieve a high detection rate and a low false-positive rate at the same time? The journal version writes it as two products. Suppose the cascade has stages, and on the samples that pass the earlier stages, stage has false-positive rate and detection rate :
As long as each stage lets 30% of the background through and catches 99% of the faces, chaining 10 stages gives
The demand on each stage is very loose. A 99% detection rate sounds hard, but with 30% false positives allowed at the same time it is much easier. After multiplying through, the detection rate drops only to about 90%, while the false-positive rate drops by five orders of magnitude.
Put back on MIT+CMU's 75 million windows and there are still 443 false positives. The final detector kept adding stages, up to 38, until false positives on the validation set were nearly zero.
Speed can be worked out too. The average number of features computed per window is
is the number of features in stage and is the fraction stage lets through. Because faces are extremely rare, the pass fraction is nearly equal to that stage's false-positive rate. In the final version in the journal paper, stage 1 has 2 features and throws out about 50% of the background, and stage 2 has 10 features and throws out another 80%. The first two terms come to features; after these two stages only of the windows remain, and the cost of all 36 later stages is first multiplied by this 0.1. Measured on MIT+CMU, each window computes 8 features on average, out of 6,060 features in all.
The journal version also ran a clean comparison. On one side is a single 200-feature classifier; on the other, a cascade of ten 20-feature classifiers, with the same total number of features. Their ROC curves nearly overlap, and the cascade is almost 10 times faster.
Each Stage Trains on the Earlier Stages' Mistakes
How is the cascade trained? The journal version writes it as a double loop. The user first decides the maximum false-positive rate allowed per stage, the minimum detection rate per stage, and the overall target false-positive rate .
- Add a stage and train it with AdaBoost, starting from 1 feature.
- Measure the whole cascade's and on the validation set, and lower this stage's threshold until the detection rate is at least times that of the previous stage.
- If the false-positive rate hasn't yet dropped to times that of the previous stage, add another feature and go back to step 2.
- Once this stage meets its targets, run the current cascade over a large batch of images with no faces, collect the windows wrongly judged to be faces, and use them as the negatives for the next stage.
- If the overall false-positive rate is still above , go back to step 1.
Step 4 decides what each stage learns. Stage 1's negatives are cut at random from images with no faces, mostly background you can dismiss at a glance, such as sky and walls. The negatives stage 2 sees are all ones stage 1 failed to stop; those stage 10 sees are ones the first 9 stages all misjudged. The later the stage, the more its negatives look like faces; the paper says this pushes each later stage's whole ROC curve down, so the same detection rate has to tolerate more false positives. That is also why the feature counts keep growing further along, from 2, 10, 25 and 50 to an average of nearly 190 over the last 31 stages (this note's estimate).
In later terminology, this procedure is hard negative mining. The journal version also points out a hidden benefit. A single large classifier can take ten thousand to a hundred thousand negatives at most before it becomes impossible to train; the last few stages of a cascade in effect learn from the few thousand hardest windows sifted out of hundreds of millions of background windows.
The final detector looks like this.
- Positives: 4,916 faces hand-labeled in photos crawled at random from the web, scaled and aligned to 24×24, plus mirror images for 9,832 in all. The journal version adds how they were cropped: the top of the box above the eyebrows, the bottom halfway between the mouth and the chin, then the whole box enlarged by 50%. The authors tried a tighter-cropped 16×16 version, which did slightly worse; they speculate that the 24×24 crop takes in more of the chin, the cheek contours and the hairline.
- Negatives: 9,544 images manually checked to contain no faces, holding about 350 million sub-windows. The first stage samples from them at random; each later stage collects at most 10,000 false positives of the cascade before it.
- Structure: 38 stages, the first five with 1, 10, 25, 25 and 50 features, 6,061 in all.
The journal version's numbers differ slightly, with 2 features in the first stage, 6,060 in all and at most 6,000 negatives collected per stage; the cascade figure above uses the journal version's numbers. The authors are also blunt about it. How many features each stage gets was found by trial and error, with manual intervention in the first 7 stages; the final number of stages and the size of each are not critical to the final performance.
Scanning and Merging
At detection time the detector slides over the image, scaling up by 1.25× each time, with the shift growing with scale; at scale it moves pixels ( is rounding). The paper's main results use ; changing it to 1.5 is a good deal faster, with only a slight loss of accuracy.
Around the same face, shifted by a few pixels or scaled up a little, the detector usually still says face, so several boxes pile up on one face. The paper puts overlapping boxes into the same group and outputs one box per group, with each of its four corners averaged over the group.
The paper also tried voting. Three similar detectors were trained, keeping only results at least two of them agree on. The three detectors' errors are highly correlated, so this brought only a small improvement.
Discussion
Results on MIT+CMU
The test data is the MIT+CMU frontal face test set, 130 images with 507 faces. This dataset has no single agreed "score"; each paper reports only the detection rate at some number of false positives, so the authors read their own ROC curve at the false-positive counts each of the others reported, to make comparison easy.

The horizontal axis is the "number" of false positives over the whole test set; to turn it into a rate, divide by the 75,081,800 windows scanned. The way the curve is drawn also has to do with the cascade. The final stage's threshold is adjusted first; setting it to negative infinity amounts to removing that stage, and pushing the detection and false-positive rates higher still means removing more stages.
The table below gives the detection rate at several false-positive counts.
| False positives | VJ | VJ voting | Rowley |
|---|---|---|---|
| 10 | 76.1% | 81.1% | 83.2% |
| 31 | 88.4% | 89.7% | 86.0% |
| 50 | 91.4% | 92.1% | – |
| 65 | 92.0% | 93.1% | – |
| 78 | 92.1% | 93.1% | – |
| 95 | 92.9% | 93.2% | 89.2% |
| 167 | 93.9% | 93.7% | 90.1% |
Compiled from Table 2 of the paper. VJ is this paper's 38-stage detector; Rowley gives the results of the various Rowley–Baluja–Kanade versions.
With only 10 false positives allowed, Rowley's 83.2% beats the single detector's 76.1%, and the voting version is still 2 percentage points behind. From 31 false positives up, VJ beats Rowley all the way. Two other systems report only a single point. Schneiderman–Kanade reaches 94.4% at 65 false positives, higher than VJ's 92.0%; Roth–Yang–Ahuja reaches 94.8% at 78 false positives, but on a subset with the 5 images of line-drawn faces removed, which the journal version specifies as 125 images and 483 faces.
So the paper chooses its words with restraint, claiming detection rates "comparable" to the best previous systems. Where this paper wins is speed.
Speed
With a starting scale of 1.25 and , a 384×288 image takes about 0.067 seconds on a 700 MHz Pentium III, or 15 images per second. That setting gives about 65,000 windows (this note's estimate), roughly 1 microsecond per window on average. The paper says this is about 15 times faster than Rowley–Baluja–Kanade and about 600 times faster than Schneiderman–Kanade.
The authors also ported it to a Compaq iPaq handheld. Its 200 MIPS StrongARM processor has no floating-point unit, and the detector still ran at 2 images per second.
Where It Fails
The conference version says only that this is a detector for frontal, upright faces. The journal version adds a section on failure modes.
- Angle: the authors observe that it tolerates only about ±15° of in-plane rotation and ±45° of turning toward profile, and becomes unreliable beyond that. The training faces were only roughly aligned, and this bit of tolerance comes from those untidy samples.
- Backlighting: it often fails when the face is very dark and the background very bright. A nonlinear normalization that leaves out extreme values helps somewhat, but within the integral-image framework the computation goes up sharply.
- Occlusion: it usually misses faces with the eyes covered and usually still finds faces with the mouth covered. This fits with the first two features both looking at the eyes.
The authors also own up to a theoretical gap. AdaBoost's training and generalization guarantees hold for its original threshold; whether they still hold after each stage's threshold is lowered, the authors say, is unclear.
The Copy in OpenCV
The Viola–Jones most people actually use is OpenCV's implementation with models trained by Rainer Lienhart, which is not the same detector as the paper's.
haarcascade_frontalface_default.xml also uses a 24×24 window, with 25 stages and 2,913 stumps in total, each stump looking at a single feature; the first stage uses 9 features, increasing stage by stage to around two hundred. The other common one, haarcascade_frontalface_alt.xml, uses a 20×20 window and Gentle AdaBoost, with 22 stages and 2,135 features. Lienhart and Maydt extended the features to rectangles tilted at 45° in 2002, and OpenCV's training tool supports them, but both default models use only upright rectangles.
OpenCV's detection pipeline also differs from the paper in two places.
- It shrinks the image, not the detector.
detectMultiScaledownscales the image for each scale and keeps the detector at a fixed size. The defaultscaleFactor=1.1is denser than the paper's 1.25; at scales below 2 the window moves 2 pixels at a time, and 1 pixel after that (on the downscaled image). - Merging takes a vote. Overlapping boxes are clustered and averaged, but a cluster with fewer than
minNeighborsboxes (default 3) is thrown away outright. The paper only averages, with no threshold.
So when OpenCV gives too many false positives, the first thing to tune is minNeighbors; when it misses small faces, look at minSize and scaleFactor.
The defaults of the training tool opencv_traincascade are a minimum hit rate of 0.995 per stage, a maximum false-alarm rate of 0.5 and 20 stages. Its documentation cites the products from Section 4.1 of the journal version directly, for an overall hit rate of about and a false-alarm rate of about . The tool has been disabled since OpenCV 4.0, and the documentation tells users to go back to the 3.4 branch to train.
On photos from the web, it struggles. In 2015 WIDER FACE used OpenCV's Viola–Jones as one of its baselines. WIDER FACE's test set is split into three subsets, Easy, Medium and Hard, graded roughly by face height, with Hard taking in small faces of 11 to 30 pixels; scores are AP, the area under the curve of precision against recall, with a maximum of 1. Viola–Jones's AP on the three subsets is 0.412, 0.333 and 0.137; on small, unoccluded faces 10 to 50 pixels tall it is only 0.040. LearnOpenCV compared several of OpenCV's and Dlib's face detectors in 2018. Its verdict on the Haar cascade listed many false positives, no use at all on profile faces and no use under occlusion either, and it concluded that it was "time to bid farewell to Haar-based face detector."
OpenCV 5.0 was released in June 2026, and CascadeClassifier and the whole set of haarcascade XMLs have moved from the main library to the xobjdetect module of opencv_contrib (merged into the 5.x branch in March 2024). The official 4-to-5 migration guide recommends that new projects switch to FaceDetectorYN in the main module, which is based on a deep network.
Conclusion
Viola–Jones is fast because it lets the background go as early as possible. Across MIT+CMU's 75 million windows, each window computed only 8 to 10 features on average (8 in the journal version, 10 in the conference version), leaving almost all of the 6,000-plus features to the very few face-like locations. The integral image makes each feature a handful of lookups, AdaBoost picks one feature per round, and the cascade trains later stages on the false positives of earlier ones. Detection rates are comparable to the best systems of its time, and speed is more than an order of magnitude higher.
Access gates, kiosks and similar setups, with the camera facing straight on, steady lighting and one frontal face at a time, are exactly the conditions the paper trained for, and haarcascade_frontalface_default.xml still holds up there. Switch to group photos snapped on a phone, with profiles, backlighting and sunglasses over the eyes, and the failure modes the journal version itself lists show up one by one, and switching to a deep-learning detector saves a lot of trouble. When a project upgrades to OpenCV 5, the Haar cascade needs contrib installed separately, and what the main module has ready is FaceDetectorYN.
The cascade idea has outlived the Haar features. MTCNN in 2016 chains three CNNs of different sizes, and the smallest sweeps the image pyramid first to stop most positions, again letting the cheap classifier speak first.