Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
07eed8c4
Commit
07eed8c4
authored
Jul 12, 2011
by
Evgeniy Kozinov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring latentSVM
parent
ea8e2796
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
81 additions
and
81 deletions
+81
-81
objdetect.hpp
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
+6
-10
_latentsvm.h
modules/objdetect/src/_latentsvm.h
+3
-6
_lsvm_error.h
modules/objdetect/src/_lsvm_error.h
+1
-0
_lsvm_routine.h
modules/objdetect/src/_lsvm_routine.h
+3
-3
_lsvm_types.h
modules/objdetect/src/_lsvm_types.h
+14
-19
featurepyramid.cpp
modules/objdetect/src/featurepyramid.cpp
+0
-0
latentsvm.cpp
modules/objdetect/src/latentsvm.cpp
+4
-5
lsvmparser.cpp
modules/objdetect/src/lsvmparser.cpp
+1
-2
matching.cpp
modules/objdetect/src/matching.cpp
+0
-0
routine.cpp
modules/objdetect/src/routine.cpp
+49
-36
No files found.
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
View file @
07eed8c4
...
...
@@ -160,9 +160,9 @@ CVAPI(int) cvRunHaarClassifierCascade( const CvHaarClassifierCascade* cascade,
// (x, y) - coordinate in level l
typedef
struct
{
unsigned
int
x
;
unsigned
int
y
;
unsigned
int
l
;
int
x
;
int
y
;
int
l
;
}
CvLSVMFilterPosition
;
// DataType: STRUCT filterObject
...
...
@@ -179,16 +179,12 @@ typedef struct
// used formula H[(j * sizeX + i) * p + k], where
// k - component of feature vector in cell (i, j)
// END OF FILTER DESCRIPTION
// xp - auxillary parameter for internal use
// size of row in feature vectors
// (yp = (int) (p / xp); p = xp * yp)
typedef
struct
{
CvLSVMFilterPosition
V
;
float
fineFunction
[
4
];
unsigned
int
sizeX
;
unsigned
int
sizeY
;
unsigned
int
p
;
unsigned
int
xp
;
int
sizeX
;
int
sizeY
;
int
numFeatures
;
float
*
H
;
}
CvLSVMFilterObject
;
...
...
modules/objdetect/src/_latentsvm.h
View file @
07eed8c4
...
...
@@ -37,10 +37,7 @@
// RESULT
// Error status
*/
int
getFeaturePyramid
(
IplImage
*
image
,
const
int
lambda
,
const
int
k
,
const
int
startX
,
const
int
startY
,
const
int
W
,
const
int
H
,
CvLSVMFeaturePyramid
**
maps
);
int
getFeaturePyramid
(
IplImage
*
image
,
CvLSVMFeaturePyramid
**
maps
);
/*
// Getting feature map for the selected subimage
...
...
@@ -55,7 +52,7 @@ int getFeaturePyramid(IplImage * image,
// RESULT
// Error status
*/
int
getFeatureMaps
_dp
(
const
IplImage
*
image
,
const
int
k
,
CvLSVMFeatureMap
**
map
);
int
getFeatureMaps
(
const
IplImage
*
image
,
const
int
k
,
CvLSVMFeatureMap
**
map
);
/*
...
...
@@ -71,7 +68,7 @@ int getFeatureMaps_dp(const IplImage * image, const int k, CvLSVMFeatureMap **ma
// RESULT
// Error status
*/
int
normaliz
ationAndTruncationFeatureMaps
(
CvLSVMFeatureMap
*
map
,
const
float
alfa
);
int
normaliz
eAndTruncate
(
CvLSVMFeatureMap
*
map
,
const
float
alfa
);
/*
// Feature map reduction
...
...
modules/objdetect/src/_lsvm_error.h
View file @
07eed8c4
...
...
@@ -2,6 +2,7 @@
#define LSVM_ERROR
#define LATENT_SVM_OK 0
#define LATENT_SVM_MEM_NULL 2
#define DISTANCE_TRANSFORM_OK 1
#define DISTANCE_TRANSFORM_GET_INTERSECTION_ERROR -1
#define DISTANCE_TRANSFORM_ERROR -2
...
...
modules/objdetect/src/_lsvm_routine.h
View file @
07eed8c4
...
...
@@ -13,18 +13,18 @@
// Error status is return value
//////////////////////////////////////////////////////////////
int
allocFilterObject
(
CvLSVMFilterObject
**
obj
,
const
int
sizeX
,
const
int
sizeY
,
const
int
p
,
const
int
xp
);
const
int
p
);
int
freeFilterObject
(
CvLSVMFilterObject
**
obj
);
int
allocFeatureMapObject
(
CvLSVMFeatureMap
**
obj
,
const
int
sizeX
,
const
int
sizeY
,
const
int
p
,
const
int
xp
);
const
int
p
);
int
freeFeatureMapObject
(
CvLSVMFeatureMap
**
obj
);
#ifdef __cplusplus
extern
"C"
#endif
int
allocFeaturePyramidObject
(
CvLSVMFeaturePyramid
**
obj
,
const
int
lambda
,
const
int
countLevel
);
const
int
countLevel
);
#ifdef __cplusplus
extern
"C"
...
...
modules/objdetect/src/_lsvm_types.h
View file @
07eed8c4
...
...
@@ -14,7 +14,7 @@
// The number of elements in bin
// The number of sectors in gradient histogram building
#define
CNTPARTION
9
#define
NUM_SECTOR
9
// The number of levels in image resize procedure
// We need Lambda levels to resize image twice
...
...
@@ -23,6 +23,8 @@
// Block size. Used in feature pyramid building procedure
#define SIDE_LENGTH 8
#define VAL_OF_TRUNCATE 0.2f
//////////////////////////////////////////////////////////////
// main data structures //
//////////////////////////////////////////////////////////////
...
...
@@ -30,31 +32,24 @@
// DataType: STRUCT featureMap
// FEATURE MAP DESCRIPTION
// Rectangular map (sizeX x sizeY),
// every cell stores feature vector (dimension =
p
)
//
H
- matrix of feature vectors
// every cell stores feature vector (dimension =
numFeatures
)
//
map
- matrix of feature vectors
// to set and get feature vectors (i,j)
// used formula
M
ap[(j * sizeX + i) * p + k], where
// used formula
m
ap[(j * sizeX + i) * p + k], where
// k - component of feature vector in cell (i, j)
// END OF FEATURE MAP DESCRIPTION
// xp - auxillary parameter for internal use
// size of row in feature vectors
// (yp = (int) (p / xp); p = xp * yp)
typedef
struct
{
int
sizeX
;
int
sizeY
;
int
p
;
int
xp
;
float
*
Map
;
int
numFeatures
;
float
*
map
;
}
CvLSVMFeatureMap
;
// DataType: STRUCT featurePyramid
//
// countLevel - number of levels in the feature pyramid
// lambda - resize scale coefficient
// numLevels - number of levels in the feature pyramid
// pyramid - array of pointers to feature map at different levels
typedef
struct
{
int
countLevel
;
int
lambda
;
int
numLevels
;
CvLSVMFeatureMap
**
pyramid
;
}
CvLSVMFeaturePyramid
;
...
...
@@ -74,14 +69,14 @@ typedef struct{
// DataType: STRUCT fftImage
// The structure stores FFT image
//
//
p
- number of channels
//
numFeatures
- number of channels
// x - array of FFT images for 2d signals
// n - number of rows
// m - number of collums
typedef
struct
{
unsigned
int
p
;
unsigned
int
dimX
;
unsigned
int
dimY
;
int
numFeatures
;
int
dimX
;
int
dimY
;
float
**
channels
;
}
CvLSVMFftImage
;
...
...
modules/objdetect/src/featurepyramid.cpp
View file @
07eed8c4
This diff is collapsed.
Click to expand it.
modules/objdetect/src/latentsvm.cpp
View file @
07eed8c4
...
...
@@ -127,8 +127,7 @@ CvLSVMFeaturePyramid* createFeaturePyramidWithBorder(IplImage *image,
CvLSVMFeaturePyramid
*
H
;
// Obtaining feature pyramid
opResult
=
getFeaturePyramid
(
image
,
LAMBDA
,
SIDE_LENGTH
,
0
,
0
,
image
->
width
,
image
->
height
,
&
H
);
opResult
=
getFeaturePyramid
(
image
,
&
H
);
if
(
opResult
!=
LATENT_SVM_OK
)
{
...
...
@@ -139,7 +138,7 @@ CvLSVMFeaturePyramid* createFeaturePyramidWithBorder(IplImage *image,
// Addition nullable border for each feature map
// the size of the border for root filters
computeBorderSize
(
maxXBorder
,
maxYBorder
,
&
bx
,
&
by
);
for
(
level
=
0
;
level
<
H
->
countLevel
;
level
++
)
for
(
level
=
0
;
level
<
H
->
numLevels
;
level
++
)
{
addNullableBorder
(
H
->
pyramid
[
level
],
bx
,
by
);
}
...
...
@@ -196,7 +195,7 @@ int searchObject(const CvLSVMFeaturePyramid *H, const CvLSVMFilterObject **all_F
// Transformation filter displacement from the block space
// to the space of pixels at the initial image
// that settles at the level number LAMBDA
convertPoints
(
H
->
countLevel
,
H
->
lambda
,
LAMBDA
,
(
*
points
),
convertPoints
(
H
->
numLevels
,
LAMBDA
,
LAMBDA
,
(
*
points
),
(
*
levels
),
(
*
partsDisplacement
),
(
*
kPoints
),
n
,
maxXBorder
,
maxYBorder
);
...
...
@@ -305,7 +304,7 @@ int searchObjectThreshold(const CvLSVMFeaturePyramid *H,
// Transformation filter displacement from the block space
// to the space of pixels at the initial image
// that settles at the level number LAMBDA
convertPoints
(
H
->
countLevel
,
H
->
lambda
,
LAMBDA
,
(
*
points
),
convertPoints
(
H
->
numLevels
,
LAMBDA
,
LAMBDA
,
(
*
points
),
(
*
levels
),
(
*
partsDisplacement
),
(
*
kPoints
),
n
,
maxXBorder
,
maxYBorder
);
...
...
modules/objdetect/src/lsvmparser.cpp
View file @
07eed8c4
...
...
@@ -658,8 +658,7 @@ void parserModel(FILE * xmlf, CvLSVMFilterObject *** model, int *last, int *max,
if
(
tagVal
==
EMODEL
){
//printf("</Model>\n");
for
(
ii
=
0
;
ii
<=
*
last
;
ii
++
){
(
*
model
)[
ii
]
->
p
=
p
;
(
*
model
)[
ii
]
->
xp
=
9
;
(
*
model
)[
ii
]
->
numFeatures
=
p
;
}
*
count
=
N_comp
;
return
;
...
...
modules/objdetect/src/matching.cpp
View file @
07eed8c4
This diff is collapsed.
Click to expand it.
modules/objdetect/src/routine.cpp
View file @
07eed8c4
#include "precomp.hpp"
#include "_lsvm_routine.h"
int
allocFilterObject
(
CvLSVMFilterObject
**
obj
,
const
int
sizeX
,
const
int
sizeY
,
const
int
p
,
const
int
xp
){
int
allocFilterObject
(
CvLSVMFilterObject
**
obj
,
const
int
sizeX
,
const
int
sizeY
,
const
int
numFeatures
)
{
int
i
;
(
*
obj
)
=
(
CvLSVMFilterObject
*
)
malloc
(
sizeof
(
CvLSVMFilterObject
));
(
*
obj
)
->
sizeX
=
sizeX
;
(
*
obj
)
->
sizeY
=
sizeY
;
(
*
obj
)
->
p
=
p
;
(
*
obj
)
->
xp
=
xp
;
(
*
obj
)
->
sizeX
=
sizeX
;
(
*
obj
)
->
sizeY
=
sizeY
;
(
*
obj
)
->
numFeatures
=
numFeatures
;
(
*
obj
)
->
fineFunction
[
0
]
=
0.0
f
;
(
*
obj
)
->
fineFunction
[
1
]
=
0.0
f
;
(
*
obj
)
->
fineFunction
[
2
]
=
0.0
f
;
...
...
@@ -15,75 +16,87 @@ int allocFilterObject(CvLSVMFilterObject **obj, const int sizeX, const int sizeY
(
*
obj
)
->
V
.
x
=
0
;
(
*
obj
)
->
V
.
y
=
0
;
(
*
obj
)
->
V
.
l
=
0
;
(
*
obj
)
->
H
=
(
float
*
)
malloc
(
sizeof
(
float
)
*
(
sizeX
*
sizeY
*
p
));
for
(
i
=
0
;
i
<
sizeX
*
sizeY
*
p
;
i
++
){
(
*
obj
)
->
H
=
(
float
*
)
malloc
(
sizeof
(
float
)
*
(
sizeX
*
sizeY
*
numFeatures
));
for
(
i
=
0
;
i
<
sizeX
*
sizeY
*
numFeatures
;
i
++
)
{
(
*
obj
)
->
H
[
i
]
=
0.0
f
;
}
return
LATENT_SVM_OK
;
}
int
freeFilterObject
(
CvLSVMFilterObject
**
obj
){
if
(
*
obj
==
NULL
)
return
0
;
int
freeFilterObject
(
CvLSVMFilterObject
**
obj
)
{
if
(
*
obj
==
NULL
)
return
LATENT_SVM_MEM_NULL
;
free
((
*
obj
)
->
H
);
free
(
*
obj
);
(
*
obj
)
=
NULL
;
return
LATENT_SVM_OK
;
}
int
allocFeatureMapObject
(
CvLSVMFeatureMap
**
obj
,
const
int
sizeX
,
const
int
sizeY
,
const
int
p
,
const
int
xp
){
int
allocFeatureMapObject
(
CvLSVMFeatureMap
**
obj
,
const
int
sizeX
,
const
int
sizeY
,
const
int
numFeatures
)
{
int
i
;
(
*
obj
)
=
(
CvLSVMFeatureMap
*
)
malloc
(
sizeof
(
CvLSVMFeatureMap
));
(
*
obj
)
->
sizeX
=
sizeX
;
(
*
obj
)
->
sizeY
=
sizeY
;
(
*
obj
)
->
p
=
p
;
(
*
obj
)
->
xp
=
xp
;
(
*
obj
)
->
Map
=
(
float
*
)
malloc
(
sizeof
(
float
)
*
(
sizeX
*
sizeY
*
p
));
for
(
i
=
0
;
i
<
sizeX
*
sizeY
*
p
;
i
++
){
(
*
obj
)
->
Map
[
i
]
=
0.0
;
(
*
obj
)
->
sizeX
=
sizeX
;
(
*
obj
)
->
sizeY
=
sizeY
;
(
*
obj
)
->
numFeatures
=
numFeatures
;
(
*
obj
)
->
map
=
(
float
*
)
malloc
(
sizeof
(
float
)
*
(
sizeX
*
sizeY
*
numFeatures
));
for
(
i
=
0
;
i
<
sizeX
*
sizeY
*
numFeatures
;
i
++
)
{
(
*
obj
)
->
map
[
i
]
=
0.0
f
;
}
return
LATENT_SVM_OK
;
}
int
freeFeatureMapObject
(
CvLSVMFeatureMap
**
obj
){
if
(
*
obj
==
NULL
)
return
0
;
free
((
*
obj
)
->
Map
);
int
freeFeatureMapObject
(
CvLSVMFeatureMap
**
obj
)
{
if
(
*
obj
==
NULL
)
return
LATENT_SVM_MEM_NULL
;
free
((
*
obj
)
->
map
);
free
(
*
obj
);
(
*
obj
)
=
NULL
;
return
LATENT_SVM_OK
;
}
int
allocFeaturePyramidObject
(
CvLSVMFeaturePyramid
**
obj
,
const
int
lambda
,
const
int
countLevel
){
int
allocFeaturePyramidObject
(
CvLSVMFeaturePyramid
**
obj
,
const
int
numLevels
)
{
(
*
obj
)
=
(
CvLSVMFeaturePyramid
*
)
malloc
(
sizeof
(
CvLSVMFeaturePyramid
));
(
*
obj
)
->
countLevel
=
countLevel
;
(
*
obj
)
->
pyramid
=
(
CvLSVMFeatureMap
**
)
malloc
(
sizeof
(
CvLSVMFeatureMap
*
)
*
countLevel
);
(
*
obj
)
->
lambda
=
lambda
;
(
*
obj
)
->
numLevels
=
numLevels
;
(
*
obj
)
->
pyramid
=
(
CvLSVMFeatureMap
**
)
malloc
(
sizeof
(
CvLSVMFeatureMap
*
)
*
numLevels
)
;
return
LATENT_SVM_OK
;
}
int
freeFeaturePyramidObject
(
CvLSVMFeaturePyramid
**
obj
){
int
freeFeaturePyramidObject
(
CvLSVMFeaturePyramid
**
obj
)
{
int
i
;
if
(
*
obj
==
NULL
)
return
0
;
for
(
i
=
0
;
i
<
(
*
obj
)
->
countLevel
;
i
++
)
if
(
*
obj
==
NULL
)
return
LATENT_SVM_MEM_NULL
;
for
(
i
=
0
;
i
<
(
*
obj
)
->
numLevels
;
i
++
)
{
freeFeatureMapObject
(
&
((
*
obj
)
->
pyramid
[
i
]));
}
free
((
*
obj
)
->
pyramid
);
free
(
*
obj
);
(
*
obj
)
=
NULL
;
return
LATENT_SVM_OK
;
}
int
allocFFTImage
(
CvLSVMFftImage
**
image
,
int
p
,
int
dimX
,
int
dimY
)
int
allocFFTImage
(
CvLSVMFftImage
**
image
,
int
numFeatures
,
int
dimX
,
int
dimY
)
{
int
i
,
j
,
size
;
*
image
=
(
CvLSVMFftImage
*
)
malloc
(
sizeof
(
CvLSVMFftImage
));
(
*
image
)
->
p
=
p
;
(
*
image
)
->
dimX
=
dimX
;
(
*
image
)
->
dimY
=
dimY
;
(
*
image
)
->
channels
=
(
float
**
)
malloc
(
sizeof
(
float
*
)
*
p
);
(
*
image
)
->
numFeatures
=
numFeatures
;
(
*
image
)
->
dimX
=
dimX
;
(
*
image
)
->
dimY
=
dimY
;
(
*
image
)
->
channels
=
(
float
**
)
malloc
(
sizeof
(
float
*
)
*
numFeatures
);
size
=
2
*
dimX
*
dimY
;
for
(
i
=
0
;
i
<
p
;
i
++
)
for
(
i
=
0
;
i
<
numFeatures
;
i
++
)
{
(
*
image
)
->
channels
[
i
]
=
(
float
*
)
malloc
(
sizeof
(
float
)
*
size
);
for
(
j
=
0
;
j
<
size
;
j
++
)
{
(
*
image
)
->
channels
[
i
][
j
]
=
0.0
;
(
*
image
)
->
channels
[
i
][
j
]
=
0.0
f
;
}
}
return
LATENT_SVM_OK
;
...
...
@@ -91,9 +104,9 @@ int allocFFTImage(CvLSVMFftImage **image, int p, int dimX, int dimY)
int
freeFFTImage
(
CvLSVMFftImage
**
image
)
{
unsigned
i
;
int
i
;
if
(
*
image
==
NULL
)
return
LATENT_SVM_OK
;
for
(
i
=
0
;
i
<
(
*
image
)
->
p
;
i
++
)
for
(
i
=
0
;
i
<
(
*
image
)
->
numFeatures
;
i
++
)
{
free
((
*
image
)
->
channels
[
i
]);
(
*
image
)
->
channels
[
i
]
=
NULL
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment