4343#define __OPENCV_OBJDETECT_HPP__
4444
4545#include " opencv2/core.hpp"
46- // #include "opencv2/core/core_c.h"
4746
4847#include < map>
4948#include < vector>
5049#include < string>
5150
52- extern " C" {
53-
54- /* ***************************************************************************************\
55- * Latent SVM Object Detection functions *
56- \****************************************************************************************/
57-
58- // DataType: STRUCT position
59- // Structure describes the position of the filter in the feature pyramid
60- // l - level in the feature pyramid
61- // (x, y) - coordinate in level l
62-
63- typedef struct CvLSVMFilterPosition
64- {
65- int x;
66- int y;
67- int l;
68- } CvLSVMFilterPosition;
69-
70- // DataType: STRUCT filterObject
71- // Description of the filter, which corresponds to the part of the object
72- // V - ideal (penalty = 0) position of the partial filter
73- // from the root filter position (V_i in the paper)
74- // penaltyFunction - vector describes penalty function (d_i in the paper)
75- // pf[0] * x + pf[1] * y + pf[2] * x^2 + pf[3] * y^2
76- // FILTER DESCRIPTION
77- // Rectangular map (sizeX x sizeY),
78- // every cell stores feature vector (dimension = p)
79- // H - matrix of feature vectors
80- // to set and get feature vectors (i,j)
81- // used formula H[(j * sizeX + i) * p + k], where
82- // k - component of feature vector in cell (i, j)
83- // END OF FILTER DESCRIPTION
84-
85- typedef struct CvLSVMFilterObjectCaskade {
86- CvLSVMFilterPosition V;
87- float fineFunction[4 ];
88- int sizeX;
89- int sizeY;
90- int numFeatures;
91- float *H;
92- float *H_PCA;
93- float Hypothesis, Deformation;
94- float Hypothesis_PCA, Deformation_PCA;
95- int deltaX;
96- int deltaY;
97- } CvLSVMFilterObjectCaskade;
98-
99- // data type: STRUCT CvLatentSvmDetector
100- // structure contains internal representation of trained Latent SVM detector
101- // num_filters - total number of filters (root plus part) in model
102- // num_components - number of components in model
103- // num_part_filters - array containing number of part filters for each component
104- // filters - root and part filters for all model components
105- // b - biases for all model components
106- // score_threshold - confidence level threshold
107-
108- typedef struct CvLatentSvmDetectorCaskade
109- {
110- int num_filters;
111- int num_components;
112- int * num_part_filters;
113- CvLSVMFilterObjectCaskade** filters;
114- float * b;
115- float score_threshold;
116- float *pca;
117- int pca_size;
118- } CvLatentSvmDetectorCaskade;
119-
120- }
121-
12251namespace cv
12352{
12453
125- // /////////////////////////// Object Detection ////////////////////////////
126-
127- /*
128- * This is a class wrapping up the structure CvLatentSvmDetector and functions working with it.
129- * The class goals are:
130- * 1) provide c++ interface;
131- * 2) make it possible to load and detect more than one class (model) unlike CvLatentSvmDetector.
132- */
133-
134- namespace lsvmc
54+ namespace lsvm
13555{
136- class CV_EXPORTS LatentSvmDetector
56+
57+ class CV_EXPORTS_W LSVMDetector
13758{
13859public:
139- struct CV_EXPORTS ObjectDetection
60+
61+ struct CV_EXPORTS_W ObjectDetection
14062 {
14163 ObjectDetection ();
14264 ObjectDetection ( const Rect& rect, float score, int classID=-1 );
@@ -145,26 +67,20 @@ class CV_EXPORTS LatentSvmDetector
14567 int classID;
14668 };
14769
148- LatentSvmDetector () ;
149- LatentSvmDetector ( const std::vector<std::string>& filenames, const std::vector<std::string>& classNames= std::vector<std::string>() );
150- virtual ~LatentSvmDetector () ;
70+ virtual bool isEmpty () const = 0 ;
71+ virtual void detect (cv::Mat const &image, CV_OUT std::vector<ObjectDetection> &objects,
72+ float overlapThreshold= 0 . 5f ) = 0 ;
15173
152- virtual void clear ();
153- virtual bool empty () const ;
154- bool load ( const std::vector<std::string>& filenames, const std::vector<std::string>& classNames=std::vector<std::string>() );
74+ virtual std::vector<std::string> const & getClassNames () const = 0;
75+ virtual size_t getClassCount () const = 0;
15576
156- virtual void detect (const Mat& image,
157- CV_OUT std::vector<ObjectDetection>& objects,
158- float overlapThreshold=0 .5f );
77+ static cv::Ptr<LSVMDetector> create (std::vector<std::string> const &filenames,
78+ std::vector<std::string> const &classNames = std::vector<std::string>());
15979
160- const std::vector<std::string>& getClassNames () const ;
161- size_t getClassCount () const ;
162-
163- private:
164- std::vector<CvLatentSvmDetectorCaskade*> detectors;
165- std::vector<std::string> classNames;
80+ virtual ~LSVMDetector (){}
16681};
167- }
82+
83+ } // namespace lsvm
16884} // namespace cv
16985
17086#endif
0 commit comments