]> rtime.felk.cvut.cz Git - opencv.git/commitdiff
modified doc on cascade detect
authormdim <mdim@73c94f0f-984f-4a5f-82bc-2d8db8d8ee08>
Fri, 26 Mar 2010 08:19:42 +0000 (08:19 +0000)
committermdim <mdim@73c94f0f-984f-4a5f-82bc-2d8db8d8ee08>
Fri, 26 Mar 2010 08:19:42 +0000 (08:19 +0000)
git-svn-id: https://code.ros.org/svn/opencv/trunk@2918 73c94f0f-984f-4a5f-82bc-2d8db8d8ee08

opencv/doc/cv_object_detection.tex

index 22945acf9a63e20a38ba6fb1863ca80a54a2bb33..29d99894217b280575d17ca02bae0c6d69ec1d54 100644 (file)
@@ -416,96 +416,265 @@ a positive value if the analyzed rectangle passed all the classifier stages
 \ifCpp
 
 \cvclass{FeatureEvaluator}
-Base class for computing feature values in cascade classifiers
+Base class for computing feature values in cascade classifiers.
 
 \begin{lstlisting}
-class FeatureEvaluator
+class CV_EXPORTS FeatureEvaluator
 {
 public:    
-    // feature type
-    enum { HAAR = 0, LBP = 1 };
-    virtual ~FeatureEvaluator();
-    // reads parameters of the features from a FileStorage node
+    enum { HAAR = 0, LBP = 1 }; // supported feature types 
+    virtual ~FeatureEvaluator(); // destructor
     virtual bool read(const FileNode& node);
-    // returns a full copy of the feature evaluator
     virtual Ptr<FeatureEvaluator> clone() const;
-    // returns the feature type (HAAR or LBP for now)
     virtual int getFeatureType() const;
     
-    // sets the image in which to compute the features
-    // (called by CascadeClassifier::setImage) 
-    virtual bool setImage(const Mat& image, Size origWinSize);
-    // sets window in the current image in which the features
-    // will be computed (called by CascadeClassifier::runAt)
+    virtual bool setImage(const Mat& img, Size origWinSize);
     virtual bool setWindow(Point p);
 
-    // computes value of an ordered (numerical) feature #featureIdx
     virtual double calcOrd(int featureIdx) const;
-    // computes value of a categorical feature #featureIdx
     virtual int calcCat(int featureIdx) const;
 
-    // static function that constructs feature evaluator
-    // of the specific feature type (HAAR or LBP for now)
     static Ptr<FeatureEvaluator> create(int type);
 };
 \end{lstlisting}
 
+\cvCppFunc{FeatureEvaluator::read}
+Reads parameters of the features from a FileStorage node.
+
+\begin{lstlisting}
+bool FeatureEvaluator::read(const FileNode& node);
+\end{lstlisting}
+
+\begin{description}
+\cvarg{node}{File node from which the feature parameters are read.}
+\end{description}
+
+\cvCppFunc{FeatureEvaluator::clone}
+Returns a full copy of the feature evaluator.
+
+\begin{lstlisting}
+Ptr<FeatureEvaluator> FeatureEvaluator::clone() const;
+\end{lstlisting}
+
+\cvCppFunc{FeatureEvaluator::getFeatureType}
+Returns the feature type (HAAR or LBP for now).
+
+\begin{lstlisting}
+int FeatureEvaluator::getFeatureType() const;
+\end{lstlisting}
+
+\cvCppFunc{FeatureEvaluator::setImage}
+Sets the image in which to compute the features.
+
+\begin{lstlisting}
+bool FeatureEvaluator::setImage(const Mat& img, Size origWinSize);
+\end{lstlisting}
+
+\begin{description}
+\cvarg{img}{Matrix of type  \texttt{CV\_8UC1} containing the image in which to compute the features.}
+\cvarg{origWinSize}{Size of training images.}
+\end{description}
+
+\cvCppFunc{FeatureEvaluator::setWindow}
+Sets window in the current image in which the features will be computed (called by \cvCppCross{CascadeClassifier::runAt}).
+
+\begin{lstlisting}
+bool FeatureEvaluator::setWindow(Point p); 
+\end{lstlisting}
+
+\begin{description}
+\cvarg{p}{The upper left point of window in which the features will be computed. Size of the window is equal to size of training images.}
+\end{description}
+
+\cvCppFunc{FeatureEvaluator::calcOrd}
+Computes value of an ordered (numerical) feature.
+
+\begin{lstlisting}
+double FeatureEvaluator::calcOrd(int featureIdx) const;
+\end{lstlisting}
+
+\begin{description}
+\cvarg{featureIdx}{Index of feature whose value will be computed.}
+\end{description}
+Returns computed value of ordered feature.
+
+\cvCppFunc{FeatureEvaluator::calcCat}
+Computes value of a categorical feature.
+
+\begin{lstlisting}
+int FeatureEvaluator::calcCat(int featureIdx) const;
+\end{lstlisting}
+
+\begin{description}
+\cvarg{featureIdx}{Index of feature whose value will be computed.}
+\end{description}
+Returns computed label of categorical feature, i.e. value from [0,... (number of categories - 1)].
+
+\cvCppFunc{FeatureEvaluator::create}
+Constructs feature evaluator.
+
+\begin{lstlisting}
+static Ptr<FeatureEvaluator> FeatureEvaluator::create(int type);
+\end{lstlisting}
+
+\begin{description}
+\cvarg{type}{Type of features evaluated by cascade (HAAR or LBP for now).}
+\end{description}
+
 \cvclass{CascadeClassifier}
-The cascade classifier class for object detection
+The cascade classifier class for object detection.
 
 \begin{lstlisting}
 class CascadeClassifier
 {
-public:    
-    enum { BOOST = 0 };
+public:
+       // structure for storing tree node
+    struct CV_EXPORTS DTreeNode 
+    {
+        int featureIdx; // feature index on which is a split
+        float threshold; // split threshold of ordered features only
+        int left; // left child index in the tree nodes array
+        int right; // right child index in the tree nodes array
+    };
+    
+    // structure for storing desision tree
+    struct CV_EXPORTS DTree 
+    {
+        int nodeCount; // nodes count
+    };
+    
+    // structure for storing cascade stage (BOOST only for now)
+    struct CV_EXPORTS Stage
+    {
+        int first; // first tree index in tree array
+        int ntrees; // number of trees
+        float threshold; // treshold of stage sum
+    };
+    
+    enum { BOOST = 0 }; // supported stage types
+    
+    // mode of detection (see parameter flags in function HaarDetectObjects)
+    enum { DO_CANNY_PRUNING = CV_HAAR_DO_CANNY_PRUNING,
+           SCALE_IMAGE = CV_HAAR_SCALE_IMAGE,
+           FIND_BIGGEST_OBJECT = CV_HAAR_FIND_BIGGEST_OBJECT,
+           DO_ROUGH_SEARCH = CV_HAAR_DO_ROUGH_SEARCH }; 
 
-    // default constructor
-    CascadeClassifier();
-    // load the classifier from file
+    CascadeClassifier(); // default constructor
     CascadeClassifier(const string& filename);
-    // the destructor
-    ~CascadeClassifier();
+    ~CascadeClassifier(); // destructor
     
-    // checks if the classifier has been loaded or not
     bool empty() const;
-    // loads the classifier from file. The previous content is destroyed.
     bool load(const string& filename);
-    // reads the classifier from a FileStorage node.
     bool read(const FileNode& node);
-    // detects objects of different sizes in the input image.
-    // the detected objects are returned as a list of rectangles.
-    // scaleFactor specifies how much the image size
-    //        is reduced at each image scale.
-    // minNeighbors speficifes how many neighbors should
-    //        each candiate rectangle have to retain it.
-    // flags - ignored
-    // minSize - the minimum possible object size.
-    //        Objects smaller than that are ignored.
-    void detectMultiScale( const Mat& image,
+
+    void detectMultiScale( const Mat& image, vector<Rect>& objects, 
+                           double scaleFactor=1.1, int minNeighbors=3, 
+                                                  int flags=0, Size minSize=Size());
+    
+    bool setImage( Ptr<FeatureEvaluator>&, const Mat& );
+    int runAt( Ptr<FeatureEvaluator>&, Point );
+
+    bool is_stump_based; // true, if the trees are stumps
+
+    int stageType; // stage type (BOOST only for now)
+    int featureType; // feature type (HAAR or LBP for now)
+    int ncategories; // number of categories (for categorical features only) 
+    Size origWinSize; // size of training images
+    
+    vector<Stage> stages; // vector of stages (BOOST for now)
+    vector<DTree> classifiers; // vector of decision trees
+    vector<DTreeNode> nodes; // vector of tree nodes
+    vector<float> leaves; // vector of leaf values
+    vector<int> subsets; // subsets of split by categorical feature
+
+    Ptr<FeatureEvaluator> feval; // pointer to feature evaluator
+    Ptr<CvHaarClassifierCascade> oldCascade; // pointer to old cascade
+};
+\end{lstlisting}
+
+\cvCppFunc{CascadeClassifier::CascadeClassifier}
+Loads the classifier from file.
+
+\begin{lstlisting}
+CascadeClassifier::CascadeClassifier(const string& filename);
+\end{lstlisting}
+
+\begin{description}
+\cvarg{filename}{Name of file from which classifier will be load.}
+\end{description}
+
+\cvCppFunc{CascadeClassifier::empty}
+Checks if the classifier has been loaded or not.
+
+\begin{lstlisting}
+bool CascadeClassifier::empty() const;
+\end{lstlisting}
+
+\cvCppFunc{CascadeClassifier::load}
+Loads the classifier from file. The previous content is destroyed.
+
+\begin{lstlisting}
+bool CascadeClassifier::load(const string& filename);
+\end{lstlisting}
+
+\begin{description}
+\cvarg{filename}{Name of file from which classifier will be load. File may contain as old haar classifier (trained by haartraining application) or new cascade classifier (trained traincascade application).}
+\end{description}
+
+\cvCppFunc{CascadeClassifier::read}
+Reads the classifier from a FileStorage node. File may contain a new cascade classifier (trained traincascade application) only.
+
+\begin{lstlisting}
+bool CascadeClassifier::read(const FileNode& node);
+\end{lstlisting}
+
+\cvCppFunc{CascadeClassifier::detectMultiScale}
+Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.
+
+\begin{lstlisting}
+void CascadeClassifier::detectMultiScale( const Mat& image,
                            vector<Rect>& objects,
                            double scaleFactor=1.1,
                            int minNeighbors=3, int flags=0,
                            Size minSize=Size());
-    // sets the image for detection
-    // (called by detectMultiScale at each image level)
-    bool setImage( Ptr<FeatureEvaluator>& feval, const Mat& image );
-    // runs the detector at the specified point
-    // (the image that the detector is working with should be set
-    // by setImage)
-    int runAt( Ptr<FeatureEvaluator>& feval, Point pt );
-
-    bool is_stump_based;
-
-    int stageType;
-    int featureType;
-    int ncategories;
-    Size origWinSize;
-
-    Ptr<FeatureEvaluator> feval;
-    Ptr<CvHaarClassifierCascade> oldCascade;
-};
 \end{lstlisting}
 
+\begin{description}
+\cvarg{image}{Matrix of type  \texttt{CV\_8U} containing the image in which to detect objects.}
+\cvarg{objects}{Vector of rectangles such that each rectangle contains the detected object.}
+\cvarg{scaleFactor}{Specifies how much the image size is reduced at each image scale.}
+\cvarg{minNeighbors}{Speficifes how many neighbors should each candiate rectangle have to retain it.}
+\cvarg{flags}{This parameter is not used for new cascade and have the same meaning for old cascade as in function cvHaarDetectObjects.}
+\cvarg{minSize}{The minimum possible object size. Objects smaller than that are ignored.}
+\end{description}
+
+\cvCppFunc{CascadeClassifier::setImage}
+Sets the image for detection (called by detectMultiScale at each image level).
+
+\begin{lstlisting}
+bool CascadeClassifier::setImage( Ptr<FeatureEvaluator>& feval, const Mat& image );
+\end{lstlisting}
+
+\begin{description}
+\cvarg{feval}{Pointer to feature evaluator which is used for computing features.}
+\cvarg{image}{Matrix of type  \texttt{CV\_8UC1} containing the image in which to compute the features.}
+\end{description}
+
+\cvCppFunc{CascadeClassifier::runAt}
+Runs the detector at the specified point (the image that the detector is working with should be set by setImage).
+
+\begin{lstlisting}
+int CascadeClassifier::runAt( Ptr<FeatureEvaluator>& feval, Point pt );
+\end{lstlisting}
+
+\begin{description}
+\cvarg{feval}{Feature evaluator which is used for computing features.}
+\cvarg{pt}{The upper left point of window in which the features will be computed. Size of the window is equal to size of training images.}
+\end{description}
+Returns:
+1 - if cascade classifier detects object in the given location.
+-si - otherwise. si is an index of stage which first predicted that given window is a background image.
+
 \cvCppFunc{groupRectangles}
 Groups the object candidate rectangles