7.9 KiB
Executable File
layout | title | subtitle | description | excerpt | date | author | tags | categories | published | ||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
post | Deep Learning Haar Cascade Explained | 翻译 | 这是我认为最通俗易懂的 Haar 级联分类器的解释说明,文末视频非常形象。 | 2020-03-04 14:42:00 | Rick Chan |
|
|
true |
[原文连接]http://www.willberger.org/cascade-haar-explained/
“Alright! This is where we start having some fun! The concept behind the Haar Cascade and how it is used in the real world is nothing short of amazing. So what is it?”
Haar 级联分类器的背后思想以及其现实应用实在令人倍感惊奇。
Haar cascade
“Haar Cascade is a machine learning object detection algorithm used to identify objects in an image or video and based on the concept of features proposed by Paul Viola and Michael Jones in their paper "Rapid Object Detection using a Boosted Cascade of Simple Features" in 2001.“
Haar 级联分类器是一种机器学习算法,最初由 Paul Viola 和 Michael Jones 在 2001 年的论文《Rapid Object Detection using a Boosted Cascade of Simple Features》中提出。该算法能够通过特征来识别图像或视频中的物体。
“It is a machine learning based approach where a cascade function is trained from a lot of positive and negative images. It is then used to detect objects in other images.”
通过 positive images(包含检测目标的样本) 和 negative images(不包含检测目标的样本)样本集进行训练的级联分类器,能够检测其他图像中的目标物体。
“The algorithm has four stages:
- Haar[1] Feature Selection
- Creating Integral Images[2]
- Adaboost[3] Training
- Cascading Classifiers“
Haar 级联分类器主要有四个步骤:
- Haar 特征选择
- 创建积分图
- Adaboost 训练
- 级联各个分类器
“It is well known for being able to detect faces and body parts in an image, but can be trained to identify almost any object.”
Haar 级联分类器最著名的应用是检测图像中的人脸或身体,但其实也可以检测其他物体。
“Lets take face detection as an example. Initially, the algorithm needs a lot of positive images of faces and negative images without faces to train the classifier. Then we need to extract features from it.”
本文以人脸检测为例。首先需要大量包含人脸的 positive image 和不包含人脸的 negative image 来训练分类器。然后我们从其中提取特征。
“First step is to collect the Haar Features. A Haar feature considers adjacent rectangular regions at a specific location in a detection window, sums up the pixel intensities in each region and calculates the difference between these sums. ”
第一步是收集 Haar 特征。可以将 Haar 特征看作检测窗口中相邻的举行区域,将各自区域的像素强度加合,然后计算它们的差值。
“Integral Images are used to make this super fast.”
可以使用积分图加快这一运算过程。
“But among all these features we calculated, most of them are irrelevant. For example, consider the image below. Top row shows two good features. The first feature selected seems to focus on the property that the region of the eyes is often darker than the region of the nose and cheeks. The second feature selected relies on the property that the eyes are darker than the bridge of the nose. But the same windows applying on cheeks or any other place is irrelevant. ”
但是,这些特征中的很大一部分是与任务目标不相关的(没有意义的特征)。以下图为例,应用第一行的选择窗口可以得到两个好的特征:选取第一个特征,主要是由于眼部区域通常比鼻子和脸颊更黑;选取第二个特征则依赖于眼部比鼻梁更黑这一现象。但是,将同样的检测窗口应用于脸颊或其他部位则得不到有意义的特征。
“So how do we select the best features out of 160000+ features? This is accomplished using a concept called Adaboost which both selects the best features and trains the classifiers that use them. This algorithm constructs a “strong” classifier as a linear combination of weighted simple “weak” classifiers. The process is as follows.”
在人脸检测这样的任务中,特征总数足有 160000 多个,如何从中选取最有意义的特征?这由 Adaboost 算法完成,该算法会选取最佳特征并训练分类器来使用这些特征。Adaboost 算法引入了强分类器和弱分类器的概念,强分类器由弱分类器线性组合而成。其算法过程如下:
“During the detection phase, a window of the target size is moved over the input image, and for each subsection of the image and Haar features are calculated. You can see this in action in the video below. This difference is then compared to a learned threshold that separates non-objects from objects. Because each Haar feature is only a "weak classifier" (its detection quality is slightly better than random guessing) a large number of Haar features are necessary to describe an object with sufficient accuracy and are therefore organized into cascade classifiers to form a strong classifier.”
标注
[1] Haar
“A Haar-like feature considers adjacent rectangular regions at a specific location in a detection window, sums up the pixel intensities in each region and calculates the difference between these sums.“
“This difference is then used to categorize subsections of an image. For example, let us say we have an image database with human faces. It is a common observation that among all faces the region of the eyes is darker than the region of the cheeks. Therefore a common Haar feature for face detection is a set of two adjacent rectangles that lie above the eye and the cheek region. The position of these rectangles is defined relative to a detection window that acts like a bounding box to the target object (the face in this case).“
[2] Integral Images
“An integral image is summed-area table is a data structure and algorithm for quickly and efficiently generating the sum of values in a rectangular subset of a grid. To understand this look at image 1 and image 2. Image 1 is the source table, Image 2 is the summation table. Notice in Image 2 row 1, col 2 value 33 is sum of Image 1 row 1 (col 1 + col 2).“
[3] Adaboost
“Problems in machine learning often suffer from the curse of dimensionality — each sample may consist of a huge number of potential features (for instance, there can be 162,336 Haar features, as used by the Viola–Jones object detection framework, in a 24×24 pixel image window), and evaluating every feature can reduce not only the speed of classifier training and execution, but in fact reduce predictive power, per the Hughes Effect.[3] Unlike neural networks and SVMs, the AdaBoost training process selects only those features known to improve the predictive power of the model, reducing dimensionality and potentially improving execution time as irrelevant features need not be computed.“
参考资料
人脸检测之Haar分类器
What’s the Difference Between Haar-Feature Classifiers and Convolutional Neural Networks?
Computer Vision — Detecting objects using Haar Cascade Classifier
Deep Learning Haar Cascade Explained
浅析人脸检测之Haar分类器方法:Haar特征、积分图、AdaBoost、级联