Skip to content

Commit 3f609aa

Browse files
authored
Move objdetect HaarCascadeClassifier and HOGDescriptor to contrib xobjdetect (#3692)
* Move objdetect parts to contrib * Move objdetect parts to contrib * Fix errors from CI build. * Minor fixes.
1 parent 8f3a61b commit 3f609aa

File tree

150 files changed

+758910
-78
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+758910
-78
lines changed

modules/cudalegacy/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE)
99
ocv_module_include_directories(${CUDAToolkit_INCLUDE_DIRS})
1010
endif()
1111
ocv_define_module(cudalegacy opencv_core opencv_video
12-
OPTIONAL opencv_objdetect opencv_imgproc opencv_3d opencv_stereo opencv_calib opencv_cudaarithm opencv_cudafilters opencv_cudaimgproc)
12+
OPTIONAL opencv_objdetect opencv_xobjdetect opencv_imgproc opencv_3d opencv_stereo opencv_calib opencv_cudaarithm opencv_cudafilters opencv_cudaimgproc)

modules/cudalegacy/src/NCV.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,12 +737,12 @@ struct RectConvert
737737

738738
static void groupRectangles(std::vector<NcvRect32u> &hypotheses, int groupThreshold, double eps, std::vector<Ncv32u> *weights)
739739
{
740-
#ifndef HAVE_OPENCV_OBJDETECT
740+
#ifndef HAVE_OPENCV_XOBJDETECT
741741
CV_UNUSED(hypotheses);
742742
CV_UNUSED(groupThreshold);
743743
CV_UNUSED(eps);
744744
CV_UNUSED(weights);
745-
CV_Error(cv::Error::StsNotImplemented, "This functionality requires objdetect module");
745+
CV_Error(cv::Error::StsNotImplemented, "This functionality requires xobjdetect module");
746746
#else
747747
std::vector<cv::Rect> rects(hypotheses.size());
748748
std::transform(hypotheses.begin(), hypotheses.end(), rects.begin(), RectConvert());

modules/cudalegacy/src/cuda/NCVHaarObjectDetection.cu

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464

6565
#include "opencv2/opencv_modules.hpp"
6666

67-
#ifdef HAVE_OPENCV_OBJDETECT
68-
# include "opencv2/objdetect.hpp"
67+
#ifdef HAVE_OPENCV_XOBJDETECT
68+
# include "opencv2/xobjdetect.hpp"
6969
//# include "opencv2/objdetect/objdetect_c.h"
7070
#endif
7171

@@ -1843,16 +1843,16 @@ static NCVStatus loadFromXML(const cv::String &filename,
18431843
std::vector<HaarClassifierNode128> &haarClassifierNodes,
18441844
std::vector<HaarFeature64> &haarFeatures)
18451845
{
1846-
const char *CUDA_CC_SIZE = "size";
1847-
const char *CUDA_CC_STAGES = "stages";
1848-
const char *CUDA_CC_STAGE_THRESHOLD = "stage_threshold";
1849-
const char *CUDA_CC_TREES = "trees";
1850-
const char *CUDA_CC_FEATURE = "feature";
1851-
const char *CUDA_CC_RECT = "rects";
1852-
const char *CUDA_CC_TILTED = "tilted";
1853-
const char *CUDA_CC_THRESHOLD = "threshold";
1846+
const char *CUDA_CC_SIZE = "size";
1847+
const char *CUDA_CC_STAGES = "stages";
1848+
const char *CUDA_CC_STAGE_THRESHOLD = "stage_threshold";
1849+
const char *CUDA_CC_TREES = "trees";
1850+
const char *CUDA_CC_FEATURE = "feature";
1851+
const char *CUDA_CC_RECT = "rects";
1852+
const char *CUDA_CC_TILTED = "tilted";
1853+
const char *CUDA_CC_THRESHOLD = "threshold";
18541854
const char *CUDA_CC_LEFT_VAL = "left_val";
1855-
const char *CUDA_CC_RIGHT_VAL = "right_val";
1855+
const char *CUDA_CC_RIGHT_VAL = "right_val";
18561856
const char *CUDA_CC_LEFT_NODE = "left_node";
18571857
const char *CUDA_CC_RIGHT_NODE = "right_node";
18581858

@@ -1873,60 +1873,60 @@ static NCVStatus loadFromXML(const cv::String &filename,
18731873
haarClassifierNodes.resize(0);
18741874
haarFeatures.resize(0);
18751875

1876-
cv::FileStorage fs(filename, cv::FileStorage::READ | cv::FileStorage::FORMAT_XML);
1877-
1878-
if (!fs.isOpened())
1876+
cv::FileStorage fs(filename, cv::FileStorage::READ | cv::FileStorage::FORMAT_XML);
1877+
1878+
if (!fs.isOpened())
18791879
return NCV_FILE_ERROR;
18801880

1881-
const cv::FileNode &root = fs.getFirstTopLevelNode();
1881+
const cv::FileNode &root = fs.getFirstTopLevelNode();
18821882
const cv::FileNode &fnSize = root[CUDA_CC_SIZE];
18831883

18841884
// collect the cascade classifier window size
18851885
haar.ClassifierSize.width = (int)fnSize[CUDA_CC_SIZE_W];
18861886
haar.ClassifierSize.height = (int)fnSize[CUDA_CC_SIZE_H];
18871887
CV_Assert(haar.ClassifierSize.height > 0 && haar.ClassifierSize.width > 0);
18881888

1889-
const cv::FileNode &fnStages = root[CUDA_CC_STAGES];
1889+
const cv::FileNode &fnStages = root[CUDA_CC_STAGES];
18901890
cv::FileNodeIterator it = fnStages.begin(), it_end = fnStages.end();
18911891

1892-
for (; it != it_end; ++it) // by stages
1893-
{
1894-
cv::FileNode fnStage = *it;
1892+
for (; it != it_end; ++it) // by stages
1893+
{
1894+
cv::FileNode fnStage = *it;
18951895
HaarStage64 curStage;
18961896

1897-
curStage.setStartClassifierRootNodeOffset(static_cast<Ncv32u>(haarClassifierNodes.size()));
1897+
curStage.setStartClassifierRootNodeOffset(static_cast<Ncv32u>(haarClassifierNodes.size()));
18981898
curStage.setStageThreshold((float)fnStage[CUDA_CC_STAGE_THRESHOLD]);
18991899

1900-
// iterate over the trees
1901-
const cv::FileNode &fnTrees = fnStage[CUDA_CC_TREES];
1902-
cv::FileNodeIterator it1 = fnTrees.begin(), it1_end = fnTrees.end();
1903-
1904-
for (; it1 != it1_end; ++it1) // by trees
1905-
{
1906-
cv::FileNode tree = *it1;
1907-
Ncv32u nodeId = (size_t)0;
1908-
HaarClassifierNode128 curNode;
1909-
1910-
curNode.setThreshold((float)tree[0][CUDA_CC_THRESHOLD]);
1911-
1912-
NcvBool bIsLeftNodeLeaf = false;
1913-
NcvBool bIsRightNodeLeaf = false;
1914-
1900+
// iterate over the trees
1901+
const cv::FileNode &fnTrees = fnStage[CUDA_CC_TREES];
1902+
cv::FileNodeIterator it1 = fnTrees.begin(), it1_end = fnTrees.end();
1903+
1904+
for (; it1 != it1_end; ++it1) // by trees
1905+
{
1906+
cv::FileNode tree = *it1;
1907+
Ncv32u nodeId = (size_t)0;
1908+
HaarClassifierNode128 curNode;
1909+
1910+
curNode.setThreshold((float)tree[0][CUDA_CC_THRESHOLD]);
1911+
1912+
NcvBool bIsLeftNodeLeaf = false;
1913+
NcvBool bIsRightNodeLeaf = false;
1914+
19151915
HaarClassifierNodeDescriptor32 nodeLeft;
19161916

19171917
cv::FileNode leftNode = tree[0][CUDA_CC_LEFT_NODE];
19181918

19191919
if (leftNode.fs == NULL)
19201920
{
1921-
Ncv32f leftVal = tree[0][CUDA_CC_LEFT_VAL];
1922-
ncvStat = nodeLeft.create(leftVal);
1921+
Ncv32f leftVal = tree[0][CUDA_CC_LEFT_VAL];
1922+
ncvStat = nodeLeft.create(leftVal);
19231923
ncvAssertReturn(ncvStat == NCV_SUCCESS, ncvStat);
19241924
bIsLeftNodeLeaf = true;
19251925
}
19261926
else
19271927
{
1928-
Ncv32u leftNodeOffset = (int)tree[0][CUDA_CC_LEFT_NODE];
1929-
nodeLeft.create((Ncv32u)(h_TmpClassifierNotRootNodes.size() + leftNodeOffset - 1));
1928+
Ncv32u leftNodeOffset = (int)tree[0][CUDA_CC_LEFT_NODE];
1929+
nodeLeft.create((Ncv32u)(h_TmpClassifierNotRootNodes.size() + leftNodeOffset - 1));
19301930
haar.bHasStumpsOnly = false;
19311931
}
19321932

@@ -1937,15 +1937,15 @@ static NCVStatus loadFromXML(const cv::String &filename,
19371937

19381938
if (rightNode.fs == NULL)
19391939
{
1940-
Ncv32f rightVal = tree[0][CUDA_CC_RIGHT_VAL];
1941-
ncvStat = nodeRight.create(rightVal);
1940+
Ncv32f rightVal = tree[0][CUDA_CC_RIGHT_VAL];
1941+
ncvStat = nodeRight.create(rightVal);
19421942
ncvAssertReturn(ncvStat == NCV_SUCCESS, ncvStat);
19431943
bIsRightNodeLeaf = true;
19441944
}
19451945
else
19461946
{
1947-
Ncv32u rightNodeOffset = (int)tree[0][CUDA_CC_RIGHT_NODE];
1948-
nodeRight.create((Ncv32u)(h_TmpClassifierNotRootNodes.size() + rightNodeOffset - 1));
1947+
Ncv32u rightNodeOffset = (int)tree[0][CUDA_CC_RIGHT_NODE];
1948+
nodeRight.create((Ncv32u)(h_TmpClassifierNotRootNodes.size() + rightNodeOffset - 1));
19491949
haar.bHasStumpsOnly = false;
19501950
}
19511951

@@ -1955,9 +1955,9 @@ static NCVStatus loadFromXML(const cv::String &filename,
19551955
Ncv32u tiltedVal = (int)fnFeature[CUDA_CC_TILTED];
19561956
haar.bNeedsTiltedII = (tiltedVal != 0);
19571957

1958-
cv::FileNodeIterator it2 = fnFeature[CUDA_CC_RECT].begin(), it2_end = fnFeature[CUDA_CC_RECT].end();
1958+
cv::FileNodeIterator it2 = fnFeature[CUDA_CC_RECT].begin(), it2_end = fnFeature[CUDA_CC_RECT].end();
19591959

1960-
Ncv32u featureId = 0;
1960+
Ncv32u featureId = 0;
19611961
for (; it2 != it2_end; ++it2) // by feature
19621962
{
19631963
cv::FileNode rect = *it2;

modules/cudalegacy/src/precomp.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@
6363
# include "opencv2/objdetect.hpp"
6464
#endif
6565

66+
#ifdef HAVE_OPENCV_XOBJDETECT
67+
# include "opencv2/xobjdetect.hpp"
68+
#endif
69+
6670
#ifdef HAVE_OPENCV_3D
6771
# include "opencv2/3d.hpp"
6872
#endif

modules/cudaobjdetect/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ set(the_description "CUDA-accelerated Object Detection")
66

77
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 /wd4324 /wd4512 -Wundef -Wmissing-declarations -Wshadow -Wstrict-aliasing)
88

9-
ocv_define_module(cudaobjdetect opencv_objdetect opencv_cudaarithm opencv_cudawarping OPTIONAL opencv_cudalegacy WRAP python)
9+
ocv_define_module(cudaobjdetect opencv_objdetect opencv_xobjdetect opencv_cudaarithm opencv_cudawarping OPTIONAL opencv_cudalegacy WRAP python)

modules/cudaobjdetect/include/opencv2/cudaobjdetect.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#endif
4949

5050
#include "opencv2/core/cuda.hpp"
51-
#include "opencv2/objdetect.hpp"
51+
#include "opencv2/xobjdetect.hpp"
5252

5353
/**
5454
@addtogroup cuda
@@ -70,11 +70,11 @@ namespace cv { namespace cuda {
7070
7171
@note
7272
- An example applying the HOG descriptor for people detection can be found at
73-
opencv_source_code/samples/cpp/peopledetect.cpp
73+
xobjdetect_module/samples/peopledetect.cpp
7474
- A CUDA example applying the HOG descriptor for people detection can be found at
75-
opencv_source_code/samples/gpu/hog.cpp
75+
xobjdetect_module/samples/gpu/hog.cpp
7676
- (Python) An example applying the HOG descriptor for people detection can be found at
77-
opencv_source_code/samples/python/peopledetect.py
77+
xobjdetect_module/samples/python/peopledetect.py
7878
*/
7979
class CV_EXPORTS_W HOG : public Algorithm
8080
{
@@ -222,8 +222,8 @@ class CV_EXPORTS_W HOG : public Algorithm
222222
/** @brief Cascade classifier class used for object detection. Supports HAAR and LBP cascades. :
223223
224224
@note
225-
- A cascade classifier example can be found at
226-
opencv_source_code/samples/gpu/cascadeclassifier.cpp
225+
- A cascade classifier example can be found at
226+
xobjdetect_module/samples/gpu/cascadeclassifier.cpp
227227
- A Nvidea API specific cascade classifier example can be found at
228228
opencv_source_code/samples/gpu/cascadeclassifier_nvidia_api.cpp
229229
*/

modules/cudaobjdetect/perf/perf_precomp.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
#include "opencv2/ts/cuda_perf.hpp"
4747

4848
#include "opencv2/cudaobjdetect.hpp"
49-
#include "opencv2/objdetect.hpp"
49+
#include "opencv2/xobjdetect.hpp"
5050

5151
namespace opencv_test { using namespace perf; }
5252

modules/cudaobjdetect/src/precomp.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#include "opencv2/cudaobjdetect.hpp"
4949
#include "opencv2/cudaarithm.hpp"
5050
#include "opencv2/cudawarping.hpp"
51-
#include "opencv2/objdetect.hpp"
51+
#include "opencv2/xobjdetect.hpp"
5252

5353
#include "opencv2/core/private.cuda.hpp"
5454
#include "opencv2/core/utility.hpp"

modules/cudaobjdetect/test/test_precomp.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#include "opencv2/ts/cuda_test.hpp"
4949

5050
#include "opencv2/cudaobjdetect.hpp"
51-
#include "opencv2/objdetect.hpp"
51+
#include "opencv2/xobjdetect.hpp"
5252

5353
#include "cvconfig.h"
5454

modules/face/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
set(the_description "Face recognition etc")
22
ocv_define_module(face opencv_core
33
opencv_imgproc
4-
opencv_objdetect
4+
opencv_xobjdetect
55
opencv_3d # estimateAffinePartial2D() (trainFacemark)
66
opencv_photo # seamlessClone() (face_swap sample)
77
WRAP python java objc

0 commit comments

Comments
 (0)