Commit 5c86e4bc authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

Merge pull request #192 from Jiaolong/lasvm_test_path

corrected the testing data path for latentsvm detector and some typos
parents fa4a4c60 75896858
...@@ -49,10 +49,10 @@ namespace cv ...@@ -49,10 +49,10 @@ namespace cv
namespace lsvm namespace lsvm
{ {
float calcM (int k,int di,int dj, const CvLSVMFeaturePyramidCaskade * H, const CvLSVMFilterObjectCaskade *filter); float calcM (int k,int di,int dj, const CvLSVMFeaturePyramidCascade * H, const CvLSVMFilterObjectCascade *filter);
float calcM_PCA (int k,int di,int dj, const CvLSVMFeaturePyramidCaskade * H, const CvLSVMFilterObjectCaskade *filter); float calcM_PCA (int k,int di,int dj, const CvLSVMFeaturePyramidCascade * H, const CvLSVMFilterObjectCascade *filter);
float calcM_PCA_cash(int k,int di,int dj, const CvLSVMFeaturePyramidCaskade * H, const CvLSVMFilterObjectCaskade *filter, float * cashM, int * maskM, int step); float calcM_PCA_cash(int k,int di,int dj, const CvLSVMFeaturePyramidCascade * H, const CvLSVMFilterObjectCascade *filter, float * cashM, int * maskM, int step);
float calcFine (const CvLSVMFilterObjectCaskade *filter, int di, int dj); float calcFine (const CvLSVMFilterObjectCascade *filter, int di, int dj);
} }
} }
#endif #endif
\ No newline at end of file
...@@ -61,29 +61,29 @@ namespace lsvm ...@@ -61,29 +61,29 @@ namespace lsvm
// (pyramid constructed both contrast and non-contrast image) // (pyramid constructed both contrast and non-contrast image)
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
void FeaturePyramid32(CvLSVMFeaturePyramidCaskade* H, int maxX, int maxY); void FeaturePyramid32(CvLSVMFeaturePyramidCascade* H, int maxX, int maxY);
/* /*
// Creation PSA feature pyramid // Creation PCA feature pyramid
// //
// API // API
// featurePyramid* createPSA_FeaturePyramid(featurePyramid* H); // featurePyramid* createPCA_FeaturePyramid(featurePyramid* H);
// INPUT // INPUT
// H - feature pyramid // H - feature pyramid
// OUTPUT // OUTPUT
// RESULT // RESULT
// PSA feature pyramid // PCA feature pyramid
*/ */
CvLSVMFeaturePyramidCaskade* createPCA_FeaturePyramid(CvLSVMFeaturePyramidCaskade* H, CvLSVMFeaturePyramidCascade* createPCA_FeaturePyramid(CvLSVMFeaturePyramidCascade* H,
CvLatentSvmDetectorCaskade* detector, CvLatentSvmDetectorCascade* detector,
int maxX, int maxY); int maxX, int maxY);
/* /*
// Getting feature pyramid // Getting feature pyramid
// //
// API // API
// int getFeaturePyramid(IplImage * image, const CvLSVMFilterObjectCaskade **all_F, // int getFeaturePyramid(IplImage * image, const CvLSVMFilterObjectCascade **all_F,
const int n_f, const int n_f,
const int lambda, const int k, const int lambda, const int k,
const int startX, const int startY, const int startX, const int startY,
...@@ -101,7 +101,7 @@ CvLSVMFeaturePyramidCaskade* createPCA_FeaturePyramid(CvLSVMFeaturePyramidCaskad ...@@ -101,7 +101,7 @@ CvLSVMFeaturePyramidCaskade* createPCA_FeaturePyramid(CvLSVMFeaturePyramidCaskad
// RESULT // RESULT
// Error status // Error status
*/ */
int getFeaturePyramid(IplImage * image, CvLSVMFeaturePyramidCaskade **maps); int getFeaturePyramid(IplImage * image, CvLSVMFeaturePyramidCascade **maps);
/* /*
// Getting feature map for the selected subimage // Getting feature map for the selected subimage
...@@ -116,7 +116,7 @@ int getFeaturePyramid(IplImage * image, CvLSVMFeaturePyramidCaskade **maps); ...@@ -116,7 +116,7 @@ int getFeaturePyramid(IplImage * image, CvLSVMFeaturePyramidCaskade **maps);
// RESULT // RESULT
// Error status // Error status
*/ */
int getFeatureMaps(const IplImage * image, const int k, CvLSVMFeatureMapCaskade **map); int getFeatureMaps(const IplImage * image, const int k, CvLSVMFeatureMapCascade **map);
/* /*
...@@ -132,7 +132,7 @@ int getFeatureMaps(const IplImage * image, const int k, CvLSVMFeatureMapCaskade ...@@ -132,7 +132,7 @@ int getFeatureMaps(const IplImage * image, const int k, CvLSVMFeatureMapCaskade
// RESULT // RESULT
// Error status // Error status
*/ */
int normalizeAndTruncate(CvLSVMFeatureMapCaskade *map, const float alfa); int normalizeAndTruncate(CvLSVMFeatureMapCascade *map, const float alfa);
/* /*
// Feature map reduction // Feature map reduction
...@@ -148,7 +148,7 @@ int normalizeAndTruncate(CvLSVMFeatureMapCaskade *map, const float alfa); ...@@ -148,7 +148,7 @@ int normalizeAndTruncate(CvLSVMFeatureMapCaskade *map, const float alfa);
// RESULT // RESULT
// Error status // Error status
*/ */
int PCAFeatureMaps(CvLSVMFeatureMapCaskade *map); int PCAFeatureMaps(CvLSVMFeatureMapCascade *map);
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
// search object // search object
...@@ -227,7 +227,7 @@ int clippingBoxes(int width, int height, ...@@ -227,7 +227,7 @@ int clippingBoxes(int width, int height,
// RESULT // RESULT
// Feature pyramid with nullable border // Feature pyramid with nullable border
*/ */
CvLSVMFeaturePyramidCaskade* createFeaturePyramidWithBorder(IplImage *image, CvLSVMFeaturePyramidCascade* createFeaturePyramidWithBorder(IplImage *image,
int maxXBorder, int maxYBorder); int maxXBorder, int maxYBorder);
/* /*
...@@ -235,7 +235,7 @@ CvLSVMFeaturePyramidCaskade* createFeaturePyramidWithBorder(IplImage *image, ...@@ -235,7 +235,7 @@ CvLSVMFeaturePyramidCaskade* createFeaturePyramidWithBorder(IplImage *image,
// //
// API // API
// int searchObjectThresholdSomeComponents(const featurePyramid *H, // int searchObjectThresholdSomeComponents(const featurePyramid *H,
const CvLSVMFilterObjectCaskade **filters, const CvLSVMFilterObjectCascade **filters,
int kComponents, const int *kPartFilters, int kComponents, const int *kPartFilters,
const float *b, float scoreThreshold, const float *b, float scoreThreshold,
CvPoint **points, CvPoint **oppPoints, CvPoint **points, CvPoint **oppPoints,
...@@ -255,9 +255,9 @@ CvLSVMFeaturePyramidCaskade* createFeaturePyramidWithBorder(IplImage *image, ...@@ -255,9 +255,9 @@ CvLSVMFeaturePyramidCaskade* createFeaturePyramidWithBorder(IplImage *image,
// RESULT // RESULT
// Error status // Error status
*/ */
int searchObjectThresholdSomeComponents(const CvLSVMFeaturePyramidCaskade *H, int searchObjectThresholdSomeComponents(const CvLSVMFeaturePyramidCascade *H,
const CvLSVMFeaturePyramidCaskade *H_PCA, const CvLSVMFeaturePyramidCascade *H_PCA,
const CvLSVMFilterObjectCaskade **filters, const CvLSVMFilterObjectCascade **filters,
int kComponents, const int *kPartFilters, int kComponents, const int *kPartFilters,
const float *b, float scoreThreshold, const float *b, float scoreThreshold,
CvPoint **points, CvPoint **oppPoints, CvPoint **points, CvPoint **oppPoints,
...@@ -294,7 +294,7 @@ int getOppositePoint(CvPoint point, ...@@ -294,7 +294,7 @@ int getOppositePoint(CvPoint point,
// //
// API // API
// int showRootFilterBoxes(const IplImage *image, // int showRootFilterBoxes(const IplImage *image,
const CvLSVMFilterObjectCaskade *filter, const CvLSVMFilterObjectCascade *filter,
CvPoint *points, int *levels, int kPoints, CvPoint *points, int *levels, int kPoints,
CvScalar color, int thickness, CvScalar color, int thickness,
int line_type, int shift); int line_type, int shift);
...@@ -314,7 +314,7 @@ int getOppositePoint(CvPoint point, ...@@ -314,7 +314,7 @@ int getOppositePoint(CvPoint point,
// Error status // Error status
*/ */
int showRootFilterBoxes(IplImage *image, int showRootFilterBoxes(IplImage *image,
const CvLSVMFilterObjectCaskade *filter, const CvLSVMFilterObjectCascade *filter,
CvPoint *points, int *levels, int kPoints, CvPoint *points, int *levels, int kPoints,
CvScalar color, int thickness, CvScalar color, int thickness,
int line_type, int shift); int line_type, int shift);
...@@ -324,7 +324,7 @@ int showRootFilterBoxes(IplImage *image, ...@@ -324,7 +324,7 @@ int showRootFilterBoxes(IplImage *image,
// //
// API // API
// int showPartFilterBoxes(const IplImage *image, // int showPartFilterBoxes(const IplImage *image,
const CvLSVMFilterObjectCaskade *filter, const CvLSVMFilterObjectCascade *filter,
CvPoint *points, int *levels, int kPoints, CvPoint *points, int *levels, int kPoints,
CvScalar color, int thickness, CvScalar color, int thickness,
int line_type, int shift); int line_type, int shift);
...@@ -345,7 +345,7 @@ int showRootFilterBoxes(IplImage *image, ...@@ -345,7 +345,7 @@ int showRootFilterBoxes(IplImage *image,
// Error status // Error status
*/ */
int showPartFilterBoxes(IplImage *image, int showPartFilterBoxes(IplImage *image,
const CvLSVMFilterObjectCaskade **filters, const CvLSVMFilterObjectCascade **filters,
int n, CvPoint **partsDisplacement, int n, CvPoint **partsDisplacement,
int *levels, int kPoints, int *levels, int kPoints,
CvScalar color, int thickness, CvScalar color, int thickness,
......
...@@ -85,7 +85,7 @@ int computeBorderSize(int maxXBorder, int maxYBorder, int *bx, int *by); ...@@ -85,7 +85,7 @@ int computeBorderSize(int maxXBorder, int maxYBorder, int *bx, int *by);
// RESULT // RESULT
// Error status // Error status
*/ */
int addNullableBorder(CvLSVMFeatureMapCaskade *map, int bx, int by); int addNullableBorder(CvLSVMFeatureMapCascade *map, int bx, int by);
/* /*
// Perform non-maximum suppression algorithm (described in original paper) // Perform non-maximum suppression algorithm (described in original paper)
...@@ -117,12 +117,12 @@ int nonMaximumSuppression(int numBoxes, const CvPoint *points, ...@@ -117,12 +117,12 @@ int nonMaximumSuppression(int numBoxes, const CvPoint *points,
float overlapThreshold, float overlapThreshold,
int *numBoxesOut, CvPoint **pointsOut, int *numBoxesOut, CvPoint **pointsOut,
CvPoint **oppositePointsOut, float **scoreOut); CvPoint **oppositePointsOut, float **scoreOut);
int getMaxFilterDims(const CvLSVMFilterObjectCaskade **filters, int kComponents, int getMaxFilterDims(const CvLSVMFilterObjectCascade **filters, int kComponents,
const int *kPartFilters, const int *kPartFilters,
unsigned int *maxXBorder, unsigned int *maxYBorder); unsigned int *maxXBorder, unsigned int *maxYBorder);
//} //}
int getMaxFilterDims(const CvLSVMFilterObjectCaskade **filters, int kComponents, int getMaxFilterDims(const CvLSVMFilterObjectCascade **filters, int kComponents,
const int *kPartFilters, const int *kPartFilters,
unsigned int *maxXBorder, unsigned int *maxYBorder); unsigned int *maxXBorder, unsigned int *maxYBorder);
} }
......
...@@ -116,7 +116,7 @@ namespace lsvm ...@@ -116,7 +116,7 @@ namespace lsvm
const char *modelPath,// model path const char *modelPath,// model path
// output parametrs // output parametrs
CvLSVMFilterObjectCaskade ***filters, CvLSVMFilterObjectCascade ***filters,
int *kFilters, int *kFilters,
int *kComponents, int *kComponents,
int **kPartFilters, int **kPartFilters,
......
...@@ -58,18 +58,18 @@ namespace lsvm ...@@ -58,18 +58,18 @@ namespace lsvm
// with all fields including arrays // with all fields including arrays
// Error status is return value // Error status is return value
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
int allocFilterObject(CvLSVMFilterObjectCaskade **obj, const int sizeX, const int sizeY, int allocFilterObject(CvLSVMFilterObjectCascade **obj, const int sizeX, const int sizeY,
const int p); const int p);
int freeFilterObject (CvLSVMFilterObjectCaskade **obj); int freeFilterObject (CvLSVMFilterObjectCascade **obj);
int allocFeatureMapObject(CvLSVMFeatureMapCaskade **obj, const int sizeX, const int sizeY, int allocFeatureMapObject(CvLSVMFeatureMapCascade **obj, const int sizeX, const int sizeY,
const int p); const int p);
int freeFeatureMapObject (CvLSVMFeatureMapCaskade **obj); int freeFeatureMapObject (CvLSVMFeatureMapCascade **obj);
int allocFeaturePyramidObject(CvLSVMFeaturePyramidCaskade **obj, int allocFeaturePyramidObject(CvLSVMFeaturePyramidCascade **obj,
const int countLevel); const int countLevel);
int freeFeaturePyramidObject (CvLSVMFeaturePyramidCaskade **obj); int freeFeaturePyramidObject (CvLSVMFeaturePyramidCascade **obj);
} }
} }
......
...@@ -96,7 +96,7 @@ typedef struct{ ...@@ -96,7 +96,7 @@ typedef struct{
int sizeY; int sizeY;
int numFeatures; int numFeatures;
float *map; float *map;
} CvLSVMFeatureMapCaskade; } CvLSVMFeatureMapCascade;
// DataType: STRUCT featurePyramid // DataType: STRUCT featurePyramid
// //
...@@ -104,8 +104,8 @@ typedef struct{ ...@@ -104,8 +104,8 @@ typedef struct{
// pyramid - array of pointers to feature map at different levels // pyramid - array of pointers to feature map at different levels
typedef struct{ typedef struct{
int numLevels; int numLevels;
CvLSVMFeatureMapCaskade **pyramid; CvLSVMFeatureMapCascade **pyramid;
} CvLSVMFeaturePyramidCaskade; } CvLSVMFeaturePyramidCascade;
// DataType: STRUCT filterDisposition // DataType: STRUCT filterDisposition
// The structure stores preliminary results in optimization process // The structure stores preliminary results in optimization process
...@@ -147,7 +147,7 @@ typedef struct CvLSVMFilterPosition ...@@ -147,7 +147,7 @@ typedef struct CvLSVMFilterPosition
// k - component of feature vector in cell (i, j) // k - component of feature vector in cell (i, j)
// END OF FILTER DESCRIPTION // END OF FILTER DESCRIPTION
typedef struct CvLSVMFilterObjectCaskade{ typedef struct CvLSVMFilterObjectCascade{
CvLSVMFilterPosition V; CvLSVMFilterPosition V;
float fineFunction[4]; float fineFunction[4];
int sizeX; int sizeX;
...@@ -159,7 +159,7 @@ typedef struct CvLSVMFilterObjectCaskade{ ...@@ -159,7 +159,7 @@ typedef struct CvLSVMFilterObjectCaskade{
float Hypothesis_PCA, Deformation_PCA; float Hypothesis_PCA, Deformation_PCA;
int deltaX; int deltaX;
int deltaY; int deltaY;
} CvLSVMFilterObjectCaskade; } CvLSVMFilterObjectCascade;
// data type: STRUCT CvLatentSvmDetector // data type: STRUCT CvLatentSvmDetector
// structure contains internal representation of trained Latent SVM detector // structure contains internal representation of trained Latent SVM detector
...@@ -170,17 +170,17 @@ typedef struct CvLSVMFilterObjectCaskade{ ...@@ -170,17 +170,17 @@ typedef struct CvLSVMFilterObjectCaskade{
// b - biases for all model components // b - biases for all model components
// score_threshold - confidence level threshold // score_threshold - confidence level threshold
typedef struct CvLatentSvmDetectorCaskade typedef struct CvLatentSvmDetectorCascade
{ {
int num_filters; int num_filters;
int num_components; int num_components;
int* num_part_filters; int* num_part_filters;
CvLSVMFilterObjectCaskade** filters; CvLSVMFilterObjectCascade** filters;
float* b; float* b;
float score_threshold; float score_threshold;
float *pca; float *pca;
int pca_size; int pca_size;
} CvLatentSvmDetectorCaskade; } CvLatentSvmDetectorCascade;
} }
} }
#endif #endif
...@@ -64,7 +64,7 @@ namespace lsvm ...@@ -64,7 +64,7 @@ namespace lsvm
int getPathOfFeaturePyramid(IplImage * image, int getPathOfFeaturePyramid(IplImage * image,
float step, int numStep, int startIndex, float step, int numStep, int startIndex,
int sideLength, CvLSVMFeaturePyramidCaskade **maps); int sideLength, CvLSVMFeaturePyramidCascade **maps);
/* /*
// Getting feature map for the selected subimage // Getting feature map for the selected subimage
...@@ -79,7 +79,7 @@ int getPathOfFeaturePyramid(IplImage * image, ...@@ -79,7 +79,7 @@ int getPathOfFeaturePyramid(IplImage * image,
// RESULT // RESULT
// Error status // Error status
*/ */
int getFeatureMaps(const IplImage* image, const int k, CvLSVMFeatureMapCaskade **map) int getFeatureMaps(const IplImage* image, const int k, CvLSVMFeatureMapCascade **map)
{ {
int sizeX, sizeY; int sizeX, sizeY;
int p, px, stringSize; int p, px, stringSize;
...@@ -289,7 +289,7 @@ int getFeatureMaps(const IplImage* image, const int k, CvLSVMFeatureMapCaskade * ...@@ -289,7 +289,7 @@ int getFeatureMaps(const IplImage* image, const int k, CvLSVMFeatureMapCaskade *
// RESULT // RESULT
// Error status // Error status
*/ */
int normalizeAndTruncate(CvLSVMFeatureMapCaskade *map, const float alfa) int normalizeAndTruncate(CvLSVMFeatureMapCascade *map, const float alfa)
{ {
int i,j, ii; int i,j, ii;
int sizeX, sizeY, p, pos, pp, xp, pos1, pos2; int sizeX, sizeY, p, pos, pp, xp, pos1, pos2;
...@@ -413,7 +413,7 @@ int normalizeAndTruncate(CvLSVMFeatureMapCaskade *map, const float alfa) ...@@ -413,7 +413,7 @@ int normalizeAndTruncate(CvLSVMFeatureMapCaskade *map, const float alfa)
// RESULT // RESULT
// Error status // Error status
*/ */
int PCAFeatureMaps(CvLSVMFeatureMapCaskade *map) int PCAFeatureMaps(CvLSVMFeatureMapCascade *map)
{ {
int i,j, ii, jj, k; int i,j, ii, jj, k;
int sizeX, sizeY, p, pp, xp, yp, pos1, pos2; int sizeX, sizeY, p, pp, xp, yp, pos1, pos2;
...@@ -485,9 +485,9 @@ int PCAFeatureMaps(CvLSVMFeatureMapCaskade *map) ...@@ -485,9 +485,9 @@ int PCAFeatureMaps(CvLSVMFeatureMapCaskade *map)
int getPathOfFeaturePyramid(IplImage * image, int getPathOfFeaturePyramid(IplImage * image,
float step, int numStep, int startIndex, float step, int numStep, int startIndex,
int sideLength, CvLSVMFeaturePyramidCaskade **maps) int sideLength, CvLSVMFeaturePyramidCascade **maps)
{ {
CvLSVMFeatureMapCaskade *map; CvLSVMFeatureMapCascade *map;
IplImage *scaleTmp; IplImage *scaleTmp;
float scale; float scale;
int i; int i;
...@@ -513,11 +513,11 @@ public: ...@@ -513,11 +513,11 @@ public:
float step; float step;
int startIndex; int startIndex;
int sideLength; int sideLength;
CvLSVMFeaturePyramidCaskade **maps; CvLSVMFeaturePyramidCascade **maps;
void operator() (const Range& range) const void operator() (const Range& range) const
{ {
CvLSVMFeatureMapCaskade *map; CvLSVMFeatureMapCascade *map;
IplImage *scaleTmp; IplImage *scaleTmp;
float scale; float scale;
int err; int err;
...@@ -538,7 +538,7 @@ public: ...@@ -538,7 +538,7 @@ public:
int getPathOfFeaturePyramid_TBB(IplImage * image, int getPathOfFeaturePyramid_TBB(IplImage * image,
float step, int numStep, int startIndex, float step, int numStep, int startIndex,
int sideLength, CvLSVMFeaturePyramidCaskade **maps) int sideLength, CvLSVMFeaturePyramidCascade **maps)
{ {
PathOfFeaturePyramid str; PathOfFeaturePyramid str;
str.step = step; str.step = step;
...@@ -557,7 +557,7 @@ int getPathOfFeaturePyramid_TBB(IplImage * image, ...@@ -557,7 +557,7 @@ int getPathOfFeaturePyramid_TBB(IplImage * image,
// Getting feature pyramid // Getting feature pyramid
// //
// API // API
// int getFeaturePyramid(IplImage * image, const CvLSVMFilterObjectCaskade **all_F, // int getFeaturePyramid(IplImage * image, const CvLSVMFilterObjectCascade **all_F,
const int n_f, const int n_f,
const int lambda, const int k, const int lambda, const int k,
const int startX, const int startY, const int startX, const int startY,
...@@ -569,7 +569,7 @@ int getPathOfFeaturePyramid_TBB(IplImage * image, ...@@ -569,7 +569,7 @@ int getPathOfFeaturePyramid_TBB(IplImage * image,
// RESULT // RESULT
// Error status // Error status
*/ */
int getFeaturePyramid(IplImage * image, CvLSVMFeaturePyramidCaskade **maps) int getFeaturePyramid(IplImage * image, CvLSVMFeaturePyramidCascade **maps)
{ {
IplImage *imgResize; IplImage *imgResize;
float step; float step;
......
...@@ -46,7 +46,7 @@ namespace cv ...@@ -46,7 +46,7 @@ namespace cv
namespace lsvm namespace lsvm
{ {
float calcM (int k,int di,int dj, const CvLSVMFeaturePyramidCaskade * H, const CvLSVMFilterObjectCaskade *filter){ float calcM (int k,int di,int dj, const CvLSVMFeaturePyramidCascade * H, const CvLSVMFilterObjectCascade *filter){
int i, j; int i, j;
float m = 0.0f; float m = 0.0f;
for(j = dj; j < dj + filter->sizeY; j++){ for(j = dj; j < dj + filter->sizeY; j++){
...@@ -57,7 +57,7 @@ float calcM (int k,int di,int dj, const CvLSVMFeaturePyramidCaskade * H, cons ...@@ -57,7 +57,7 @@ float calcM (int k,int di,int dj, const CvLSVMFeaturePyramidCaskade * H, cons
} }
return m; return m;
} }
float calcM_PCA(int k,int di,int dj, const CvLSVMFeaturePyramidCaskade * H, const CvLSVMFilterObjectCaskade *filter){ float calcM_PCA(int k,int di,int dj, const CvLSVMFeaturePyramidCascade * H, const CvLSVMFilterObjectCascade *filter){
int i, j; int i, j;
float m = 0.0f; float m = 0.0f;
for(j = dj; j < dj + filter->sizeY; j++){ for(j = dj; j < dj + filter->sizeY; j++){
...@@ -69,7 +69,7 @@ float calcM_PCA(int k,int di,int dj, const CvLSVMFeaturePyramidCaskade * H, cons ...@@ -69,7 +69,7 @@ float calcM_PCA(int k,int di,int dj, const CvLSVMFeaturePyramidCaskade * H, cons
return m; return m;
} }
float calcM_PCA_cash(int k,int di,int dj, const CvLSVMFeaturePyramidCaskade * H, const CvLSVMFilterObjectCaskade *filter, float * cashM, int * maskM, int step){ float calcM_PCA_cash(int k,int di,int dj, const CvLSVMFeaturePyramidCascade * H, const CvLSVMFilterObjectCascade *filter, float * cashM, int * maskM, int step){
int i, j, n; int i, j, n;
float m = 0.0f; float m = 0.0f;
float tmp1, tmp2, tmp3, tmp4; float tmp1, tmp2, tmp3, tmp4;
...@@ -119,7 +119,7 @@ float calcM_PCA_cash(int k,int di,int dj, const CvLSVMFeaturePyramidCaskade * H, ...@@ -119,7 +119,7 @@ float calcM_PCA_cash(int k,int di,int dj, const CvLSVMFeaturePyramidCaskade * H,
} }
return m; return m;
} }
float calcFine (const CvLSVMFilterObjectCaskade *filter, int di, int dj){ float calcFine (const CvLSVMFilterObjectCascade *filter, int di, int dj){
return filter->fineFunction[0] * di + filter->fineFunction[1] * dj + return filter->fineFunction[0] * di + filter->fineFunction[1] * dj +
filter->fineFunction[2] * di * di + filter->fineFunction[3] * dj * dj; filter->fineFunction[2] * di * di + filter->fineFunction[3] * dj * dj;
} }
......
...@@ -58,17 +58,17 @@ namespace lsvm ...@@ -58,17 +58,17 @@ namespace lsvm
int estimateBoxes(CvPoint *points, int *levels, int kPoints, int estimateBoxes(CvPoint *points, int *levels, int kPoints,
int sizeX, int sizeY, CvPoint **oppositePoints); int sizeX, int sizeY, CvPoint **oppositePoints);
int searchObjectThreshold(const CvLSVMFeaturePyramidCaskade *H, int searchObjectThreshold(const CvLSVMFeaturePyramidCascade *H,
const CvLSVMFeaturePyramidCaskade *H_PCA, const CvLSVMFeaturePyramidCascade *H_PCA,
const CvLSVMFilterObjectCaskade **all_F, int n, const CvLSVMFilterObjectCascade **all_F, int n,
float b, float b,
int maxXBorder, int maxYBorder, int maxXBorder, int maxYBorder,
float scoreThreshold, float scoreThreshold,
CvPoint **points, int **levels, int *kPoints, CvPoint **points, int **levels, int *kPoints,
float **score, CvPoint ***partsDisplacement); float **score, CvPoint ***partsDisplacement);
void FeaturePyramid32(CvLSVMFeaturePyramidCaskade* H, int maxX, int maxY){ void FeaturePyramid32(CvLSVMFeaturePyramidCascade* H, int maxX, int maxY){
CvLSVMFeatureMapCaskade *H32; CvLSVMFeatureMapCascade *H32;
int i, j, k, l; int i, j, k, l;
int p = H->pyramid[0]->numFeatures; int p = H->pyramid[0]->numFeatures;
...@@ -92,8 +92,8 @@ void FeaturePyramid32(CvLSVMFeaturePyramidCaskade* H, int maxX, int maxY){ ...@@ -92,8 +92,8 @@ void FeaturePyramid32(CvLSVMFeaturePyramidCaskade* H, int maxX, int maxY){
} }
} }
CvLSVMFeaturePyramidCaskade* createPCA_FeaturePyramid(CvLSVMFeaturePyramidCaskade* H, CvLatentSvmDetectorCaskade* detector, int maxX, int maxY){ CvLSVMFeaturePyramidCascade* createPCA_FeaturePyramid(CvLSVMFeaturePyramidCascade* H, CvLatentSvmDetectorCascade* detector, int maxX, int maxY){
CvLSVMFeaturePyramidCaskade *H_PCA; CvLSVMFeaturePyramidCascade *H_PCA;
int i, j, k, l; int i, j, k, l;
int max_l = detector->pca_size; int max_l = detector->pca_size;
int p = H->pyramid[0]->numFeatures; int p = H->pyramid[0]->numFeatures;
...@@ -239,13 +239,13 @@ int clippingBoxes(int width, int height, ...@@ -239,13 +239,13 @@ int clippingBoxes(int width, int height,
// RESULT // RESULT
// Feature pyramid with nullable border // Feature pyramid with nullable border
*/ */
CvLSVMFeaturePyramidCaskade* createFeaturePyramidWithBorder(IplImage *image, CvLSVMFeaturePyramidCascade* createFeaturePyramidWithBorder(IplImage *image,
int maxXBorder, int maxYBorder) int maxXBorder, int maxYBorder)
{ {
int opResult; int opResult;
int bx, by; int bx, by;
int level; int level;
CvLSVMFeaturePyramidCaskade *H; CvLSVMFeaturePyramidCascade *H;
// Obtaining feature pyramid // Obtaining feature pyramid
opResult = getFeaturePyramid(image, &H); opResult = getFeaturePyramid(image, &H);
...@@ -303,7 +303,7 @@ int estimateBoxes(CvPoint *points, int *levels, int kPoints, ...@@ -303,7 +303,7 @@ int estimateBoxes(CvPoint *points, int *levels, int kPoints,
// //
// API // API
// int searchObjectThreshold(const featurePyramid *H, // int searchObjectThreshold(const featurePyramid *H,
const CvLSVMFilterObjectCaskade **all_F, int n, const CvLSVMFilterObjectCascade **all_F, int n,
float b, float b,
int maxXBorder, int maxYBorder, int maxXBorder, int maxYBorder,
float scoreThreshold, float scoreThreshold,
...@@ -329,9 +329,9 @@ int estimateBoxes(CvPoint *points, int *levels, int kPoints, ...@@ -329,9 +329,9 @@ int estimateBoxes(CvPoint *points, int *levels, int kPoints,
// RESULT // RESULT
// Error status // Error status
*/ */
int searchObjectThreshold(const CvLSVMFeaturePyramidCaskade *H, int searchObjectThreshold(const CvLSVMFeaturePyramidCascade *H,
const CvLSVMFeaturePyramidCaskade *H_PCA, const CvLSVMFeaturePyramidCascade *H_PCA,
const CvLSVMFilterObjectCaskade **all_F, int n, const CvLSVMFilterObjectCascade **all_F, int n,
float b, float b,
int maxXBorder, int maxYBorder, int maxXBorder, int maxYBorder,
float scoreThreshold, float scoreThreshold,
...@@ -630,7 +630,7 @@ int getOppositePoint(CvPoint point, ...@@ -630,7 +630,7 @@ int getOppositePoint(CvPoint point,
// //
// API // API
// int showRootFilterBoxes(const IplImage *image, // int showRootFilterBoxes(const IplImage *image,
const CvLSVMFilterObjectCaskade *filter, const CvLSVMFilterObjectCascade *filter,
CvPoint *points, int *levels, int kPoints, CvPoint *points, int *levels, int kPoints,
CvScalar color, int thickness, CvScalar color, int thickness,
int line_type, int shift); int line_type, int shift);
...@@ -650,7 +650,7 @@ int getOppositePoint(CvPoint point, ...@@ -650,7 +650,7 @@ int getOppositePoint(CvPoint point,
// Error status // Error status
*/ */
int showRootFilterBoxes(IplImage *image, int showRootFilterBoxes(IplImage *image,
const CvLSVMFilterObjectCaskade *filter, const CvLSVMFilterObjectCascade *filter,
CvPoint *points, int *levels, int kPoints, CvPoint *points, int *levels, int kPoints,
CvScalar color, int thickness, CvScalar color, int thickness,
int line_type, int shift) int line_type, int shift)
...@@ -679,7 +679,7 @@ int showRootFilterBoxes(IplImage *image, ...@@ -679,7 +679,7 @@ int showRootFilterBoxes(IplImage *image,
// //
// API // API
// int showPartFilterBoxes(const IplImage *image, // int showPartFilterBoxes(const IplImage *image,
const CvLSVMFilterObjectCaskade *filter, const CvLSVMFilterObjectCascade *filter,
CvPoint *points, int *levels, int kPoints, CvPoint *points, int *levels, int kPoints,
CvScalar color, int thickness, CvScalar color, int thickness,
int line_type, int shift); int line_type, int shift);
...@@ -700,7 +700,7 @@ int showRootFilterBoxes(IplImage *image, ...@@ -700,7 +700,7 @@ int showRootFilterBoxes(IplImage *image,
// Error status // Error status
*/ */
int showPartFilterBoxes(IplImage *image, int showPartFilterBoxes(IplImage *image,
const CvLSVMFilterObjectCaskade **filters, const CvLSVMFilterObjectCascade **filters,
int n, CvPoint **partsDisplacement, int n, CvPoint **partsDisplacement,
int *levels, int kPoints, int *levels, int kPoints,
CvScalar color, int thickness, CvScalar color, int thickness,
...@@ -770,7 +770,7 @@ int showBoxes(IplImage *img, ...@@ -770,7 +770,7 @@ int showBoxes(IplImage *img,
//// Computation maximum filter size for each dimension //// Computation maximum filter size for each dimension
//// ////
//// API //// API
//// int getMaxFilterDims(const CvLSVMFilterObjectCaskade **filters, int kComponents, //// int getMaxFilterDims(const CvLSVMFilterObjectCascade **filters, int kComponents,
// const int *kPartFilters, // const int *kPartFilters,
// unsigned int *maxXBorder, unsigned int *maxYBorder); // unsigned int *maxXBorder, unsigned int *maxYBorder);
//// INPUT //// INPUT
...@@ -784,7 +784,7 @@ int showBoxes(IplImage *img, ...@@ -784,7 +784,7 @@ int showBoxes(IplImage *img,
//// RESULT //// RESULT
//// Error status //// Error status
//*/ //*/
//int getMaxFilterDims(const CvLSVMFilterObjectCaskade **filters, int kComponents, //int getMaxFilterDims(const CvLSVMFilterObjectCascade **filters, int kComponents,
// const int *kPartFilters, // const int *kPartFilters,
// unsigned int *maxXBorder, unsigned int *maxYBorder) // unsigned int *maxXBorder, unsigned int *maxYBorder)
//{ //{
...@@ -812,9 +812,9 @@ int showBoxes(IplImage *img, ...@@ -812,9 +812,9 @@ int showBoxes(IplImage *img,
class PathOfModel :public ParallelLoopBody{ class PathOfModel :public ParallelLoopBody{
int *componentIndex; int *componentIndex;
const CvLSVMFeaturePyramidCaskade *H; const CvLSVMFeaturePyramidCascade *H;
const CvLSVMFeaturePyramidCaskade *H_PCA; const CvLSVMFeaturePyramidCascade *H_PCA;
const CvLSVMFilterObjectCaskade **filters; const CvLSVMFilterObjectCascade **filters;
const int *kPartFilters; const int *kPartFilters;
const float *b; const float *b;
unsigned int maxXBorder, maxYBorder; unsigned int maxXBorder, maxYBorder;
...@@ -826,9 +826,9 @@ class PathOfModel :public ParallelLoopBody{ ...@@ -826,9 +826,9 @@ class PathOfModel :public ParallelLoopBody{
public: public:
PathOfModel( PathOfModel(
int *_componentIndex, int *_componentIndex,
const CvLSVMFeaturePyramidCaskade *_H, const CvLSVMFeaturePyramidCascade *_H,
const CvLSVMFeaturePyramidCaskade *_H_PCA, const CvLSVMFeaturePyramidCascade *_H_PCA,
const CvLSVMFilterObjectCaskade **_filters, const CvLSVMFilterObjectCascade **_filters,
const int *_kPartFilters, const int *_kPartFilters,
const float *_b, const float *_b,
unsigned int _maxXBorder, unsigned int _maxYBorder, unsigned int _maxXBorder, unsigned int _maxYBorder,
...@@ -878,7 +878,7 @@ public: ...@@ -878,7 +878,7 @@ public:
// //
// API // API
// int searchObjectThresholdSomeComponents(const featurePyramid *H, // int searchObjectThresholdSomeComponents(const featurePyramid *H,
const CvLSVMFilterObjectCaskade **filters, const CvLSVMFilterObjectCascade **filters,
int kComponents, const int *kPartFilters, int kComponents, const int *kPartFilters,
const float *b, float scoreThreshold, const float *b, float scoreThreshold,
CvPoint **points, CvPoint **oppPoints, CvPoint **points, CvPoint **oppPoints,
...@@ -898,9 +898,9 @@ public: ...@@ -898,9 +898,9 @@ public:
// RESULT // RESULT
// Error status // Error status
*/ */
int searchObjectThresholdSomeComponents(const CvLSVMFeaturePyramidCaskade *H, int searchObjectThresholdSomeComponents(const CvLSVMFeaturePyramidCascade *H,
const CvLSVMFeaturePyramidCaskade *H_PCA, const CvLSVMFeaturePyramidCascade *H_PCA,
const CvLSVMFilterObjectCaskade **filters, const CvLSVMFilterObjectCascade **filters,
int kComponents, const int *kPartFilters, int kComponents, const int *kPartFilters,
const float *b, float scoreThreshold, const float *b, float scoreThreshold,
CvPoint **points, CvPoint **oppPoints, CvPoint **points, CvPoint **oppPoints,
......
...@@ -51,10 +51,10 @@ std::string extractModelName( const std::string& filename ); ...@@ -51,10 +51,10 @@ std::string extractModelName( const std::string& filename );
const int pca_size = 31; const int pca_size = 31;
CvLatentSvmDetectorCaskade* cvLoadLatentSvmDetectorCaskade(const char* filename); CvLatentSvmDetectorCascade* cvLoadLatentSvmDetectorCascade(const char* filename);
void cvReleaseLatentSvmDetectorCaskade(CvLatentSvmDetectorCaskade** detector); void cvReleaseLatentSvmDetectorCascade(CvLatentSvmDetectorCascade** detector);
CvSeq* cvLatentSvmDetectObjectsCaskade(IplImage* image, CvSeq* cvLatentSvmDetectObjectsCascade(IplImage* image,
CvLatentSvmDetectorCaskade* detector, CvLatentSvmDetectorCascade* detector,
CvMemStorage* storage, CvMemStorage* storage,
float overlap_threshold); float overlap_threshold);
...@@ -62,17 +62,17 @@ CvSeq* cvLatentSvmDetectObjectsCaskade(IplImage* image, ...@@ -62,17 +62,17 @@ CvSeq* cvLatentSvmDetectObjectsCaskade(IplImage* image,
// load trained detector from a file // load trained detector from a file
// //
// API // API
// CvLatentSvmDetectorCaskade* cvLoadLatentSvmDetector(const char* filename); // CvLatentSvmDetectorCascade* cvLoadLatentSvmDetector(const char* filename);
// INPUT // INPUT
// filename - path to the file containing the parameters of // filename - path to the file containing the parameters of
// - trained Latent SVM detector // - trained Latent SVM detector
// OUTPUT // OUTPUT
// trained Latent SVM detector in internal representation // trained Latent SVM detector in internal representation
*/ */
CvLatentSvmDetectorCaskade* cvLoadLatentSvmDetectorCaskade(const char* filename) CvLatentSvmDetectorCascade* cvLoadLatentSvmDetectorCascade(const char* filename)
{ {
CvLatentSvmDetectorCaskade* detector = 0; CvLatentSvmDetectorCascade* detector = 0;
CvLSVMFilterObjectCaskade** filters = 0; CvLSVMFilterObjectCascade** filters = 0;
int kFilters = 0; int kFilters = 0;
int kComponents = 0; int kComponents = 0;
int* kPartFilters = 0; int* kPartFilters = 0;
...@@ -84,7 +84,7 @@ CvLatentSvmDetectorCaskade* cvLoadLatentSvmDetectorCaskade(const char* filename) ...@@ -84,7 +84,7 @@ CvLatentSvmDetectorCaskade* cvLoadLatentSvmDetectorCaskade(const char* filename)
err_code = loadModel(filename, &filters, &kFilters, &kComponents, &kPartFilters, &b, &scoreThreshold, &PCAcoeff); err_code = loadModel(filename, &filters, &kFilters, &kComponents, &kPartFilters, &b, &scoreThreshold, &PCAcoeff);
if (err_code != LATENT_SVM_OK) return 0; if (err_code != LATENT_SVM_OK) return 0;
detector = (CvLatentSvmDetectorCaskade*)malloc(sizeof(CvLatentSvmDetectorCaskade)); detector = (CvLatentSvmDetectorCascade*)malloc(sizeof(CvLatentSvmDetectorCascade));
detector->filters = filters; detector->filters = filters;
detector->b = b; detector->b = b;
detector->num_components = kComponents; detector->num_components = kComponents;
...@@ -98,15 +98,15 @@ CvLatentSvmDetectorCaskade* cvLoadLatentSvmDetectorCaskade(const char* filename) ...@@ -98,15 +98,15 @@ CvLatentSvmDetectorCaskade* cvLoadLatentSvmDetectorCaskade(const char* filename)
} }
/* /*
// release memory allocated for CvLatentSvmDetectorCaskade structure // release memory allocated for CvLatentSvmDetectorCascade structure
// //
// API // API
// void cvReleaseLatentSvmDetector(CvLatentSvmDetectorCaskade** detector); // void cvReleaseLatentSvmDetector(CvLatentSvmDetectorCascade** detector);
// INPUT // INPUT
// detector - CvLatentSvmDetectorCaskade structure to be released // detector - CvLatentSvmDetectorCascade structure to be released
// OUTPUT // OUTPUT
*/ */
void cvReleaseLatentSvmDetectorCaskade(CvLatentSvmDetectorCaskade** detector) void cvReleaseLatentSvmDetectorCascade(CvLatentSvmDetectorCascade** detector)
{ {
free((*detector)->b); free((*detector)->b);
free((*detector)->num_part_filters); free((*detector)->num_part_filters);
...@@ -127,7 +127,7 @@ void cvReleaseLatentSvmDetectorCaskade(CvLatentSvmDetectorCaskade** detector) ...@@ -127,7 +127,7 @@ void cvReleaseLatentSvmDetectorCaskade(CvLatentSvmDetectorCaskade** detector)
// //
// API // API
// CvSeq* cvLatentSvmDetectObjects(const IplImage* image, // CvSeq* cvLatentSvmDetectObjects(const IplImage* image,
// CvLatentSvmDetectorCaskade* detector, // CvLatentSvmDetectorCascade* detector,
// CvMemStorage* storage, // CvMemStorage* storage,
// float overlap_threshold = 0.5f); // float overlap_threshold = 0.5f);
// INPUT // INPUT
...@@ -139,13 +139,13 @@ void cvReleaseLatentSvmDetectorCaskade(CvLatentSvmDetectorCaskade** detector) ...@@ -139,13 +139,13 @@ void cvReleaseLatentSvmDetectorCaskade(CvLatentSvmDetectorCaskade** detector)
// OUTPUT // OUTPUT
// sequence of detected objects (bounding boxes and confidence levels stored in CvObjectDetection structures) // sequence of detected objects (bounding boxes and confidence levels stored in CvObjectDetection structures)
*/ */
CvSeq* cvLatentSvmDetectObjectsCaskade(IplImage* image, CvSeq* cvLatentSvmDetectObjectsCascade(IplImage* image,
CvLatentSvmDetectorCaskade* detector, CvLatentSvmDetectorCascade* detector,
CvMemStorage* storage, CvMemStorage* storage,
float overlap_threshold) float overlap_threshold)
{ {
CvLSVMFeaturePyramidCaskade *H = 0; CvLSVMFeaturePyramidCascade *H = 0;
CvLSVMFeaturePyramidCaskade *H_PCA = 0; CvLSVMFeaturePyramidCascade *H_PCA = 0;
CvPoint *points = 0, *oppPoints = 0; CvPoint *points = 0, *oppPoints = 0;
int kPoints = 0; int kPoints = 0;
float *score = 0; float *score = 0;
...@@ -161,18 +161,18 @@ CvSeq* cvLatentSvmDetectObjectsCaskade(IplImage* image, ...@@ -161,18 +161,18 @@ CvSeq* cvLatentSvmDetectObjectsCaskade(IplImage* image,
cvCvtColor(image, image, CV_BGR2RGB); cvCvtColor(image, image, CV_BGR2RGB);
// Getting maximum filter dimensions // Getting maximum filter dimensions
getMaxFilterDims((const CvLSVMFilterObjectCaskade**)(detector->filters), detector->num_components, getMaxFilterDims((const CvLSVMFilterObjectCascade**)(detector->filters), detector->num_components,
detector->num_part_filters, &maxXBorder, &maxYBorder); detector->num_part_filters, &maxXBorder, &maxYBorder);
// Create feature pyramid with nullable border // Create feature pyramid with nullable border
H = createFeaturePyramidWithBorder(image, maxXBorder, maxYBorder); H = createFeaturePyramidWithBorder(image, maxXBorder, maxYBorder);
// Create PSA feature pyramid // Create PCA feature pyramid
H_PCA = createPCA_FeaturePyramid(H, detector, maxXBorder, maxYBorder); H_PCA = createPCA_FeaturePyramid(H, detector, maxXBorder, maxYBorder);
FeaturePyramid32(H, maxXBorder, maxYBorder); FeaturePyramid32(H, maxXBorder, maxYBorder);
// Search object // Search object
error = searchObjectThresholdSomeComponents(H, H_PCA,(const CvLSVMFilterObjectCaskade**)(detector->filters), error = searchObjectThresholdSomeComponents(H, H_PCA,(const CvLSVMFilterObjectCascade**)(detector->filters),
detector->num_components, detector->num_part_filters, detector->b, detector->score_threshold, detector->num_components, detector->num_part_filters, detector->b, detector->score_threshold,
&points, &oppPoints, &score, &kPoints); &points, &oppPoints, &score, &kPoints);
if (error != LATENT_SVM_OK) if (error != LATENT_SVM_OK)
...@@ -226,7 +226,7 @@ public: ...@@ -226,7 +226,7 @@ public:
size_t getClassCount() const; size_t getClassCount() const;
private: private:
std::vector<CvLatentSvmDetectorCaskade*> detectors; std::vector<CvLatentSvmDetectorCascade*> detectors;
std::vector<std::string> classNames; std::vector<std::string> classNames;
}; };
...@@ -250,7 +250,7 @@ LSVMDetectorImpl::LSVMDetectorImpl( const std::vector<std::string>& filenames, c ...@@ -250,7 +250,7 @@ LSVMDetectorImpl::LSVMDetectorImpl( const std::vector<std::string>& filenames, c
if( filename.length() < 5 || filename.substr(filename.length()-4, 4) != ".xml" ) if( filename.length() < 5 || filename.substr(filename.length()-4, 4) != ".xml" )
continue; continue;
CvLatentSvmDetectorCaskade* detector = cvLoadLatentSvmDetectorCaskade( filename.c_str() ); CvLatentSvmDetectorCascade* detector = cvLoadLatentSvmDetectorCascade( filename.c_str() );
if( detector ) if( detector )
{ {
detectors.push_back( detector ); detectors.push_back( detector );
...@@ -267,7 +267,7 @@ LSVMDetectorImpl::LSVMDetectorImpl( const std::vector<std::string>& filenames, c ...@@ -267,7 +267,7 @@ LSVMDetectorImpl::LSVMDetectorImpl( const std::vector<std::string>& filenames, c
LSVMDetectorImpl::~LSVMDetectorImpl() LSVMDetectorImpl::~LSVMDetectorImpl()
{ {
for(size_t i = 0; i < detectors.size(); i++) for(size_t i = 0; i < detectors.size(); i++)
cv::lsvm::cvReleaseLatentSvmDetectorCaskade(&detectors[i]); cv::lsvm::cvReleaseLatentSvmDetectorCascade(&detectors[i]);
} }
bool LSVMDetectorImpl::isEmpty() const bool LSVMDetectorImpl::isEmpty() const
...@@ -313,7 +313,7 @@ void LSVMDetectorImpl::detect( cv::Mat const &image, ...@@ -313,7 +313,7 @@ void LSVMDetectorImpl::detect( cv::Mat const &image,
{ {
IplImage image_ipl = image; IplImage image_ipl = image;
CvMemStorage* storage = cvCreateMemStorage(0); CvMemStorage* storage = cvCreateMemStorage(0);
CvSeq* detections = cv::lsvm::cvLatentSvmDetectObjectsCaskade( &image_ipl, (CvLatentSvmDetectorCaskade*)(detectors[classID]), storage, overlapThreshold); CvSeq* detections = cv::lsvm::cvLatentSvmDetectObjectsCascade( &image_ipl, (CvLatentSvmDetectorCascade*)(detectors[classID]), storage, overlapThreshold);
// convert results // convert results
objectDetections.reserve( objectDetections.size() + detections->total ); objectDetections.reserve( objectDetections.size() + detections->total );
......
...@@ -91,7 +91,7 @@ int computeBorderSize(int maxXBorder, int maxYBorder, int *bx, int *by) ...@@ -91,7 +91,7 @@ int computeBorderSize(int maxXBorder, int maxYBorder, int *bx, int *by)
// RESULT // RESULT
// Error status // Error status
*/ */
int addNullableBorder(CvLSVMFeatureMapCaskade *map, int bx, int by) int addNullableBorder(CvLSVMFeatureMapCascade *map, int bx, int by)
{ {
int sizeX, sizeY, i, j, k; int sizeX, sizeY, i, j, k;
float *new_map; float *new_map;
...@@ -124,7 +124,7 @@ int addNullableBorder(CvLSVMFeatureMapCaskade *map, int bx, int by) ...@@ -124,7 +124,7 @@ int addNullableBorder(CvLSVMFeatureMapCaskade *map, int bx, int by)
// Computation maximum filter size for each dimension // Computation maximum filter size for each dimension
// //
// API // API
// int getMaxFilterDims(const CvLSVMFilterObjectCaskade **filters, int kComponents, // int getMaxFilterDims(const CvLSVMFilterObjectCascade **filters, int kComponents,
const int *kPartFilters, const int *kPartFilters,
unsigned int *maxXBorder, unsigned int *maxYBorder); unsigned int *maxXBorder, unsigned int *maxYBorder);
// INPUT // INPUT
...@@ -138,7 +138,7 @@ int addNullableBorder(CvLSVMFeatureMapCaskade *map, int bx, int by) ...@@ -138,7 +138,7 @@ int addNullableBorder(CvLSVMFeatureMapCaskade *map, int bx, int by)
// RESULT // RESULT
// Error status // Error status
*/ */
int getMaxFilterDims(const CvLSVMFilterObjectCaskade **filters, int kComponents, int getMaxFilterDims(const CvLSVMFilterObjectCascade **filters, int kComponents,
const int *kPartFilters, const int *kPartFilters,
unsigned int *maxXBorder, unsigned int *maxYBorder) unsigned int *maxXBorder, unsigned int *maxYBorder)
{ {
......
...@@ -79,26 +79,26 @@ int isHYPOTHES (char *str); ...@@ -79,26 +79,26 @@ int isHYPOTHES (char *str);
int isDEFORM (char *str); int isDEFORM (char *str);
int getTeg (char *str); int getTeg (char *str);
void addFilter(CvLSVMFilterObjectCaskade *** model, int *last, int *max); void addFilter(CvLSVMFilterObjectCascade *** model, int *last, int *max);
void parserCascadeThresholds (FILE * xmlf, CvLSVMFilterObjectCaskade * model); void parserCascadeThresholds (FILE * xmlf, CvLSVMFilterObjectCascade * model);
void parserRFilter (FILE * xmlf, int p, int pca, CvLSVMFilterObjectCaskade * model, float *b); void parserRFilter (FILE * xmlf, int p, int pca, CvLSVMFilterObjectCascade * model, float *b);
void parserV (FILE * xmlf, int /*p*/, CvLSVMFilterObjectCaskade * model); void parserV (FILE * xmlf, int /*p*/, CvLSVMFilterObjectCascade * model);
void parserD (FILE * xmlf, int /*p*/, CvLSVMFilterObjectCaskade * model); void parserD (FILE * xmlf, int /*p*/, CvLSVMFilterObjectCascade * model);
void parserPFilter (FILE * xmlf, int p, int pca, int /*N_path*/, CvLSVMFilterObjectCaskade * model); void parserPFilter (FILE * xmlf, int p, int pca, int /*N_path*/, CvLSVMFilterObjectCascade * model);
void parserPFilterS (FILE * xmlf, int p, int pca, CvLSVMFilterObjectCaskade *** model, int *last, int *max); void parserPFilterS (FILE * xmlf, int p, int pca, CvLSVMFilterObjectCascade *** model, int *last, int *max);
void parserComp (FILE * xmlf, int p, int pca, int *N_comp, CvLSVMFilterObjectCaskade *** model, float *b, int *last, int *max); void parserComp (FILE * xmlf, int p, int pca, int *N_comp, CvLSVMFilterObjectCascade *** model, float *b, int *last, int *max);
void parserModel(FILE * xmlf, CvLSVMFilterObjectCaskade *** model, int *last, int *max, int **comp, float **b, int *count, float * score, float** PCAcoeff); void parserModel(FILE * xmlf, CvLSVMFilterObjectCascade *** model, int *last, int *max, int **comp, float **b, int *count, float * score, float** PCAcoeff);
void LSVMparser(const char * filename, void LSVMparser(const char * filename,
CvLSVMFilterObjectCaskade *** model, CvLSVMFilterObjectCascade *** model,
int *last, int *last,
int *max, int *max,
int **comp, int **comp,
...@@ -336,21 +336,21 @@ int getTeg(char *str){ ...@@ -336,21 +336,21 @@ int getTeg(char *str){
return sum; return sum;
} }
void addFilter(CvLSVMFilterObjectCaskade *** model, int *last, int *max) void addFilter(CvLSVMFilterObjectCascade *** model, int *last, int *max)
{ {
CvLSVMFilterObjectCaskade ** nmodel; CvLSVMFilterObjectCascade ** nmodel;
int i; int i;
(*last) ++; (*last) ++;
if((*last) >= (*max)){ if((*last) >= (*max)){
(*max) += 10; (*max) += 10;
nmodel = (CvLSVMFilterObjectCaskade **)malloc(sizeof(CvLSVMFilterObjectCaskade *) * (*max)); nmodel = (CvLSVMFilterObjectCascade **)malloc(sizeof(CvLSVMFilterObjectCascade *) * (*max));
for(i = 0; i < *last; i++){ for(i = 0; i < *last; i++){
nmodel[i] = (* model)[i]; nmodel[i] = (* model)[i];
} }
free(* model); free(* model);
(*model) = nmodel; (*model) = nmodel;
} }
(*model) [(*last)] = (CvLSVMFilterObjectCaskade *)malloc(sizeof(CvLSVMFilterObjectCaskade)); (*model) [(*last)] = (CvLSVMFilterObjectCascade *)malloc(sizeof(CvLSVMFilterObjectCascade));
(*model) [(*last)]->Hypothesis = 0.0f; (*model) [(*last)]->Hypothesis = 0.0f;
(*model) [(*last)]->Deformation = 0.0f; (*model) [(*last)]->Deformation = 0.0f;
(*model) [(*last)]->Hypothesis_PCA = 0.0f; (*model) [(*last)]->Hypothesis_PCA = 0.0f;
...@@ -359,7 +359,7 @@ void addFilter(CvLSVMFilterObjectCaskade *** model, int *last, int *max) ...@@ -359,7 +359,7 @@ void addFilter(CvLSVMFilterObjectCaskade *** model, int *last, int *max)
} }
//############################################## //##############################################
void parserCascadeThresholds (FILE * xmlf, CvLSVMFilterObjectCaskade * model){ void parserCascadeThresholds (FILE * xmlf, CvLSVMFilterObjectCascade * model){
int st = 0; int st = 0;
int tag; int tag;
int tagVal; int tagVal;
...@@ -438,7 +438,7 @@ void parserCascadeThresholds (FILE * xmlf, CvLSVMFilterObjectCaskade * model){ ...@@ -438,7 +438,7 @@ void parserCascadeThresholds (FILE * xmlf, CvLSVMFilterObjectCaskade * model){
} }
//############################################## //##############################################
void parserRFilter (FILE * xmlf, int p, int pca, CvLSVMFilterObjectCaskade * model, float *b){ void parserRFilter (FILE * xmlf, int p, int pca, CvLSVMFilterObjectCascade * model, float *b){
int st = 0; int st = 0;
int sizeX = 0, sizeY = 0; int sizeX = 0, sizeY = 0;
int tag; int tag;
...@@ -548,7 +548,7 @@ void parserRFilter (FILE * xmlf, int p, int pca, CvLSVMFilterObjectCaskade * mo ...@@ -548,7 +548,7 @@ void parserRFilter (FILE * xmlf, int p, int pca, CvLSVMFilterObjectCaskade * mo
} }
} }
void parserV (FILE * xmlf, int /*p*/, CvLSVMFilterObjectCaskade * model){ void parserV (FILE * xmlf, int /*p*/, CvLSVMFilterObjectCascade * model){
int st = 0; int st = 0;
int tag; int tag;
int tagVal; int tagVal;
...@@ -611,7 +611,7 @@ void parserV (FILE * xmlf, int /*p*/, CvLSVMFilterObjectCaskade * model){ ...@@ -611,7 +611,7 @@ void parserV (FILE * xmlf, int /*p*/, CvLSVMFilterObjectCaskade * model){
} }
} }
} }
void parserD (FILE * xmlf, int /*p*/, CvLSVMFilterObjectCaskade * model){ void parserD (FILE * xmlf, int /*p*/, CvLSVMFilterObjectCascade * model){
int st = 0; int st = 0;
int tag; int tag;
int tagVal; int tagVal;
...@@ -700,7 +700,7 @@ void parserD (FILE * xmlf, int /*p*/, CvLSVMFilterObjectCaskade * model){ ...@@ -700,7 +700,7 @@ void parserD (FILE * xmlf, int /*p*/, CvLSVMFilterObjectCaskade * model){
} }
} }
void parserPFilter (FILE * xmlf, int p, int pca, int /*N_path*/, CvLSVMFilterObjectCaskade * model){ void parserPFilter (FILE * xmlf, int p, int pca, int /*N_path*/, CvLSVMFilterObjectCascade * model){
int st = 0; int st = 0;
int sizeX = 0, sizeY = 0; int sizeX = 0, sizeY = 0;
int tag; int tag;
...@@ -806,7 +806,7 @@ void parserPFilter (FILE * xmlf, int p, int pca, int /*N_path*/, CvLSVMFilterOb ...@@ -806,7 +806,7 @@ void parserPFilter (FILE * xmlf, int p, int pca, int /*N_path*/, CvLSVMFilterOb
} }
} }
} }
void parserPFilterS (FILE * xmlf, int p, int pca, CvLSVMFilterObjectCaskade *** model, int *last, int *max){ void parserPFilterS (FILE * xmlf, int p, int pca, CvLSVMFilterObjectCascade *** model, int *last, int *max){
int st = 0; int st = 0;
int N_path = 0; int N_path = 0;
int tag; int tag;
...@@ -850,7 +850,7 @@ void parserPFilterS (FILE * xmlf, int p, int pca, CvLSVMFilterObjectCaskade *** ...@@ -850,7 +850,7 @@ void parserPFilterS (FILE * xmlf, int p, int pca, CvLSVMFilterObjectCaskade ***
} }
} }
} }
void parserComp (FILE * xmlf, int p, int pca, int *N_comp, CvLSVMFilterObjectCaskade *** model, float *b, int *last, int *max){ void parserComp (FILE * xmlf, int p, int pca, int *N_comp, CvLSVMFilterObjectCascade *** model, float *b, int *last, int *max){
int st = 0; int st = 0;
int tag; int tag;
int tagVal; int tagVal;
...@@ -895,7 +895,7 @@ void parserComp (FILE * xmlf, int p, int pca, int *N_comp, CvLSVMFilterObjectCas ...@@ -895,7 +895,7 @@ void parserComp (FILE * xmlf, int p, int pca, int *N_comp, CvLSVMFilterObjectCas
} }
} }
} }
void parserModel(FILE * xmlf, CvLSVMFilterObjectCaskade *** model, int *last, int *max, int **comp, float **b, int *count, float * score, float** PCAcoeff){ void parserModel(FILE * xmlf, CvLSVMFilterObjectCascade *** model, int *last, int *max, int **comp, float **b, int *count, float * score, float** PCAcoeff){
int p = 0, pca = 0; int p = 0, pca = 0;
int N_comp = 0; int N_comp = 0;
int * cmp; int * cmp;
...@@ -1023,7 +1023,7 @@ void parserModel(FILE * xmlf, CvLSVMFilterObjectCaskade *** model, int *last, in ...@@ -1023,7 +1023,7 @@ void parserModel(FILE * xmlf, CvLSVMFilterObjectCaskade *** model, int *last, in
} }
void LSVMparser(const char * filename, void LSVMparser(const char * filename,
CvLSVMFilterObjectCaskade *** model, CvLSVMFilterObjectCascade *** model,
int *last, int *last,
int *max, int *max,
int **comp, int **comp,
...@@ -1040,7 +1040,7 @@ void LSVMparser(const char * filename, ...@@ -1040,7 +1040,7 @@ void LSVMparser(const char * filename,
(*max) = 10; (*max) = 10;
(*last) = -1; (*last) = -1;
(*model) = (CvLSVMFilterObjectCaskade ** )malloc((sizeof(CvLSVMFilterObjectCaskade * )) * (*max)); (*model) = (CvLSVMFilterObjectCascade ** )malloc((sizeof(CvLSVMFilterObjectCascade * )) * (*max));
//printf("parse : %s\n", filename); //printf("parse : %s\n", filename);
xmlf = fopen(filename, "rb"); xmlf = fopen(filename, "rb");
...@@ -1075,7 +1075,7 @@ void LSVMparser(const char * filename, ...@@ -1075,7 +1075,7 @@ void LSVMparser(const char * filename,
int loadModel( int loadModel(
const char *modelPath, const char *modelPath,
CvLSVMFilterObjectCaskade ***filters, CvLSVMFilterObjectCascade ***filters,
int *kFilters, int *kFilters,
int *kComponents, int *kComponents,
int **kPartFilters, int **kPartFilters,
......
...@@ -45,11 +45,11 @@ namespace cv ...@@ -45,11 +45,11 @@ namespace cv
{ {
namespace lsvm namespace lsvm
{ {
int allocFilterObject(CvLSVMFilterObjectCaskade **obj, const int sizeX, int allocFilterObject(CvLSVMFilterObjectCascade **obj, const int sizeX,
const int sizeY, const int numFeatures) const int sizeY, const int numFeatures)
{ {
int i; int i;
(*obj) = (CvLSVMFilterObjectCaskade *)malloc(sizeof(CvLSVMFilterObjectCaskade)); (*obj) = (CvLSVMFilterObjectCascade *)malloc(sizeof(CvLSVMFilterObjectCascade));
(*obj)->sizeX = sizeX; (*obj)->sizeX = sizeX;
(*obj)->sizeY = sizeY; (*obj)->sizeY = sizeY;
(*obj)->numFeatures = numFeatures; (*obj)->numFeatures = numFeatures;
...@@ -68,7 +68,7 @@ int allocFilterObject(CvLSVMFilterObjectCaskade **obj, const int sizeX, ...@@ -68,7 +68,7 @@ int allocFilterObject(CvLSVMFilterObjectCaskade **obj, const int sizeX,
} }
return LATENT_SVM_OK; return LATENT_SVM_OK;
} }
int freeFilterObject (CvLSVMFilterObjectCaskade **obj) int freeFilterObject (CvLSVMFilterObjectCascade **obj)
{ {
if(*obj == NULL) return LATENT_SVM_MEM_NULL; if(*obj == NULL) return LATENT_SVM_MEM_NULL;
free((*obj)->H); free((*obj)->H);
...@@ -77,11 +77,11 @@ int freeFilterObject (CvLSVMFilterObjectCaskade **obj) ...@@ -77,11 +77,11 @@ int freeFilterObject (CvLSVMFilterObjectCaskade **obj)
return LATENT_SVM_OK; return LATENT_SVM_OK;
} }
int allocFeatureMapObject(CvLSVMFeatureMapCaskade **obj, const int sizeX, int allocFeatureMapObject(CvLSVMFeatureMapCascade **obj, const int sizeX,
const int sizeY, const int numFeatures) const int sizeY, const int numFeatures)
{ {
int i; int i;
(*obj) = (CvLSVMFeatureMapCaskade *)malloc(sizeof(CvLSVMFeatureMapCaskade)); (*obj) = (CvLSVMFeatureMapCascade *)malloc(sizeof(CvLSVMFeatureMapCascade));
(*obj)->sizeX = sizeX; (*obj)->sizeX = sizeX;
(*obj)->sizeY = sizeY; (*obj)->sizeY = sizeY;
(*obj)->numFeatures = numFeatures; (*obj)->numFeatures = numFeatures;
...@@ -93,7 +93,7 @@ int allocFeatureMapObject(CvLSVMFeatureMapCaskade **obj, const int sizeX, ...@@ -93,7 +93,7 @@ int allocFeatureMapObject(CvLSVMFeatureMapCaskade **obj, const int sizeX,
} }
return LATENT_SVM_OK; return LATENT_SVM_OK;
} }
int freeFeatureMapObject (CvLSVMFeatureMapCaskade **obj) int freeFeatureMapObject (CvLSVMFeatureMapCascade **obj)
{ {
if(*obj == NULL) return LATENT_SVM_MEM_NULL; if(*obj == NULL) return LATENT_SVM_MEM_NULL;
free((*obj)->map); free((*obj)->map);
...@@ -102,17 +102,17 @@ int freeFeatureMapObject (CvLSVMFeatureMapCaskade **obj) ...@@ -102,17 +102,17 @@ int freeFeatureMapObject (CvLSVMFeatureMapCaskade **obj)
return LATENT_SVM_OK; return LATENT_SVM_OK;
} }
int allocFeaturePyramidObject(CvLSVMFeaturePyramidCaskade **obj, int allocFeaturePyramidObject(CvLSVMFeaturePyramidCascade **obj,
const int numLevels) const int numLevels)
{ {
(*obj) = (CvLSVMFeaturePyramidCaskade *)malloc(sizeof(CvLSVMFeaturePyramidCaskade)); (*obj) = (CvLSVMFeaturePyramidCascade *)malloc(sizeof(CvLSVMFeaturePyramidCascade));
(*obj)->numLevels = numLevels; (*obj)->numLevels = numLevels;
(*obj)->pyramid = (CvLSVMFeatureMapCaskade **)malloc( (*obj)->pyramid = (CvLSVMFeatureMapCascade **)malloc(
sizeof(CvLSVMFeatureMapCaskade *) * numLevels); sizeof(CvLSVMFeatureMapCascade *) * numLevels);
return LATENT_SVM_OK; return LATENT_SVM_OK;
} }
int freeFeaturePyramidObject (CvLSVMFeaturePyramidCaskade **obj) int freeFeaturePyramidObject (CvLSVMFeaturePyramidCascade **obj)
{ {
int i; int i;
if(*obj == NULL) return LATENT_SVM_MEM_NULL; if(*obj == NULL) return LATENT_SVM_MEM_NULL;
......
...@@ -56,7 +56,7 @@ using namespace cv; ...@@ -56,7 +56,7 @@ using namespace cv;
const float score_thr = 0.05f; const float score_thr = 0.05f;
class LatentSVMDetectorCaskadeTest : public cvtest::BaseTest class LatentSVMDetectorCascadeTest : public cvtest::BaseTest
{ {
protected: protected:
void run(int); void run(int);
...@@ -125,15 +125,16 @@ bool compareResults( const std::vector<lsvm::LSVMDetector::ObjectDetection>& cal ...@@ -125,15 +125,16 @@ bool compareResults( const std::vector<lsvm::LSVMDetector::ObjectDetection>& cal
return true; return true;
} }
void LatentSVMDetectorCaskadeTest::run( int /* start_from */) void LatentSVMDetectorCascadeTest::run( int /* start_from */)
{ {
std::string img_path_cat = std::string(ts->get_data_path()) + "cat.png"; std::string test_data_path = ts->get_data_path() + "latentsvmdetector/";
std::string img_path_cars = std::string(ts->get_data_path()) + "cars.png"; std::string img_path_cat = test_data_path + "cat.png";
std::string img_path_cars = test_data_path + "cars.png";
std::string model_path_cat = std::string(ts->get_data_path()) + "models_VOC2007_cascade/cat.xml"; std::string model_path_cat = test_data_path + "models_VOC2007_cascade/cat.xml";
std::string model_path_car = std::string(ts->get_data_path()) + "models_VOC2007_cascade/car.xml"; std::string model_path_car = test_data_path + "models_VOC2007_cascade/car.xml";
std::string true_res_path = std::string(ts->get_data_path()) + "results_cascade.xml"; std::string true_res_path = test_data_path + "results_cascade.xml";
#ifdef HAVE_TBB #ifdef HAVE_TBB
...@@ -214,4 +215,4 @@ void LatentSVMDetectorCaskadeTest::run( int /* start_from */) ...@@ -214,4 +215,4 @@ void LatentSVMDetectorCaskadeTest::run( int /* start_from */)
ts->set_failed_test_info( cvtest::TS::OK); ts->set_failed_test_info( cvtest::TS::OK);
} }
TEST(Objdetect_LatentSVMDetectorCaskade_cpp, regression) { LatentSVMDetectorCaskadeTest test; test.safe_run(); } TEST(Objdetect_LatentSVMDetectorCascade_cpp, regression) { LatentSVMDetectorCascadeTest test; test.safe_run(); }
#include "test_precomp.hpp" #include "test_precomp.hpp"
CV_TEST_MAIN("latentsvm") CV_TEST_MAIN("cv")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment