From fe11ca886a62f5e44a5a93cb54e7c15b074239d7 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Wed, 4 Dec 2013 21:56:35 +0400 Subject: [PATCH] trying to eliminate compile problems --- .../objdetect/doc/cascade_classification.rst | 38 -------------- .../objdetect/include/opencv2/objdetect.hpp | 51 ++++++++++--------- modules/objdetect/src/cascadedetect.cpp | 17 +++++-- modules/objdetect/src/cascadedetect.hpp | 6 +-- 4 files changed, 43 insertions(+), 69 deletions(-) diff --git a/modules/objdetect/doc/cascade_classification.rst b/modules/objdetect/doc/cascade_classification.rst index ecd27c793..c351dc713 100644 --- a/modules/objdetect/doc/cascade_classification.rst +++ b/modules/objdetect/doc/cascade_classification.rst @@ -221,44 +221,6 @@ The function is parallelized with the TBB library. * (Python) A face detection example using cascade classifiers can be found at opencv_source_code/samples/python2/facedetect.py -CascadeClassifier::setImage -------------------------------- -Sets an image for detection. - -.. ocv:function:: bool CascadeClassifier::setImage( Ptr& feval, const Mat& image ) - -.. ocv:cfunction:: void cvSetImagesForHaarClassifierCascade( CvHaarClassifierCascade* cascade, const CvArr* sum, const CvArr* sqsum, const CvArr* tilted_sum, double scale ) - - :param cascade: Haar classifier cascade (OpenCV 1.x API only). See :ocv:func:`CascadeClassifier::detectMultiScale` for more information. - - :param feval: Pointer to the feature evaluator used for computing features. - - :param image: Matrix of the type ``CV_8UC1`` containing an image where the features are computed. - -The function is automatically called by :ocv:func:`CascadeClassifier::detectMultiScale` at every image scale. But if you want to test various locations manually using :ocv:func:`CascadeClassifier::runAt`, you need to call the function before, so that the integral images are computed. - -.. note:: in the old API you need to supply integral images (that can be obtained using :ocv:cfunc:`Integral`) instead of the original image. - - -CascadeClassifier::runAt ----------------------------- -Runs the detector at the specified point. - -.. ocv:function:: int CascadeClassifier::runAt( Ptr& feval, Point pt, double& weight ) - -.. ocv:cfunction:: int cvRunHaarClassifierCascade( const CvHaarClassifierCascade* cascade, CvPoint pt, int start_stage=0 ) - - :param cascade: Haar classifier cascade (OpenCV 1.x API only). See :ocv:func:`CascadeClassifier::detectMultiScale` for more information. - - :param feval: Feature evaluator used for computing features. - - :param pt: Upper left point of the window where the features are computed. Size of the window is equal to the size of training images. - -The function returns 1 if the cascade classifier detects an object in the given location. -Otherwise, it returns negated index of the stage at which the candidate has been rejected. - -Use :ocv:func:`CascadeClassifier::setImage` to set the image for the detector to work with. - groupRectangles ------------------- Groups the object candidate rectangles. diff --git a/modules/objdetect/include/opencv2/objdetect.hpp b/modules/objdetect/include/opencv2/objdetect.hpp index 26419bc59..c587b26a3 100644 --- a/modules/objdetect/include/opencv2/objdetect.hpp +++ b/modules/objdetect/include/opencv2/objdetect.hpp @@ -193,30 +193,31 @@ public: virtual Ptr getMaskGenerator() = 0; }; -class CV_EXPORTS_W CascadeClassifier : public BaseCascadeClassifier +class CV_EXPORTS_W CascadeClassifier { public: CV_WRAP CascadeClassifier(); CV_WRAP explicit CascadeClassifier(const String& filename); - virtual ~CascadeClassifier(); - CV_WRAP virtual bool empty() const; - CV_WRAP virtual bool load( const String& filename ); - CV_WRAP virtual void detectMultiScale( InputArray image, - CV_OUT std::vector& objects, - double scaleFactor = 1.1, - int minNeighbors = 3, int flags = 0, - Size minSize = Size(), - Size maxSize = Size() ); + ~CascadeClassifier(); + CV_WRAP bool empty() const; + CV_WRAP bool load( const String& filename ); + CV_WRAP bool read( const FileNode& node ); + CV_WRAP void detectMultiScale( InputArray image, + CV_OUT std::vector& objects, + double scaleFactor = 1.1, + int minNeighbors = 3, int flags = 0, + Size minSize = Size(), + Size maxSize = Size() ); - CV_WRAP virtual void detectMultiScale( InputArray image, - CV_OUT std::vector& objects, - CV_OUT std::vector& numDetections, - double scaleFactor=1.1, - int minNeighbors=3, int flags=0, - Size minSize=Size(), - Size maxSize=Size() ); + CV_WRAP void detectMultiScale( InputArray image, + CV_OUT std::vector& objects, + CV_OUT std::vector& numDetections, + double scaleFactor=1.1, + int minNeighbors=3, int flags=0, + Size minSize=Size(), + Size maxSize=Size() ); - CV_WRAP virtual void detectMultiScale( InputArray image, + CV_WRAP void detectMultiScale( InputArray image, CV_OUT std::vector& objects, CV_OUT std::vector& rejectLevels, CV_OUT std::vector& levelWeights, @@ -226,18 +227,18 @@ public: Size maxSize = Size(), bool outputRejectLevels = false ); - CV_WRAP virtual bool isOldFormatCascade() const; - CV_WRAP virtual Size getOriginalWindowSize() const; - CV_WRAP virtual int getFeatureType() const; - virtual void* getOldCascade(); + CV_WRAP bool isOldFormatCascade() const; + CV_WRAP Size getOriginalWindowSize() const; + CV_WRAP int getFeatureType() const; + void* getOldCascade(); - virtual void setMaskGenerator(const Ptr& maskGenerator); - virtual Ptr getMaskGenerator(); + void setMaskGenerator(const Ptr& maskGenerator); + Ptr getMaskGenerator(); protected: Ptr cc; }; -CV_EXPORTS Ptr createFaceDetectionMaskGenerator(); +CV_EXPORTS Ptr createFaceDetectionMaskGenerator(); //////////////// HOG (Histogram-of-Oriented-Gradients) Descriptor and Object Detector ////////////// diff --git a/modules/objdetect/src/cascadedetect.cpp b/modules/objdetect/src/cascadedetect.cpp index 10c1b17a3..292237560 100644 --- a/modules/objdetect/src/cascadedetect.cpp +++ b/modules/objdetect/src/cascadedetect.cpp @@ -918,12 +918,12 @@ Ptr CascadeClassifierImpl::getMaskGenerato return maskGenerator; } -Ptr createFaceDetectionMaskGenerator() +Ptr createFaceDetectionMaskGenerator() { #ifdef HAVE_TEGRA_OPTIMIZATION return tegra::getCascadeClassifierMaskGenerator(*this); #else - return Ptr(); + return Ptr(); #endif } @@ -1390,6 +1390,17 @@ bool CascadeClassifier::load( const String& filename ) return !empty(); } +bool CascadeClassifier::read(const FileNode &root) +{ + Ptr ccimpl; + bool ok = ccimpl->read_(root); + if( ok ) + cc = ccimpl.staticCast(); + else + cc.release(); + return ok; +} + void CascadeClassifier::detectMultiScale( InputArray image, CV_OUT std::vector& objects, double scaleFactor, @@ -1452,7 +1463,7 @@ void* CascadeClassifier::getOldCascade() return cc->getOldCascade(); } -void CascadeClassifier::setMaskGenerator(const Ptr& maskGenerator) +void CascadeClassifier::setMaskGenerator(const Ptr& maskGenerator) { CV_Assert(!empty()); cc->setMaskGenerator(maskGenerator); diff --git a/modules/objdetect/src/cascadedetect.hpp b/modules/objdetect/src/cascadedetect.hpp index 862a273dc..2505ea071 100644 --- a/modules/objdetect/src/cascadedetect.hpp +++ b/modules/objdetect/src/cascadedetect.hpp @@ -86,7 +86,7 @@ protected: class Data { public: - struct CV_EXPORTS DTreeNode + struct DTreeNode { int featureIdx; float threshold; // for ordered features only @@ -94,12 +94,12 @@ protected: int right; }; - struct CV_EXPORTS DTree + struct DTree { int nodeCount; }; - struct CV_EXPORTS Stage + struct Stage { int first; int ntrees;