parent
d9f68235d0
commit
facaf8f4cf
|
@ -4,14 +4,14 @@ title: "Deep Learning Haar Cascade Explained"
|
||||||
subtitle: ""
|
subtitle: ""
|
||||||
description: "翻译"
|
description: "翻译"
|
||||||
excerpt: "这是我认为最通俗易懂的 Haar 级联分类器的解释说明,文末视频非常形象。"
|
excerpt: "这是我认为最通俗易懂的 Haar 级联分类器的解释说明,文末视频非常形象。"
|
||||||
date: 2020-03-04 14:42:00
|
date: 2020-11-24 11:26:00
|
||||||
author: "Rick Chan"
|
author: "Rick Chan"
|
||||||
tags: ["AI", "Classifier", "Haar"]
|
tags: ["AI", "Classifier", "Haar"]
|
||||||
categories: ["Algorithm"]
|
categories: ["Algorithm"]
|
||||||
published: true
|
published: true
|
||||||
---
|
---
|
||||||
|
|
||||||
[原文连接]<http://www.willberger.org/cascade-haar-explained/>
|
[原文连接](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?”
|
“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?”
|
||||||
|
|
||||||
|
@ -23,9 +23,9 @@ Haar 级联分类器的背后思想以及其现实应用实在令人倍感惊奇
|
||||||
|
|
||||||
Haar 级联分类器是一种机器学习算法,最初由 Paul Viola 和 Michael Jones 在 2001 年的论文《Rapid Object Detection using a Boosted Cascade of Simple Features》中提出。该算法能够通过特征来识别图像或视频中的物体。
|
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.”
|
“It is a machine learning based approach where a cascade function is trained from a lot of positive[a] and negative[a] images. It is then used to detect objects in other images.”
|
||||||
|
|
||||||
通过 positive images(包含检测目标的样本) 和 negative images(不包含检测目标的样本)样本集进行训练的级联分类器,能够检测其他图像中的目标物体。
|
通过阳性 images(包含检测目标的样本)[a] 和阴性 images(不包含检测目标的样本)[a]样本集进行训练的级联分类器,能够检测其他图像中的目标物体。
|
||||||
|
|
||||||
“The algorithm has four stages:
|
“The algorithm has four stages:
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ 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.”
|
“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 来训练分类器。然后我们从其中提取特征。
|
本文以人脸检测为例。首先需要大量包含人脸的阳性 image 和不包含人脸的阴性 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.”
|
“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.”
|
||||||
|
|
||||||
|
@ -77,15 +77,70 @@ Haar 级联分类器最著名的应用是检测图像中的人脸或身体,但
|
||||||
|
|
||||||
![Integral Images](./img/Deep_Learning_Haar_Cascade_Explained/003.png)
|
![Integral Images](./img/Deep_Learning_Haar_Cascade_Explained/003.png)
|
||||||
|
|
||||||
“The cascade classifier[a] consists of a collection of stages, where each stage is an ensemble of weak learners. The weak learners are simple classifiers called decision stumps. Each stage is trained using a technique called boosting. Boosting provides the ability to train a highly accurate classifier by taking a weighted average of the decisions made by the weak learners.”
|
“The cascade classifier[b] consists of a collection of stages, where each stage is an ensemble of weak learners. The weak learners are simple classifiers called decision stumps. Each stage is trained using a technique called boosting. Boosting provides the ability to train a highly accurate classifier by taking a weighted average of the decisions made by the weak learners.”
|
||||||
|
|
||||||
级联分类器[a]由一系列小的阶段组成,每个阶段就是一个弱学习过程。弱学习过程是一个被称作单层分类器的简单分类器。每个阶段由 boosting 算法进行训练。通过对每个阶段的决策进行加权,Boosting 提供了训练高准确度分类器的方法。
|
级联分类器[b]由一系列小的阶段组成,每个阶段就是一个弱学习过程。弱学习过程是一个被称作单层分类器的简单分类器。每个阶段由 boosting 算法进行训练。通过对每个阶段的决策进行加权,Boosting 提供了训练高准确度分类器的方法。
|
||||||
|
|
||||||
“Each stage of the classifier labels the region defined by the current location of the sliding window as either positive or negative. Positive indicates that an object was found and negative indicates no objects were found. If the label is negative, the classification of this region is complete, and the detector slides the window to the next location. If the label is positive, the classifier passes the region to the next stage. The detector reports an object found at the current window location when the final stage classifies the region as positive.”
|
“Each stage of the classifier labels the region defined by the current location of the sliding window as either positive or negative. Positive indicates that an object was found and negative indicates no objects were found. If the label is negative, the classification of this region is complete, and the detector slides the window to the next location. If the label is positive, the classifier passes the region to the next stage. The detector reports an object found at the current window location when the final stage classifies the region as positive.”
|
||||||
|
|
||||||
每个阶段的分类器对滑动窗口的当前区域打标签(positive 或 negative)。Positive 意味着检测到了目标,negative 意味着没有检测到目标。如果没有检测到目标则完成当前区域的检测,滑动窗口移动到下一个区域。如果检测结果为 positive,则分类器将当前区域传递给下一个阶段继续进行检测。当所有检测阶段都返回 positive,那么检测器报告在当前位置发现了目标物。
|
每个阶段的分类器对滑动窗口的当前区域打标签(阳性 或 阴性)。阳性意味着检测到了目标,阴性意味着没有检测到目标。如果没有检测到目标则完成当前区域的检测,滑动窗口移动到下一个区域。如果检测结果为阳性,则分类器将当前区域传递给下一个阶段继续进行检测。当所有检测阶段都返回阳性,那么检测器报告在当前位置发现了目标物。
|
||||||
|
|
||||||
“The stages are designed to reject negative samples as fast as possible. The assumption is that the vast majority of windows do not contain the object of interest. Conversely, true positives are rare and worth taking the time to verify.”
|
“The stages are designed to reject negative samples as fast as possible. The assumption is that the vast majority of windows do not contain the object of interest. Conversely, true positives are rare and worth taking the time to verify.
|
||||||
|
|
||||||
|
* A true positive occurs when a positive sample is correctly classified.
|
||||||
|
* A false positive occurs when a negative sample is mistakenly classified as positive.
|
||||||
|
* A false negative occurs when a positive sample is mistakenly classified as negative.”
|
||||||
|
|
||||||
|
所有的阶段都被设计为能够快速的滤除阴性采样。这是因为我们假设大部分的滑动窗口不包含待检测目标。相反,真阳性比较稀少,值得多花费一些时间去处理。
|
||||||
|
|
||||||
|
* 真阳性:是指被正确分类的阳性采样。
|
||||||
|
* 假阳性:是指被错误分类的阴性采样。
|
||||||
|
* 假阴性:是指被错误分类的阳性采样。
|
||||||
|
|
||||||
|
“To work well, each stage in the cascade must have a low false negative rate. If a stage incorrectly labels an object as negative, the classification stops, and you cannot correct the mistake. However, each stage can have a high false positive rate. Even if the detector incorrectly labels a nonobject as positive, you can correct the mistake in subsequent stages. Adding more stages reduces the overall false positive rate, but it also reduces the overall true positive rate.”
|
||||||
|
|
||||||
|
为了保证好的检测效果,级联分类器每个阶段的假阴性率必须非常低。如果某个目标(阳性采样)被错误的识别为阴性,那么检测就会停止,我们再也没有机会去纠正这个错误了。然而,每个阶段的假阳性率可以比较高,甚至可以将不包含目标的标记为阳性,因为可以在下一个阶段中纠正这个错误。增加处理阶段将降低假阳性率,同时也会降低真阳性率。
|
||||||
|
|
||||||
|
“Cascade classifier training requires a set of positive samples and a set of negative images. You must provide a set of positive images with regions of interest specified to be used as positive samples. You can use the Image Labeler to label objects of interest with bounding boxes. The Image Labeler outputs a table to use for positive samples. You also must provide a set of negative images from which the function generates negative samples automatically. To achieve acceptable detector accuracy, set the number of stages, feature type, and other function parameters.“
|
||||||
|
|
||||||
|
训练级联分类器需要一组阳性采样和一组阴性采样图像。可以提供一组包含感兴趣区的阳性图像作为阳性采样。使用 Image Labeler 标记由包围盒框选的目标。Image Labeler 输出阳性采样标签。同时,还需要一组阴性图像,算法函数将自动生成阴性采样。为了达到可接受的精度,需要设置级联深度,特征类型和其他参数。
|
||||||
|
|
||||||
|
![Integral Images](./img/Deep_Learning_Haar_Cascade_Explained/004.png)
|
||||||
|
|
||||||
|
“The video below shows this in action.“
|
||||||
|
|
||||||
|
下面的视频展示了以上所述的检测过程。
|
||||||
|
|
||||||
|
## Haar Cascade - Facial Detection IN ACTION
|
||||||
|
|
||||||
|
“If a picture is worth a thousand words this would be a million words. This is where it all comes together. The Ahh-hah moment.”
|
||||||
|
|
||||||
|
“This simple video helped crystalize for me how this algorithm works. Here are some observations:
|
||||||
|
|
||||||
|
* Notice how the algorithm moves the window systematically over the image, applying the Haar features as it is trying to detect the face. This is depicted by the green rectangles.
|
||||||
|
* Notice underneath the red boundary square, we see the classifier executing stages quickly discarding window frames that are clearly not a match (stages 1-25)
|
||||||
|
* To the right of the stage we see the how well it performed in identifying the face.
|
||||||
|
* Notice as it gets closer and closer to identifying the face, the number of stages increases into the 20s. (around the 1 minute mark). This demonstrates the cascading effect where the early stages are discarding the input as it has identified them as irrelevant. As it gets closer to finding a face it pays closer attention.”
|
||||||
|
|
||||||
|
![Integral Images](./img/Deep_Learning_Haar_Cascade_Explained/005.gif)
|
||||||
|
|
||||||
|
[点击查看原始视频](https://www.youtube.com/watch?v=hPCTwxF0qf4&feature=youtu.be)
|
||||||
|
|
||||||
|
“Let me know if you have any questions or have any comments below.”
|
||||||
|
|
||||||
|
“I want to make sure I got this post right. It will be critical that you understand this before we go into the next section where we will implement a full Custom Object Haar Cascade detector.”
|
||||||
|
|
||||||
|
## Next Steps
|
||||||
|
|
||||||
|
“I don't know about you, but I find the best way to understand something is by doing it. Conceptually we now have an idea for how the machine learning Haar Cascade object detection works. Now lets build a real world custom Object Detector, train it, and see it in action. I have a really cool example for us! Click on the button below.”
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
1. Wikipedia, Wikipedia. “AdaBoost.” Wikipedia, Wikimedia Foundation, 13 Jan. 2018, en.wikipedia.org/wiki/AdaBoost.
|
||||||
|
2. Docs, OpenCV. “Face Detection Using Haar Cascades.” OpenCV: Face Detection Using Haar Cascades, 4 Aug. 2017, docs.opencv.org/3.3.0/d7/d8b/tutorial_py_face_detection.html.
|
||||||
|
3. Wikipedia, Wikipedia. “Viola–Jones object detection framework.” Wikipedia, Wikimedia Foundation, 4 November. 2017, en.wikipedia.org/wiki/Viola–Jones_object_detection_framework.
|
||||||
|
4. Wikipedia, Wikipedia. “Cascading Classifiers.” Wikipedia, Wikimedia Foundation, 15 October. 2013, en.wikipedia.org/wiki/Cascading_classifiers.
|
||||||
|
5. Mathworks, Mathworks. “Train a Cascade Object Detector” Mathworks, 2017, www.mathworks.com/help/vision/ug/train-a-cascade-object-detector.html.
|
||||||
|
|
||||||
## 原文标注
|
## 原文标注
|
||||||
|
|
||||||
|
@ -107,7 +162,11 @@ Haar 级联分类器最著名的应用是检测图像中的人脸或身体,但
|
||||||
|
|
||||||
## 译注
|
## 译注
|
||||||
|
|
||||||
[4] Cascade Classifier
|
[a] positive and negative
|
||||||
|
|
||||||
|
指阳性(positive)或阴性(negative),包含待检测目标的为阳性,不包含待检测目标的为阴性。检测结果可能出现假阳性或假阴性,是指检测出现了错误,相反则为真阳性或真阴性。
|
||||||
|
|
||||||
|
[b] Cascade Classifier
|
||||||
|
|
||||||
级联分类器是将一些小的分类过程组合成完整分类器的方法。以下图为例,需要将图中的“+”和“-”数据分开,仅靠一个分类过程很难实现。
|
级联分类器是将一些小的分类过程组合成完整分类器的方法。以下图为例,需要将图中的“+”和“-”数据分开,仅靠一个分类过程很难实现。
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
Binary file not shown.
After Width: | Height: | Size: 8.2 MiB |
Loading…
Reference in New Issue