2014-11-27 20:39:05 +08:00
|
|
|
Cascade Classifier {#tutorial_cascade_classifier}
|
|
|
|
==================
|
|
|
|
|
|
|
|
Goal
|
|
|
|
----
|
|
|
|
|
|
|
|
In this tutorial you will learn how to:
|
|
|
|
|
|
|
|
- Use the @ref cv::CascadeClassifier class to detect objects in a video stream. Particularly, we
|
|
|
|
will use the functions:
|
2014-11-28 00:54:13 +08:00
|
|
|
- @ref cv::CascadeClassifier::load to load a .xml classifier file. It can be either a Haar or a LBP classifer
|
|
|
|
- @ref cv::CascadeClassifier::detectMultiScale to perform the detection.
|
2014-11-27 20:39:05 +08:00
|
|
|
|
|
|
|
Theory
|
|
|
|
------
|
|
|
|
|
|
|
|
Code
|
|
|
|
----
|
|
|
|
|
|
|
|
This tutorial code's is shown lines below. You can also download it from
|
2018-05-31 21:45:18 +08:00
|
|
|
[here](https://github.com/opencv/opencv/tree/3.4/samples/cpp/tutorial_code/objectDetection/objectDetection.cpp)
|
2016-07-18 21:32:05 +08:00
|
|
|
@include samples/cpp/tutorial_code/objectDetection/objectDetection.cpp
|
2014-11-27 20:39:05 +08:00
|
|
|
|
|
|
|
Explanation
|
|
|
|
-----------
|
|
|
|
|
|
|
|
Result
|
|
|
|
------
|
|
|
|
|
2014-11-28 21:21:28 +08:00
|
|
|
-# Here is the result of running the code above and using as input the video stream of a build-in
|
2014-11-27 20:39:05 +08:00
|
|
|
webcam:
|
|
|
|
|
2014-11-28 21:21:28 +08:00
|
|
|
![](images/Cascade_Classifier_Tutorial_Result_Haar.jpg)
|
2014-11-27 20:39:05 +08:00
|
|
|
|
2017-01-19 17:17:53 +08:00
|
|
|
Be sure the program will find the path of files *haarcascade_frontalface_alt.xml* and
|
|
|
|
*haarcascade_eye_tree_eyeglasses.xml*. They are located in
|
2014-11-27 20:39:05 +08:00
|
|
|
*opencv/data/haarcascades*
|
|
|
|
|
2014-11-28 21:21:28 +08:00
|
|
|
-# This is the result of using the file *lbpcascade_frontalface.xml* (LBP trained) for the face
|
2014-11-27 20:39:05 +08:00
|
|
|
detection. For the eyes we keep using the file used in the tutorial.
|
|
|
|
|
2014-11-28 21:21:28 +08:00
|
|
|
![](images/Cascade_Classifier_Tutorial_Result_LBP.jpg)
|