Skip to content

Commit 515e8f3

Browse files
authored
Merge pull request #462 from Nuzhny007/master
Fix build face and pedestrian detectors with OpenCV 5.0
2 parents 9d69ad1 + 6f0879d commit 515e8f3

File tree

5 files changed

+7
-22
lines changed

5 files changed

+7
-22
lines changed

src/Detector/BaseDetector.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,12 @@ std::unique_ptr<BaseDetector> BaseDetector::CreateDetector(tracking::Detectors d
5454
break;
5555

5656
case tracking::Face_HAAR:
57-
#if (CV_VERSION_MAJOR < 5)
5857
detector = std::make_unique<FaceDetector>(frame);
59-
#else
60-
std::cerr << "Haar detector was removed from OpenCV 5.0" << std::endl;
61-
CV_Assert(0);
62-
#endif
6358
break;
6459

6560
case tracking::Pedestrian_HOG:
6661
case tracking::Pedestrian_C4:
67-
#if (CV_VERSION_MAJOR < 5)
6862
detector = std::make_unique<PedestrianDetector>(frame);
69-
#else
70-
std::cerr << "HOG detector was removed from OpenCV 5.0" << std::endl;
71-
CV_Assert(0);
72-
#endif
7363
break;
7464

7565
#ifdef USE_OCV_DNN

src/Detector/FaceDetector.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#include "FaceDetector.h"
22

3-
#if (CV_VERSION_MAJOR < 5)
4-
53
///
64
/// \brief FaceDetector::FaceDetector
75
/// \param gray
@@ -59,5 +57,3 @@ void FaceDetector::Detect(const cv::UMat& gray)
5957
m_regions.push_back(rect);
6058
}
6159
}
62-
63-
#endif //(CV_VERSION_MAJOR < 5)

src/Detector/FaceDetector.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
#include "BaseDetector.h"
44

5-
#if (CV_VERSION_MAJOR < 5)
5+
#if (CV_VERSION_MAJOR >= 5)
6+
#include <opencv2/xobjdetect.hpp>
7+
#endif //(CV_VERSION_MAJOR < 5)
8+
69
///
710
/// \brief The FaceDetector class
811
///
@@ -25,4 +28,3 @@ class FaceDetector final : public BaseDetector
2528
private:
2629
cv::CascadeClassifier m_cascade;
2730
};
28-
#endif //(CV_VERSION_MAJOR < 5)

src/Detector/PedestrianDetector.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#include "PedestrianDetector.h"
22
#include "nms.h"
33

4-
#if (CV_VERSION_MAJOR < 5)
5-
64
///
75
/// \brief PedestrianDetector::PedestrianDetector
86
/// \param gray
@@ -105,4 +103,3 @@ void PedestrianDetector::Detect(const cv::UMat& gray)
105103
m_regions.push_back(rect);
106104
}
107105
}
108-
#endif //(CV_VERSION_MAJOR < 5)

src/Detector/PedestrianDetector.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
#include "BaseDetector.h"
44

5-
#if (CV_VERSION_MAJOR < 5)
5+
#if (CV_VERSION_MAJOR >= 5)
6+
#include <opencv2/xobjdetect.hpp>
7+
#endif //(CV_VERSION_MAJOR < 5)
68

79
#include "pedestrians/c4-pedestrian-detector.h"
810

@@ -50,5 +52,3 @@ class PedestrianDetector final : public BaseDetector
5052
static const int HUMAN_xdiv = 9;
5153
static const int HUMAN_ydiv = 4;
5254
};
53-
54-
#endif //(CV_VERSION_MAJOR < 5)

0 commit comments

Comments
 (0)