From eda124ec32436505c72721c136681d069e7d8764 Mon Sep 17 00:00:00 2001
From: Vladislav Vinogradov <vlad.vinogradov@itseez.com>
Date: Thu, 11 Apr 2013 12:51:00 +0400
Subject: [PATCH] removed gpuobjdetect module

---
 modules/gpu/CMakeLists.txt                    |   2 +-
 modules/gpu/doc/gpu.rst                       |   1 +
 .../doc/object_detection.rst                  |   0
 modules/gpu/include/opencv2/gpu.hpp           | 121 +++++++++++-
 .../perf/perf_objdetect.cpp                   |   0
 modules/gpu/perf/perf_precomp.hpp             |   1 +
 .../src/cascadeclassifier.cpp                 |  35 +++-
 modules/{gpuobjdetect => gpu}/src/cuda/hog.cu |   0
 modules/{gpuobjdetect => gpu}/src/cuda/lbp.cu |   0
 .../{gpuobjdetect => gpu}/src/cuda/lbp.hpp    |   0
 modules/{gpuobjdetect => gpu}/src/hog.cpp     |   0
 modules/gpu/src/precomp.hpp                   |  11 ++
 .../test/test_objdetect.cpp                   |   0
 modules/gpu/test/test_precomp.hpp             |   5 +-
 modules/gpuobjdetect/CMakeLists.txt           |   9 -
 modules/gpuobjdetect/doc/gpuobjdetect.rst     |   8 -
 .../include/opencv2/gpuobjdetect.hpp          | 172 ------------------
 modules/gpuobjdetect/perf/perf_main.cpp       |  47 -----
 modules/gpuobjdetect/perf/perf_precomp.cpp    |  43 -----
 modules/gpuobjdetect/perf/perf_precomp.hpp    |  65 -------
 modules/gpuobjdetect/src/precomp.cpp          |  43 -----
 modules/gpuobjdetect/src/precomp.hpp          |  61 -------
 modules/gpuobjdetect/test/test_main.cpp       |  45 -----
 modules/gpuobjdetect/test/test_precomp.cpp    |  43 -----
 modules/gpuobjdetect/test/test_precomp.hpp    |  63 -------
 samples/cpp/CMakeLists.txt                    |   1 -
 samples/gpu/CMakeLists.txt                    |   2 +-
 27 files changed, 172 insertions(+), 606 deletions(-)
 rename modules/{gpuobjdetect => gpu}/doc/object_detection.rst (100%)
 rename modules/{gpuobjdetect => gpu}/perf/perf_objdetect.cpp (100%)
 rename modules/{gpuobjdetect => gpu}/src/cascadeclassifier.cpp (98%)
 rename modules/{gpuobjdetect => gpu}/src/cuda/hog.cu (100%)
 rename modules/{gpuobjdetect => gpu}/src/cuda/lbp.cu (100%)
 rename modules/{gpuobjdetect => gpu}/src/cuda/lbp.hpp (100%)
 rename modules/{gpuobjdetect => gpu}/src/hog.cpp (100%)
 rename modules/{gpuobjdetect => gpu}/test/test_objdetect.cpp (100%)
 delete mode 100644 modules/gpuobjdetect/CMakeLists.txt
 delete mode 100644 modules/gpuobjdetect/doc/gpuobjdetect.rst
 delete mode 100644 modules/gpuobjdetect/include/opencv2/gpuobjdetect.hpp
 delete mode 100644 modules/gpuobjdetect/perf/perf_main.cpp
 delete mode 100644 modules/gpuobjdetect/perf/perf_precomp.cpp
 delete mode 100644 modules/gpuobjdetect/perf/perf_precomp.hpp
 delete mode 100644 modules/gpuobjdetect/src/precomp.cpp
 delete mode 100644 modules/gpuobjdetect/src/precomp.hpp
 delete mode 100644 modules/gpuobjdetect/test/test_main.cpp
 delete mode 100644 modules/gpuobjdetect/test/test_precomp.cpp
 delete mode 100644 modules/gpuobjdetect/test/test_precomp.hpp

diff --git a/modules/gpu/CMakeLists.txt b/modules/gpu/CMakeLists.txt
index dec43263a3..662a652b97 100644
--- a/modules/gpu/CMakeLists.txt
+++ b/modules/gpu/CMakeLists.txt
@@ -7,7 +7,7 @@ set(the_description "GPU-accelerated Computer Vision")
 ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wmissing-declarations -Wshadow -Wunused-parameter)
 
 ocv_define_module(gpu opencv_gpuarithm opencv_gpufilters opencv_gpuwarping opencv_gpuimgproc
-                      opencv_gpufeatures2d opencv_gpuvideo opencv_gpustereo opencv_gpuobjdetect)
+                      opencv_gpufeatures2d opencv_gpuvideo opencv_gpustereo)
 
 if(HAVE_CUDA)
   add_subdirectory(perf4au)
diff --git a/modules/gpu/doc/gpu.rst b/modules/gpu/doc/gpu.rst
index d98f90d3b1..bc3b9bdb1f 100644
--- a/modules/gpu/doc/gpu.rst
+++ b/modules/gpu/doc/gpu.rst
@@ -8,3 +8,4 @@ gpu. GPU-accelerated Computer Vision
     introduction
     initalization_and_information
     data_structures
+    object_detection
diff --git a/modules/gpuobjdetect/doc/object_detection.rst b/modules/gpu/doc/object_detection.rst
similarity index 100%
rename from modules/gpuobjdetect/doc/object_detection.rst
rename to modules/gpu/doc/object_detection.rst
diff --git a/modules/gpu/include/opencv2/gpu.hpp b/modules/gpu/include/opencv2/gpu.hpp
index 72b3f49a20..db6157ab79 100644
--- a/modules/gpu/include/opencv2/gpu.hpp
+++ b/modules/gpu/include/opencv2/gpu.hpp
@@ -51,10 +51,129 @@
 #include "opencv2/gpufeatures2d.hpp"
 #include "opencv2/gpuvideo.hpp"
 #include "opencv2/gpustereo.hpp"
-#include "opencv2/gpuobjdetect.hpp"
 
 namespace cv { namespace gpu {
 
+//////////////// HOG (Histogram-of-Oriented-Gradients) Descriptor and Object Detector //////////////
+struct CV_EXPORTS HOGConfidence
+{
+   double scale;
+   std::vector<Point> locations;
+   std::vector<double> confidences;
+   std::vector<double> part_scores[4];
+};
+
+struct CV_EXPORTS HOGDescriptor
+{
+    enum { DEFAULT_WIN_SIGMA = -1 };
+    enum { DEFAULT_NLEVELS = 64 };
+    enum { DESCR_FORMAT_ROW_BY_ROW, DESCR_FORMAT_COL_BY_COL };
+
+    HOGDescriptor(Size win_size=Size(64, 128), Size block_size=Size(16, 16),
+                  Size block_stride=Size(8, 8), Size cell_size=Size(8, 8),
+                  int nbins=9, double win_sigma=DEFAULT_WIN_SIGMA,
+                  double threshold_L2hys=0.2, bool gamma_correction=true,
+                  int nlevels=DEFAULT_NLEVELS);
+
+    size_t getDescriptorSize() const;
+    size_t getBlockHistogramSize() const;
+
+    void setSVMDetector(const std::vector<float>& detector);
+
+    static std::vector<float> getDefaultPeopleDetector();
+    static std::vector<float> getPeopleDetector48x96();
+    static std::vector<float> getPeopleDetector64x128();
+
+    void detect(const GpuMat& img, std::vector<Point>& found_locations,
+                double hit_threshold=0, Size win_stride=Size(),
+                Size padding=Size());
+
+    void detectMultiScale(const GpuMat& img, std::vector<Rect>& found_locations,
+                          double hit_threshold=0, Size win_stride=Size(),
+                          Size padding=Size(), double scale0=1.05,
+                          int group_threshold=2);
+
+    void computeConfidence(const GpuMat& img, std::vector<Point>& hits, double hit_threshold,
+                                                Size win_stride, Size padding, std::vector<Point>& locations, std::vector<double>& confidences);
+
+    void computeConfidenceMultiScale(const GpuMat& img, std::vector<Rect>& found_locations,
+                                                                    double hit_threshold, Size win_stride, Size padding,
+                                                                    std::vector<HOGConfidence> &conf_out, int group_threshold);
+
+    void getDescriptors(const GpuMat& img, Size win_stride,
+                        GpuMat& descriptors,
+                        int descr_format=DESCR_FORMAT_COL_BY_COL);
+
+    Size win_size;
+    Size block_size;
+    Size block_stride;
+    Size cell_size;
+    int nbins;
+    double win_sigma;
+    double threshold_L2hys;
+    bool gamma_correction;
+    int nlevels;
+
+protected:
+    void computeBlockHistograms(const GpuMat& img);
+    void computeGradient(const GpuMat& img, GpuMat& grad, GpuMat& qangle);
+
+    double getWinSigma() const;
+    bool checkDetectorSize() const;
+
+    static int numPartsWithin(int size, int part_size, int stride);
+    static Size numPartsWithin(Size size, Size part_size, Size stride);
+
+    // Coefficients of the separating plane
+    float free_coef;
+    GpuMat detector;
+
+    // Results of the last classification step
+    GpuMat labels, labels_buf;
+    Mat labels_host;
+
+    // Results of the last histogram evaluation step
+    GpuMat block_hists, block_hists_buf;
+
+    // Gradients conputation results
+    GpuMat grad, qangle, grad_buf, qangle_buf;
+
+    // returns subbuffer with required size, reallocates buffer if nessesary.
+    static GpuMat getBuffer(const Size& sz, int type, GpuMat& buf);
+    static GpuMat getBuffer(int rows, int cols, int type, GpuMat& buf);
+
+    std::vector<GpuMat> image_scales;
+};
+
+// The cascade classifier class for object detection: supports old haar and new lbp xlm formats and nvbin for haar cascades olny.
+class CV_EXPORTS CascadeClassifier_GPU
+{
+public:
+    CascadeClassifier_GPU();
+    CascadeClassifier_GPU(const String& filename);
+    ~CascadeClassifier_GPU();
+
+    bool empty() const;
+    bool load(const String& filename);
+    void release();
+
+    /* returns number of detected objects */
+    int detectMultiScale(const GpuMat& image, GpuMat& objectsBuf, double scaleFactor = 1.2, int minNeighbors = 4, Size minSize = Size());
+    int detectMultiScale(const GpuMat& image, GpuMat& objectsBuf, Size maxObjectSize, Size minSize = Size(), double scaleFactor = 1.1, int minNeighbors = 4);
+
+    bool findLargestObject;
+    bool visualizeInPlace;
+
+    Size getClassifierSize() const;
+
+private:
+    struct CascadeClassifierImpl;
+    CascadeClassifierImpl* impl;
+    struct HaarCascade;
+    struct LbpCascade;
+    friend class CascadeClassifier_GPU_LBP;
+};
+
 //!performs labeling via graph cuts of a 2D regular 4-connected graph.
 CV_EXPORTS void graphcut(GpuMat& terminals, GpuMat& leftTransp, GpuMat& rightTransp, GpuMat& top, GpuMat& bottom, GpuMat& labels,
                          GpuMat& buf, Stream& stream = Stream::Null());
diff --git a/modules/gpuobjdetect/perf/perf_objdetect.cpp b/modules/gpu/perf/perf_objdetect.cpp
similarity index 100%
rename from modules/gpuobjdetect/perf/perf_objdetect.cpp
rename to modules/gpu/perf/perf_objdetect.cpp
diff --git a/modules/gpu/perf/perf_precomp.hpp b/modules/gpu/perf/perf_precomp.hpp
index 0329b3a980..5bfb14b52e 100644
--- a/modules/gpu/perf/perf_precomp.hpp
+++ b/modules/gpu/perf/perf_precomp.hpp
@@ -56,6 +56,7 @@
 
 #include "opencv2/gpu.hpp"
 #include "opencv2/calib3d.hpp"
+#include "opencv2/objdetect.hpp"
 
 #ifdef GTEST_CREATE_SHARED_LIBRARY
 #error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
diff --git a/modules/gpuobjdetect/src/cascadeclassifier.cpp b/modules/gpu/src/cascadeclassifier.cpp
similarity index 98%
rename from modules/gpuobjdetect/src/cascadeclassifier.cpp
rename to modules/gpu/src/cascadeclassifier.cpp
index 0b9f9aafc2..d9f34a54a0 100644
--- a/modules/gpuobjdetect/src/cascadeclassifier.cpp
+++ b/modules/gpu/src/cascadeclassifier.cpp
@@ -41,8 +41,6 @@
 //M*/
 
 #include "precomp.hpp"
-#include <vector>
-#include <iostream>
 #include "opencv2/objdetect/objdetect_c.h"
 
 using namespace cv;
@@ -75,6 +73,37 @@ public:
     virtual bool read(const String& classifierAsXml) = 0;
 };
 
+#ifndef HAVE_OPENCV_GPULEGACY
+
+struct cv::gpu::CascadeClassifier_GPU::HaarCascade
+{
+public:
+    HaarCascade()
+    {
+        throw_no_cuda();
+    }
+
+    unsigned int process(const GpuMat&, GpuMat&, float, int, bool, bool, cv::Size, cv::Size)
+    {
+        throw_no_cuda();
+        return 0;
+    }
+
+    cv::Size getClassifierCvSize() const
+    {
+        throw_no_cuda();
+        return cv::Size();
+    }
+
+    bool read(const String&)
+    {
+        throw_no_cuda();
+        return false;
+    }
+};
+
+#else
+
 struct cv::gpu::CascadeClassifier_GPU::HaarCascade : cv::gpu::CascadeClassifier_GPU::CascadeClassifierImpl
 {
 public:
@@ -284,6 +313,8 @@ private:
     virtual ~HaarCascade(){}
 };
 
+#endif
+
 cv::Size operator -(const cv::Size& a, const cv::Size& b)
 {
     return cv::Size(a.width - b.width, a.height - b.height);
diff --git a/modules/gpuobjdetect/src/cuda/hog.cu b/modules/gpu/src/cuda/hog.cu
similarity index 100%
rename from modules/gpuobjdetect/src/cuda/hog.cu
rename to modules/gpu/src/cuda/hog.cu
diff --git a/modules/gpuobjdetect/src/cuda/lbp.cu b/modules/gpu/src/cuda/lbp.cu
similarity index 100%
rename from modules/gpuobjdetect/src/cuda/lbp.cu
rename to modules/gpu/src/cuda/lbp.cu
diff --git a/modules/gpuobjdetect/src/cuda/lbp.hpp b/modules/gpu/src/cuda/lbp.hpp
similarity index 100%
rename from modules/gpuobjdetect/src/cuda/lbp.hpp
rename to modules/gpu/src/cuda/lbp.hpp
diff --git a/modules/gpuobjdetect/src/hog.cpp b/modules/gpu/src/hog.cpp
similarity index 100%
rename from modules/gpuobjdetect/src/hog.cpp
rename to modules/gpu/src/hog.cpp
diff --git a/modules/gpu/src/precomp.hpp b/modules/gpu/src/precomp.hpp
index c662cb1d73..0b468a3e9b 100644
--- a/modules/gpu/src/precomp.hpp
+++ b/modules/gpu/src/precomp.hpp
@@ -43,9 +43,20 @@
 #ifndef __OPENCV_PRECOMP_H__
 #define __OPENCV_PRECOMP_H__
 
+#include <vector>
+#include <iostream>
+
 #include "opencv2/gpu.hpp"
 #include "opencv2/calib3d.hpp"
+#include "opencv2/objdetect.hpp"
 
 #include "opencv2/core/gpu_private.hpp"
 
+#include "opencv2/opencv_modules.hpp"
+
+#ifdef HAVE_OPENCV_GPULEGACY
+#  include "opencv2/gpulegacy.hpp"
+#  include "opencv2/gpulegacy/private.hpp"
+#endif
+
 #endif /* __OPENCV_PRECOMP_H__ */
diff --git a/modules/gpuobjdetect/test/test_objdetect.cpp b/modules/gpu/test/test_objdetect.cpp
similarity index 100%
rename from modules/gpuobjdetect/test/test_objdetect.cpp
rename to modules/gpu/test/test_objdetect.cpp
diff --git a/modules/gpu/test/test_precomp.hpp b/modules/gpu/test/test_precomp.hpp
index 3177e88e7a..f2b0bf4051 100644
--- a/modules/gpu/test/test_precomp.hpp
+++ b/modules/gpu/test/test_precomp.hpp
@@ -51,12 +51,15 @@
 #ifndef __OPENCV_TEST_PRECOMP_HPP__
 #define __OPENCV_TEST_PRECOMP_HPP__
 
+#include <fstream>
+
 #include "opencv2/ts.hpp"
 #include "opencv2/ts/gpu_test.hpp"
 
+#include "opencv2/gpu.hpp"
 #include "opencv2/core.hpp"
 #include "opencv2/core/opengl.hpp"
-#include "opencv2/gpu.hpp"
 #include "opencv2/calib3d.hpp"
+#include "opencv2/objdetect.hpp"
 
 #endif
diff --git a/modules/gpuobjdetect/CMakeLists.txt b/modules/gpuobjdetect/CMakeLists.txt
deleted file mode 100644
index bcc2242c5d..0000000000
--- a/modules/gpuobjdetect/CMakeLists.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-if(ANDROID OR IOS)
-  ocv_module_disable(gpuobjdetect)
-endif()
-
-set(the_description "GPU-accelerated Object Detection")
-
-ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wmissing-declarations)
-
-ocv_define_module(gpuobjdetect opencv_objdetect opencv_gpuwarping opencv_gpuimgproc OPTIONAL opencv_gpulegacy)
diff --git a/modules/gpuobjdetect/doc/gpuobjdetect.rst b/modules/gpuobjdetect/doc/gpuobjdetect.rst
deleted file mode 100644
index c53225d2df..0000000000
--- a/modules/gpuobjdetect/doc/gpuobjdetect.rst
+++ /dev/null
@@ -1,8 +0,0 @@
-*************************************
-gpu. GPU-accelerated Object Detection
-*************************************
-
-.. toctree::
-    :maxdepth: 1
-
-    object_detection
diff --git a/modules/gpuobjdetect/include/opencv2/gpuobjdetect.hpp b/modules/gpuobjdetect/include/opencv2/gpuobjdetect.hpp
deleted file mode 100644
index ab665b3b7f..0000000000
--- a/modules/gpuobjdetect/include/opencv2/gpuobjdetect.hpp
+++ /dev/null
@@ -1,172 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_GPUOBJDETECT_HPP__
-#define __OPENCV_GPUOBJDETECT_HPP__
-
-#include "opencv2/core/gpumat.hpp"
-
-namespace cv { namespace gpu {
-
-//////////////// HOG (Histogram-of-Oriented-Gradients) Descriptor and Object Detector //////////////
-struct CV_EXPORTS HOGConfidence
-{
-   double scale;
-   std::vector<Point> locations;
-   std::vector<double> confidences;
-   std::vector<double> part_scores[4];
-};
-
-struct CV_EXPORTS HOGDescriptor
-{
-    enum { DEFAULT_WIN_SIGMA = -1 };
-    enum { DEFAULT_NLEVELS = 64 };
-    enum { DESCR_FORMAT_ROW_BY_ROW, DESCR_FORMAT_COL_BY_COL };
-
-    HOGDescriptor(Size win_size=Size(64, 128), Size block_size=Size(16, 16),
-                  Size block_stride=Size(8, 8), Size cell_size=Size(8, 8),
-                  int nbins=9, double win_sigma=DEFAULT_WIN_SIGMA,
-                  double threshold_L2hys=0.2, bool gamma_correction=true,
-                  int nlevels=DEFAULT_NLEVELS);
-
-    size_t getDescriptorSize() const;
-    size_t getBlockHistogramSize() const;
-
-    void setSVMDetector(const std::vector<float>& detector);
-
-    static std::vector<float> getDefaultPeopleDetector();
-    static std::vector<float> getPeopleDetector48x96();
-    static std::vector<float> getPeopleDetector64x128();
-
-    void detect(const GpuMat& img, std::vector<Point>& found_locations,
-                double hit_threshold=0, Size win_stride=Size(),
-                Size padding=Size());
-
-    void detectMultiScale(const GpuMat& img, std::vector<Rect>& found_locations,
-                          double hit_threshold=0, Size win_stride=Size(),
-                          Size padding=Size(), double scale0=1.05,
-                          int group_threshold=2);
-
-    void computeConfidence(const GpuMat& img, std::vector<Point>& hits, double hit_threshold,
-                                                Size win_stride, Size padding, std::vector<Point>& locations, std::vector<double>& confidences);
-
-    void computeConfidenceMultiScale(const GpuMat& img, std::vector<Rect>& found_locations,
-                                                                    double hit_threshold, Size win_stride, Size padding,
-                                                                    std::vector<HOGConfidence> &conf_out, int group_threshold);
-
-    void getDescriptors(const GpuMat& img, Size win_stride,
-                        GpuMat& descriptors,
-                        int descr_format=DESCR_FORMAT_COL_BY_COL);
-
-    Size win_size;
-    Size block_size;
-    Size block_stride;
-    Size cell_size;
-    int nbins;
-    double win_sigma;
-    double threshold_L2hys;
-    bool gamma_correction;
-    int nlevels;
-
-protected:
-    void computeBlockHistograms(const GpuMat& img);
-    void computeGradient(const GpuMat& img, GpuMat& grad, GpuMat& qangle);
-
-    double getWinSigma() const;
-    bool checkDetectorSize() const;
-
-    static int numPartsWithin(int size, int part_size, int stride);
-    static Size numPartsWithin(Size size, Size part_size, Size stride);
-
-    // Coefficients of the separating plane
-    float free_coef;
-    GpuMat detector;
-
-    // Results of the last classification step
-    GpuMat labels, labels_buf;
-    Mat labels_host;
-
-    // Results of the last histogram evaluation step
-    GpuMat block_hists, block_hists_buf;
-
-    // Gradients conputation results
-    GpuMat grad, qangle, grad_buf, qangle_buf;
-
-    // returns subbuffer with required size, reallocates buffer if nessesary.
-    static GpuMat getBuffer(const Size& sz, int type, GpuMat& buf);
-    static GpuMat getBuffer(int rows, int cols, int type, GpuMat& buf);
-
-    std::vector<GpuMat> image_scales;
-};
-
-// The cascade classifier class for object detection: supports old haar and new lbp xlm formats and nvbin for haar cascades olny.
-class CV_EXPORTS CascadeClassifier_GPU
-{
-public:
-    CascadeClassifier_GPU();
-    CascadeClassifier_GPU(const String& filename);
-    ~CascadeClassifier_GPU();
-
-    bool empty() const;
-    bool load(const String& filename);
-    void release();
-
-    /* returns number of detected objects */
-    int detectMultiScale(const GpuMat& image, GpuMat& objectsBuf, double scaleFactor = 1.2, int minNeighbors = 4, Size minSize = Size());
-    int detectMultiScale(const GpuMat& image, GpuMat& objectsBuf, Size maxObjectSize, Size minSize = Size(), double scaleFactor = 1.1, int minNeighbors = 4);
-
-    bool findLargestObject;
-    bool visualizeInPlace;
-
-    Size getClassifierSize() const;
-
-private:
-    struct CascadeClassifierImpl;
-    CascadeClassifierImpl* impl;
-    struct HaarCascade;
-    struct LbpCascade;
-    friend class CascadeClassifier_GPU_LBP;
-};
-
-}} // namespace cv { namespace gpu {
-
-#endif /* __OPENCV_GPUOBJDETECT_HPP__ */
diff --git a/modules/gpuobjdetect/perf/perf_main.cpp b/modules/gpuobjdetect/perf/perf_main.cpp
deleted file mode 100644
index b35791cda2..0000000000
--- a/modules/gpuobjdetect/perf/perf_main.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "perf_precomp.hpp"
-
-using namespace perf;
-
-CV_PERF_TEST_MAIN(gpuarithm, printCudaInfo())
diff --git a/modules/gpuobjdetect/perf/perf_precomp.cpp b/modules/gpuobjdetect/perf/perf_precomp.cpp
deleted file mode 100644
index 81f16e8f14..0000000000
--- a/modules/gpuobjdetect/perf/perf_precomp.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "perf_precomp.hpp"
diff --git a/modules/gpuobjdetect/perf/perf_precomp.hpp b/modules/gpuobjdetect/perf/perf_precomp.hpp
deleted file mode 100644
index 2a1acac7b5..0000000000
--- a/modules/gpuobjdetect/perf/perf_precomp.hpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifdef __GNUC__
-#  pragma GCC diagnostic ignored "-Wmissing-declarations"
-#  if defined __clang__ || defined __APPLE__
-#    pragma GCC diagnostic ignored "-Wmissing-prototypes"
-#    pragma GCC diagnostic ignored "-Wextra"
-#  endif
-#endif
-
-#ifndef __OPENCV_PERF_PRECOMP_HPP__
-#define __OPENCV_PERF_PRECOMP_HPP__
-
-#include "opencv2/ts.hpp"
-#include "opencv2/ts/gpu_perf.hpp"
-
-#include "opencv2/gpuobjdetect.hpp"
-
-#include "opencv2/objdetect.hpp"
-
-#ifdef GTEST_CREATE_SHARED_LIBRARY
-#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
-#endif
-
-#endif
diff --git a/modules/gpuobjdetect/src/precomp.cpp b/modules/gpuobjdetect/src/precomp.cpp
deleted file mode 100644
index 3c01a2596d..0000000000
--- a/modules/gpuobjdetect/src/precomp.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
diff --git a/modules/gpuobjdetect/src/precomp.hpp b/modules/gpuobjdetect/src/precomp.hpp
deleted file mode 100644
index 40fd6c46d7..0000000000
--- a/modules/gpuobjdetect/src/precomp.hpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_PRECOMP_H__
-#define __OPENCV_PRECOMP_H__
-
-#include "opencv2/gpuobjdetect.hpp"
-#include "opencv2/gpuwarping.hpp"
-#include "opencv2/gpuimgproc.hpp"
-#include "opencv2/gpuarithm.hpp"
-
-#include "opencv2/objdetect.hpp"
-
-#include "opencv2/core/gpu_private.hpp"
-
-#include "opencv2/opencv_modules.hpp"
-
-#ifdef HAVE_OPENCV_GPULEGACY
-#  include "opencv2/gpulegacy/private.hpp"
-#endif
-
-#endif /* __OPENCV_PRECOMP_H__ */
diff --git a/modules/gpuobjdetect/test/test_main.cpp b/modules/gpuobjdetect/test/test_main.cpp
deleted file mode 100644
index eea3d7c008..0000000000
--- a/modules/gpuobjdetect/test/test_main.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-
-CV_GPU_TEST_MAIN("gpu")
diff --git a/modules/gpuobjdetect/test/test_precomp.cpp b/modules/gpuobjdetect/test/test_precomp.cpp
deleted file mode 100644
index 0fb6521809..0000000000
--- a/modules/gpuobjdetect/test/test_precomp.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
diff --git a/modules/gpuobjdetect/test/test_precomp.hpp b/modules/gpuobjdetect/test/test_precomp.hpp
deleted file mode 100644
index 13527ba064..0000000000
--- a/modules/gpuobjdetect/test/test_precomp.hpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifdef __GNUC__
-#  pragma GCC diagnostic ignored "-Wmissing-declarations"
-#  if defined __clang__ || defined __APPLE__
-#    pragma GCC diagnostic ignored "-Wmissing-prototypes"
-#    pragma GCC diagnostic ignored "-Wextra"
-#  endif
-#endif
-
-#ifndef __OPENCV_TEST_PRECOMP_HPP__
-#define __OPENCV_TEST_PRECOMP_HPP__
-
-#include <fstream>
-
-#include "opencv2/ts.hpp"
-#include "opencv2/ts/gpu_test.hpp"
-
-#include "opencv2/gpuobjdetect.hpp"
-
-#include "opencv2/objdetect.hpp"
-
-#endif
diff --git a/samples/cpp/CMakeLists.txt b/samples/cpp/CMakeLists.txt
index ea1b3e1024..84913d2844 100644
--- a/samples/cpp/CMakeLists.txt
+++ b/samples/cpp/CMakeLists.txt
@@ -24,7 +24,6 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
     ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpufeatures2d/include")
     ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpuvideo/include")
     ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpustereo/include")
-    ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpuobjdetect/include")
     ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/include")
   endif()
 
diff --git a/samples/gpu/CMakeLists.txt b/samples/gpu/CMakeLists.txt
index f03af5605d..7fed87be0b 100644
--- a/samples/gpu/CMakeLists.txt
+++ b/samples/gpu/CMakeLists.txt
@@ -3,7 +3,7 @@ SET(OPENCV_GPU_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc ope
                                      opencv_calib3d opencv_legacy opencv_contrib opencv_gpu
                                      opencv_nonfree opencv_softcascade opencv_superres
                                      opencv_gpucodec opencv_gpuarithm opencv_gpufilters opencv_gpuwarping opencv_gpuimgproc
-                                     opencv_gpufeatures2d opencv_gpuvideo opencv_gpuobjdetect
+                                     opencv_gpufeatures2d opencv_gpuvideo
                                      opencv_gpustereo opencv_gpulegacy)
 
 ocv_check_dependencies(${OPENCV_GPU_SAMPLES_REQUIRED_DEPS})