Skip to content

Commit

Permalink
Merge pull request #462 from Nuzhny007/master
Browse files Browse the repository at this point in the history
Fix build face and pedestrian detectors with OpenCV 5.0
  • Loading branch information
Nuzhny007 authored Jan 29, 2025
2 parents 9d69ad1 + 6f0879d commit 515e8f3
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 22 deletions.
10 changes: 0 additions & 10 deletions src/Detector/BaseDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,12 @@ std::unique_ptr<BaseDetector> BaseDetector::CreateDetector(tracking::Detectors d
break;

case tracking::Face_HAAR:
#if (CV_VERSION_MAJOR < 5)
detector = std::make_unique<FaceDetector>(frame);
#else
std::cerr << "Haar detector was removed from OpenCV 5.0" << std::endl;
CV_Assert(0);
#endif
break;

case tracking::Pedestrian_HOG:
case tracking::Pedestrian_C4:
#if (CV_VERSION_MAJOR < 5)
detector = std::make_unique<PedestrianDetector>(frame);
#else
std::cerr << "HOG detector was removed from OpenCV 5.0" << std::endl;
CV_Assert(0);
#endif
break;

#ifdef USE_OCV_DNN
Expand Down
4 changes: 0 additions & 4 deletions src/Detector/FaceDetector.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "FaceDetector.h"

#if (CV_VERSION_MAJOR < 5)

///
/// \brief FaceDetector::FaceDetector
/// \param gray
Expand Down Expand Up @@ -59,5 +57,3 @@ void FaceDetector::Detect(const cv::UMat& gray)
m_regions.push_back(rect);
}
}

#endif //(CV_VERSION_MAJOR < 5)
6 changes: 4 additions & 2 deletions src/Detector/FaceDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

#include "BaseDetector.h"

#if (CV_VERSION_MAJOR < 5)
#if (CV_VERSION_MAJOR >= 5)
#include <opencv2/xobjdetect.hpp>
#endif //(CV_VERSION_MAJOR < 5)

///
/// \brief The FaceDetector class
///
Expand All @@ -25,4 +28,3 @@ class FaceDetector final : public BaseDetector
private:
cv::CascadeClassifier m_cascade;
};
#endif //(CV_VERSION_MAJOR < 5)
3 changes: 0 additions & 3 deletions src/Detector/PedestrianDetector.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "PedestrianDetector.h"
#include "nms.h"

#if (CV_VERSION_MAJOR < 5)

///
/// \brief PedestrianDetector::PedestrianDetector
/// \param gray
Expand Down Expand Up @@ -105,4 +103,3 @@ void PedestrianDetector::Detect(const cv::UMat& gray)
m_regions.push_back(rect);
}
}
#endif //(CV_VERSION_MAJOR < 5)
6 changes: 3 additions & 3 deletions src/Detector/PedestrianDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

#include "BaseDetector.h"

#if (CV_VERSION_MAJOR < 5)
#if (CV_VERSION_MAJOR >= 5)
#include <opencv2/xobjdetect.hpp>
#endif //(CV_VERSION_MAJOR < 5)

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

Expand Down Expand Up @@ -50,5 +52,3 @@ class PedestrianDetector final : public BaseDetector
static const int HUMAN_xdiv = 9;
static const int HUMAN_ydiv = 4;
};

#endif //(CV_VERSION_MAJOR < 5)

0 comments on commit 515e8f3

Please sign in to comment.