Skip to content

Commit 9d593e7

Browse files
committed
Merge pull request opencv#8324 from sturkmen72:update_objectDetection_cpp
2 parents 6fe1898 + 50bda8a commit 9d593e7

File tree

3 files changed

+16
-106
lines changed

3 files changed

+16
-106
lines changed

doc/tutorials/objdetect/cascade_classifier/cascade_classifier.markdown

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ Code
1919

2020
This tutorial code's is shown lines below. You can also download it from
2121
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/objectDetection/objectDetection.cpp)
22-
. The second version (using LBP for face detection) can be [found
23-
here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/objectDetection/objectDetection2.cpp)
2422
@include samples/cpp/tutorial_code/objectDetection/objectDetection.cpp
2523

2624
Explanation
@@ -34,8 +32,8 @@ Result
3432

3533
![](images/Cascade_Classifier_Tutorial_Result_Haar.jpg)
3634

37-
Remember to copy the files *haarcascade_frontalface_alt.xml* and
38-
*haarcascade_eye_tree_eyeglasses.xml* in your current directory. They are located in
35+
Be sure the program will find the path of files *haarcascade_frontalface_alt.xml* and
36+
*haarcascade_eye_tree_eyeglasses.xml*. They are located in
3937
*opencv/data/haarcascades*
4038

4139
-# This is the result of using the file *lbpcascade_frontalface.xml* (LBP trained) for the face

samples/cpp/tutorial_code/objectDetection/objectDetection.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,25 @@ using namespace cv;
1313
void detectAndDisplay( Mat frame );
1414

1515
/** Global variables */
16-
String face_cascade_name = "haarcascade_frontalface_alt.xml";
17-
String eyes_cascade_name = "haarcascade_eye_tree_eyeglasses.xml";
16+
String face_cascade_name, eyes_cascade_name;
1817
CascadeClassifier face_cascade;
1918
CascadeClassifier eyes_cascade;
2019
String window_name = "Capture - Face detection";
2120

2221
/** @function main */
23-
int main( void )
22+
int main( int argc, const char** argv )
2423
{
24+
CommandLineParser parser(argc, argv,
25+
"{help h||}"
26+
"{face_cascade|../../data/haarcascades/haarcascade_frontalface_alt.xml|}"
27+
"{eyes_cascade|../../data/haarcascades/haarcascade_eye_tree_eyeglasses.xml|}");
28+
29+
cout << "\nThis program demonstrates using the cv::CascadeClassifier class to detect objects (Face + eyes) in a video stream.\n"
30+
"You can use Haar or LBP features.\n\n";
31+
parser.printMessage();
32+
33+
face_cascade_name = parser.get<string>("face_cascade");
34+
eyes_cascade_name = parser.get<string>("eyes_cascade");
2535
VideoCapture capture;
2636
Mat frame;
2737

@@ -30,7 +40,7 @@ int main( void )
3040
if( !eyes_cascade.load( eyes_cascade_name ) ){ printf("--(!)Error loading eyes cascade\n"); return -1; };
3141

3242
//-- 2. Read the video stream
33-
capture.open( -1 );
43+
capture.open( 0 );
3444
if ( ! capture.isOpened() ) { printf("--(!)Error opening video capture\n"); return -1; }
3545

3646
while ( capture.read(frame) )

samples/cpp/tutorial_code/objectDetection/objectDetection2.cpp

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)