diff --git a/apps/sft/CMakeLists.txt b/apps/sft/CMakeLists.txt index aa3bae229..bc7c1ebed 100644 --- a/apps/sft/CMakeLists.txt +++ b/apps/sft/CMakeLists.txt @@ -2,10 +2,10 @@ if(IOS OR ANDROID) return() endif() -set(the_target sft) -set(name ${the_target}) +set(name sft) +set(the_target opencv_${name}) -set(OPENCV_${the_target}_DEPS opencv_core opencv_objdetect opencv_highgui opencv_imgproc opencv_ml) +set(OPENCV_${the_target}_DEPS opencv_core opencv_softcascade opencv_highgui opencv_imgproc opencv_ml) ocv_check_dependencies(${OPENCV_${the_target}_DEPS}) if(NOT OCV_DEPENDENCIES_FOUND) @@ -28,7 +28,7 @@ set_target_properties(${the_target} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH} RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} INSTALL_NAME_DIR lib - OUTPUT_NAME ${name}) + OUTPUT_NAME ${the_target}) if(ENABLE_SOLUTION_FOLDERS) set_target_properties(${the_target} PROPERTIES FOLDER "applications") diff --git a/apps/sft/include/sft/fpool.hpp b/apps/sft/include/sft/fpool.hpp index 91dc500ec..0af71c890 100644 --- a/apps/sft/include/sft/fpool.hpp +++ b/apps/sft/include/sft/fpool.hpp @@ -48,7 +48,7 @@ #include #include -#include +#include namespace sft { struct ICF diff --git a/modules/objdetect/doc/objdetect.rst b/modules/objdetect/doc/objdetect.rst index 381742e50..4bab781b8 100644 --- a/modules/objdetect/doc/objdetect.rst +++ b/modules/objdetect/doc/objdetect.rst @@ -8,5 +8,4 @@ objdetect. Object Detection :maxdepth: 2 cascade_classification - soft_cascade latent_svm diff --git a/modules/objdetect/include/opencv2/objdetect/objdetect.hpp b/modules/objdetect/include/opencv2/objdetect/objdetect.hpp index 83257976d..f9138e242 100644 --- a/modules/objdetect/include/opencv2/objdetect/objdetect.hpp +++ b/modules/objdetect/include/opencv2/objdetect/objdetect.hpp @@ -488,105 +488,6 @@ protected: Ptr maskGenerator; }; - -class CV_EXPORTS_W ICFPreprocessor -{ -public: - CV_WRAP ICFPreprocessor(); - CV_WRAP void apply(cv::InputArray _frame, cv::OutputArray _integrals) const; -protected: - enum {BINS = 10}; -}; - -// Implementation of soft (stageless) cascaded detector. -class CV_EXPORTS_W SCascade : public Algorithm -{ -public: - - // Representation of detectors result. - struct CV_EXPORTS Detection - { - // Default object type. - enum {PEDESTRIAN = 1}; - - // Creates Detection from an object bounding box and confidence. - // Param b is a bounding box - // Param c is a confidence that object belongs to class k - // Paral k is an object class - Detection(const cv::Rect& b, const float c, int k = PEDESTRIAN) : bb(b), confidence(c), kind(k) {} - - cv::Rect bb; - float confidence; - int kind; - }; - - // Create channel integrals for Soft Cascade detector. - class CV_EXPORTS Channels - { - public: - // constrictor form resizing factor. - // Param shr is a resizing factor. Resize is applied before the computing integral sum - Channels(const int shrinkage); - - // Appends specified number of HOG first-order features integrals into given vector. - // Param gray is an input 1-channel gray image. - // Param integrals is a vector of integrals. Hog-channels will be appended to it. - // Param bins is a number of hog-bins - void appendHogBins(const cv::Mat& gray, std::vector& integrals, int bins) const; - - // Converts 3-channel BGR input frame in Luv and appends each channel to the integrals. - // Param frame is an input 3-channel BGR colored image. - // Param integrals is a vector of integrals. Computed from the frame luv-channels will be appended to it. - void appendLuvBins(const cv::Mat& frame, std::vector& integrals) const; - - private: - int shrinkage; - }; - - enum { NO_REJECT = 1, DOLLAR = 2, /*PASCAL = 4,*/ DEFAULT = NO_REJECT}; - - // An empty cascade will be created. - // Param minScale is a minimum scale relative to the original size of the image on which cascade will be applyed. - // Param minScale is a maximum scale relative to the original size of the image on which cascade will be applyed. - // Param scales is a number of scales from minScale to maxScale. - // Param rejCriteria is used for NMS. - CV_WRAP SCascade(const double minScale = 0.4, const double maxScale = 5., const int scales = 55, const int rejCriteria = 1); - - CV_WRAP virtual ~SCascade(); - - cv::AlgorithmInfo* info() const; - - // Load cascade from FileNode. - // Param fn is a root node for cascade. Should be . - CV_WRAP virtual bool load(const FileNode& fn); - - // Load cascade config. - CV_WRAP virtual void read(const FileNode& fn); - - // Return the vector of Decection objcts. - // Param image is a frame on which detector will be applied. - // Param rois is a vector of regions of interest. Only the objects that fall into one of the regions will be returned. - // Param objects is an output array of Detections - virtual void detect(InputArray image, InputArray rois, std::vector& objects) const; - // Param rects is an output array of bounding rectangles for detected objects. - // Param confs is an output array of confidence for detected objects. i-th bounding rectangle corresponds i-th configence. - CV_WRAP virtual void detect(InputArray image, InputArray rois, OutputArray rects, OutputArray confs) const; - -private: - void detectNoRoi(const Mat& image, std::vector& objects) const; - - struct Fields; - Fields* fields; - - double minScale; - double maxScale; - - int scales; - int rejCriteria; -}; - -CV_EXPORTS bool initModule_objdetect(void); - //////////////// HOG (Histogram-of-Oriented-Gradients) Descriptor and Object Detector ////////////// // struct for detection region of interest (ROI) diff --git a/modules/objdetect/perf/perf_cascadeclassifier.cpp b/modules/objdetect/perf/perf_cascadeclassifier.cpp index 78c80f39d..27b4226e9 100644 --- a/modules/objdetect/perf/perf_cascadeclassifier.cpp +++ b/modules/objdetect/perf/perf_cascadeclassifier.cpp @@ -47,47 +47,4 @@ PERF_TEST_P(ImageName_MinSize, CascadeClassifierLBPFrontalFace, std::sort(faces.begin(), faces.end(), comparators::RectLess()); SANITY_CHECK(faces, 3.001 * faces.size()); -} - -typedef std::tr1::tuple fixture; -typedef perf::TestBaseWithParam detect; - - -namespace { -typedef cv::SCascade::Detection detection_t; - -void extractRacts(std::vector objectBoxes, vector& rects) -{ - rects.clear(); - for (int i = 0; i < (int)objectBoxes.size(); ++i) - rects.push_back(objectBoxes[i].bb); -} - -} - -PERF_TEST_P(detect, SCascade, - testing::Combine(testing::Values(std::string("cv/cascadeandhog/cascades/inria_caltech-17.01.2013.xml")), - testing::Values(std::string("cv/cascadeandhog/images/image_00000000_0.png")))) -{ - typedef cv::SCascade::Detection Detection; - cv::Mat colored = imread(getDataPath(get<1>(GetParam()))); - ASSERT_FALSE(colored.empty()); - - cv::SCascade cascade; - cv::FileStorage fs(getDataPath(get<0>(GetParam())), cv::FileStorage::READ); - ASSERT_TRUE(fs.isOpened()); - ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode())); - - std::vector objectBoxes; - cascade.detect(colored, cv::noArray(), objectBoxes); - - TEST_CYCLE() - { - cascade.detect(colored, cv::noArray(), objectBoxes); - } - - vector rects; - extractRacts(objectBoxes, rects); - std::sort(rects.begin(), rects.end(), comparators::RectLess()); - SANITY_CHECK(rects); } \ No newline at end of file diff --git a/modules/softcascade/CMakeLists.txt b/modules/softcascade/CMakeLists.txt new file mode 100644 index 000000000..ef38c3ad7 --- /dev/null +++ b/modules/softcascade/CMakeLists.txt @@ -0,0 +1,2 @@ +set(the_description "Soft Cascade detection and training") +ocv_define_module(softcascade opencv_core opencv_imgproc opencv_ml) \ No newline at end of file diff --git a/modules/softcascade/doc/softcascade.rst b/modules/softcascade/doc/softcascade.rst new file mode 100644 index 000000000..66c93d1fc --- /dev/null +++ b/modules/softcascade/doc/softcascade.rst @@ -0,0 +1,11 @@ +******************************************************** +softcascade. Soft Cascade object detection and training. +******************************************************** + +.. highlight:: cpp + +.. toctree:: + :maxdepth: 2 + + softcascade_detector + softcascade_training \ No newline at end of file diff --git a/modules/objdetect/doc/soft_cascade.rst b/modules/softcascade/doc/softcascade_detector.rst similarity index 91% rename from modules/objdetect/doc/soft_cascade.rst rename to modules/softcascade/doc/softcascade_detector.rst index ac537b3a8..2ac6264fa 100644 --- a/modules/objdetect/doc/soft_cascade.rst +++ b/modules/softcascade/doc/softcascade_detector.rst @@ -1,10 +1,10 @@ Soft Cascade Classifier -====================== +======================= .. highlight:: cpp Soft Cascade Classifier for Object Detection ----------------------------------------------------------- +-------------------------------------------- Cascade detectors have been shown to operate extremely rapidly, with high accuracy, and have important applications in different spheres. The initial goal for this cascade implementation was the fast and accurate pedestrian detector but it also useful in general. Soft cascade is trained with AdaBoost. But instead of training sequence of stages, the soft cascade is trained as a one long stage of T weak classifiers. Soft cascade is formulated as follows: @@ -16,7 +16,7 @@ where :math:`\texttt{s}_t(x) = \alpha_t\texttt{h}_t(x)` are the set of threshold .. math:: \texttt{H}_t(x) = \sum _{\texttt{i}=1..\texttt{t}} {\texttt{s}_i(x)} -be the partial sum of sample responses before :math:`t`-the weak classifier will be applied. The funtcion :math:`\texttt{H}_t(x)` of :math:`t` for sample :math:`x` named *sample trace*. +be the partial sum of sample responses before :math:`t`-the weak classifier will be applied. The function :math:`\texttt{H}_t(x)` of :math:`t` for sample :math:`x` named *sample trace*. After each weak classifier evaluation, the sample trace at the point :math:`t` is compared with the rejection threshold :math:`r_t`. The sequence of :math:`r_t` named *rejection trace*. The sample has been rejected if it fall rejection threshold. So stageless cascade allows to reject not-object sample as soon as possible. Another meaning of the sample trace is a confidence with that sample recognized as desired object. At each :math:`t` that confidence depend on all previous weak classifier. This feature of soft cascade is resulted in more accurate detection. The original formulation of soft cascade can be found in [BJ05]_. @@ -49,9 +49,9 @@ An empty cascade will be created. .. ocv:function:: bool SCascade::SCascade(const float minScale = 0.4f, const float maxScale = 5.f, const int scales = 55, const int rejfactor = 1) - :param minScale: a minimum scale relative to the original size of the image on which cascade will be applyed. + :param minScale: a minimum scale relative to the original size of the image on which cascade will be applied. - :param maxScale: a maximum scale relative to the original size of the image on which cascade will be applyed. + :param maxScale: a maximum scale relative to the original size of the image on which cascade will be applied. :param scales: a number of scales from minScale to maxScale. @@ -79,7 +79,7 @@ Load cascade from FileNode. SCascade::detect -------------------------- -Apply cascade to an input frame and return the vector of Decection objcts. +Apply cascade to an input frame and return the vector of Detection objects. .. ocv:function:: void SCascade::detect(InputArray image, InputArray rois, std::vector& objects) const @@ -93,4 +93,4 @@ Apply cascade to an input frame and return the vector of Decection objcts. :param rects: an output array of bounding rectangles for detected objects. - :param confs: an output array of confidence for detected objects. i-th bounding rectangle corresponds i-th configence. \ No newline at end of file + :param confs: an output array of confidence for detected objects. i-th bounding rectangle corresponds i-th confidence. \ No newline at end of file diff --git a/modules/softcascade/doc/softcascade_training.rst b/modules/softcascade/doc/softcascade_training.rst new file mode 100644 index 000000000..8b9ea5e35 --- /dev/null +++ b/modules/softcascade/doc/softcascade_training.rst @@ -0,0 +1,2 @@ +Soft Cascade Training +======================= \ No newline at end of file diff --git a/modules/softcascade/include/opencv2/softcascade/softcascade.hpp b/modules/softcascade/include/opencv2/softcascade/softcascade.hpp new file mode 100644 index 000000000..c589906aa --- /dev/null +++ b/modules/softcascade/include/opencv2/softcascade/softcascade.hpp @@ -0,0 +1,149 @@ +/*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) 2008-2013, 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_SOFTCASCADE_HPP__ +#define __OPENCV_SOFTCASCADE_HPP__ + +#include "opencv2/core/core.hpp" + +namespace cv { + +class CV_EXPORTS_W ICFPreprocessor +{ +public: + CV_WRAP ICFPreprocessor(); + CV_WRAP void apply(cv::InputArray _frame, cv::OutputArray _integrals) const; +protected: + enum {BINS = 10}; +}; + +// Implementation of soft (stageless) cascaded detector. +class CV_EXPORTS_W SCascade : public Algorithm +{ +public: + + // Representation of detectors result. + struct CV_EXPORTS Detection + { + // Default object type. + enum {PEDESTRIAN = 1}; + + // Creates Detection from an object bounding box and confidence. + // Param b is a bounding box + // Param c is a confidence that object belongs to class k + // Param k is an object class + Detection(const cv::Rect& b, const float c, int k = PEDESTRIAN) : bb(b), confidence(c), kind(k) {} + + cv::Rect bb; + float confidence; + int kind; + }; + + // Create channel integrals for Soft Cascade detector. + class CV_EXPORTS Channels + { + public: + // constrictor form resizing factor. + // Param shrinkage is a resizing factor. Resize is applied before the computing integral sum + Channels(const int shrinkage); + + // Appends specified number of HOG first-order features integrals into given vector. + // Param gray is an input 1-channel gray image. + // Param integrals is a vector of integrals. Hog-channels will be appended to it. + // Param bins is a number of hog-bins + void appendHogBins(const cv::Mat& gray, std::vector& integrals, int bins) const; + + // Converts 3-channel BGR input frame in Luv and appends each channel to the integrals. + // Param frame is an input 3-channel BGR colored image. + // Param integrals is a vector of integrals. Computed from the frame luv-channels will be appended to it. + void appendLuvBins(const cv::Mat& frame, std::vector& integrals) const; + + private: + int shrinkage; + }; + + enum { NO_REJECT = 1, DOLLAR = 2, /*PASCAL = 4,*/ DEFAULT = NO_REJECT}; + + // An empty cascade will be created. + // Param minScale is a minimum scale relative to the original size of the image on which cascade will be applied. + // Param minScale is a maximum scale relative to the original size of the image on which cascade will be applied. + // Param scales is a number of scales from minScale to maxScale. + // Param rejCriteria is used for NMS. + CV_WRAP SCascade(const double minScale = 0.4, const double maxScale = 5., const int scales = 55, const int rejCriteria = 1); + + CV_WRAP virtual ~SCascade(); + + cv::AlgorithmInfo* info() const; + + // Load cascade from FileNode. + // Param fn is a root node for cascade. Should be . + CV_WRAP virtual bool load(const FileNode& fn); + + // Load cascade config. + CV_WRAP virtual void read(const FileNode& fn); + + // Return the vector of Detection objects. + // Param image is a frame on which detector will be applied. + // Param rois is a vector of regions of interest. Only the objects that fall into one of the regions will be returned. + // Param objects is an output array of Detections + virtual void detect(InputArray image, InputArray rois, std::vector& objects) const; + // Param rects is an output array of bounding rectangles for detected objects. + // Param confs is an output array of confidence for detected objects. i-th bounding rectangle corresponds i-th confidence. + CV_WRAP virtual void detect(InputArray image, InputArray rois, CV_OUT OutputArray rects, CV_OUT OutputArray confs) const; + +private: + void detectNoRoi(const Mat& image, std::vector& objects) const; + + struct Fields; + Fields* fields; + + double minScale; + double maxScale; + + int scales; + int rejCriteria; +}; + +CV_EXPORTS bool initModule_softcascade(void); +} + +#endif \ No newline at end of file diff --git a/modules/softcascade/perf/perf_main.cpp b/modules/softcascade/perf/perf_main.cpp new file mode 100644 index 000000000..f045c4b46 --- /dev/null +++ b/modules/softcascade/perf/perf_main.cpp @@ -0,0 +1,45 @@ +/*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) 2008-2013, 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" + +CV_PERF_TEST_MAIN(softcascade) diff --git a/modules/softcascade/perf/perf_precomp. b/modules/softcascade/perf/perf_precomp. new file mode 100644 index 000000000..e69de29bb diff --git a/modules/softcascade/perf/perf_precomp.cpp b/modules/softcascade/perf/perf_precomp.cpp new file mode 100644 index 000000000..cc728b050 --- /dev/null +++ b/modules/softcascade/perf/perf_precomp.cpp @@ -0,0 +1,43 @@ +/*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) 2008-2013, 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/softcascade/perf/perf_precomp.hpp b/modules/softcascade/perf/perf_precomp.hpp new file mode 100644 index 000000000..b761c88c6 --- /dev/null +++ b/modules/softcascade/perf/perf_precomp.hpp @@ -0,0 +1,62 @@ +/*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) 2008-2013, 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/ts.hpp" +# include "opencv2/softcascade/softcascade.hpp" +# include "opencv2/highgui/highgui.hpp" + +#ifdef GTEST_CREATE_SHARED_LIBRARY +# error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined +#endif + +#endif diff --git a/modules/softcascade/perf/perf_softcascade.cpp b/modules/softcascade/perf/perf_softcascade.cpp new file mode 100644 index 000000000..cf612b605 --- /dev/null +++ b/modules/softcascade/perf/perf_softcascade.cpp @@ -0,0 +1,48 @@ +#include "perf_precomp.hpp" +#include + +using cv::Rect; +using std::tr1::get; + +typedef std::tr1::tuple fixture; +typedef perf::TestBaseWithParam detect; + + +namespace { +typedef cv::SCascade::Detection detection_t; + +void extractRacts(std::vector objectBoxes, std::vector& rects) +{ + rects.clear(); + for (int i = 0; i < (int)objectBoxes.size(); ++i) + rects.push_back(objectBoxes[i].bb); +} + +} + +PERF_TEST_P(detect, SCascade, + testing::Combine(testing::Values(std::string("cv/cascadeandhog/cascades/inria_caltech-17.01.2013.xml")), + testing::Values(std::string("cv/cascadeandhog/images/image_00000000_0.png")))) +{ + typedef cv::SCascade::Detection Detection; + cv::Mat colored = cv::imread(getDataPath(get<1>(GetParam()))); + ASSERT_FALSE(colored.empty()); + + cv::SCascade cascade; + cv::FileStorage fs(getDataPath(get<0>(GetParam())), cv::FileStorage::READ); + ASSERT_TRUE(fs.isOpened()); + ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode())); + + std::vector objectBoxes; + cascade.detect(colored, cv::noArray(), objectBoxes); + + TEST_CYCLE() + { + cascade.detect(colored, cv::noArray(), objectBoxes); + } + + std::vector rects; + extractRacts(objectBoxes, rects); + std::sort(rects.begin(), rects.end(), perf::comparators::RectLess()); + SANITY_CHECK(rects); +} \ No newline at end of file diff --git a/modules/objdetect/src/icf.cpp b/modules/softcascade/src/icf.cpp similarity index 97% rename from modules/objdetect/src/icf.cpp rename to modules/softcascade/src/icf.cpp index a9321276c..8b14421ef 100644 --- a/modules/objdetect/src/icf.cpp +++ b/modules/softcascade/src/icf.cpp @@ -11,7 +11,7 @@ // For Open Source Computer Vision Library // // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. -// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved. +// Copyright (C) 2008-2013, 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, @@ -22,7 +22,7 @@ // // * 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. +// 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. diff --git a/modules/softcascade/src/precomp.cpp b/modules/softcascade/src/precomp.cpp new file mode 100644 index 000000000..62c236d08 --- /dev/null +++ b/modules/softcascade/src/precomp.cpp @@ -0,0 +1,43 @@ +/*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) 2008-2013, 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/softcascade/src/precomp.hpp b/modules/softcascade/src/precomp.hpp new file mode 100644 index 000000000..28771c073 --- /dev/null +++ b/modules/softcascade/src/precomp.hpp @@ -0,0 +1,58 @@ +/*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) 2008-2013, 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__ + +#ifdef HAVE_CVCONFIG_H +#include "cvconfig.h" +#endif + +#include "opencv2/softcascade/softcascade.hpp" +#include "opencv2/imgproc/imgproc.hpp" +#include "opencv2/imgproc/imgproc_c.h" +#include "opencv2/core/core_c.h" +#include "opencv2/core/internal.hpp" + +#include "opencv2/opencv_modules.hpp" + +#endif diff --git a/modules/objdetect/src/softcascade.cpp b/modules/softcascade/src/softcascade.cpp similarity index 99% rename from modules/objdetect/src/softcascade.cpp rename to modules/softcascade/src/softcascade.cpp index 9893f417b..3bf3a2ac7 100644 --- a/modules/objdetect/src/softcascade.cpp +++ b/modules/softcascade/src/softcascade.cpp @@ -11,7 +11,7 @@ // For Open Source Computer Vision Library // // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. -// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved. +// Copyright (C) 2008-2013, 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, @@ -22,7 +22,7 @@ // // * 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. +// 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. diff --git a/modules/objdetect/src/objdetect_init.cpp b/modules/softcascade/src/softcascade_init.cpp similarity index 93% rename from modules/objdetect/src/objdetect_init.cpp rename to modules/softcascade/src/softcascade_init.cpp index 68e64243a..17594d304 100644 --- a/modules/objdetect/src/objdetect_init.cpp +++ b/modules/softcascade/src/softcascade_init.cpp @@ -11,7 +11,7 @@ // For Open Source Computer Vision Library // // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. -// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved. +// Copyright (C) 2008-2013, 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, @@ -22,7 +22,7 @@ // // * 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. +// 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. @@ -51,7 +51,7 @@ CV_INIT_ALGORITHM(SCascade, "CascadeDetector.SCascade", obj.info()->addParam(obj, "scales", obj.scales); obj.info()->addParam(obj, "rejCriteria", obj.rejCriteria)); -bool initModule_objdetect(void) +bool initModule_softcascade(void) { Ptr sc = createSCascade(); return sc->info() != 0; diff --git a/modules/softcascade/test/test_main.cpp b/modules/softcascade/test/test_main.cpp new file mode 100644 index 000000000..d3999d483 --- /dev/null +++ b/modules/softcascade/test/test_main.cpp @@ -0,0 +1,45 @@ +/*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) 2008-2013, 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_TEST_MAIN("cv") diff --git a/modules/softcascade/test/test_precomp.cpp b/modules/softcascade/test/test_precomp.cpp new file mode 100644 index 000000000..278cdd03c --- /dev/null +++ b/modules/softcascade/test/test_precomp.cpp @@ -0,0 +1,43 @@ +/*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) 2008-2013, 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/softcascade/test/test_precomp.hpp b/modules/softcascade/test/test_precomp.hpp new file mode 100644 index 000000000..6abcbeada --- /dev/null +++ b/modules/softcascade/test/test_precomp.hpp @@ -0,0 +1,59 @@ +/*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) 2008-2013, 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 "opencv2/ts/ts.hpp" +# include "opencv2/softcascade/softcascade.hpp" +# include "opencv2/imgproc/imgproc.hpp" +# include "opencv2/highgui/highgui.hpp" + +#endif diff --git a/modules/objdetect/test/test_softcascade.cpp b/modules/softcascade/test/test_softcascade.cpp similarity index 97% rename from modules/objdetect/test/test_softcascade.cpp rename to modules/softcascade/test/test_softcascade.cpp index 024ea925a..a53b33958 100644 --- a/modules/objdetect/test/test_softcascade.cpp +++ b/modules/softcascade/test/test_softcascade.cpp @@ -11,7 +11,7 @@ // For Open Source Computer Vision Library // // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. -// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved. +// Copyright (C) 2008-2013, 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, @@ -22,7 +22,7 @@ // // * 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. +// 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.