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
25cadb1a
Commit
25cadb1a
authored
Sep 21, 2011
by
Anatoly Baksheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed compilation under ubuntu
parent
50543d62
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
78 deletions
+78
-78
cascadedetect.hpp
modules/objdetect/src/cascadedetect.hpp
+78
-78
No files found.
modules/objdetect/src/cascadedetect.hpp
View file @
25cadb1a
...
...
@@ -238,84 +238,84 @@ inline void LBPEvaluator::Feature :: updatePtrs( const Mat& sum )
CV_SUM_PTRS
(
p
[
8
],
p
[
9
],
p
[
12
],
p
[
13
],
ptr
,
tr
,
step
);
}
//---------------------------------------------- HOGEvaluator -------------------------------------------
class
HOGEvaluator
:
public
FeatureEvaluator
{
public
:
struct
Feature
{
Feature
();
float
calc
(
int
offset
)
const
;
void
updatePtrs
(
const
vector
<
Mat
>&
_hist
,
const
Mat
&
_normSum
);
bool
read
(
const
FileNode
&
node
);
enum
{
CELL_NUM
=
4
,
BIN_NUM
=
9
};
Rect
rect
[
CELL_NUM
];
int
featComponent
;
//component index from 0 to 35
const
float
*
pF
[
4
];
//for feature calculation
const
float
*
pN
[
4
];
//for normalization calculation
};
HOGEvaluator
();
virtual
~
HOGEvaluator
();
virtual
bool
read
(
const
FileNode
&
node
);
virtual
Ptr
<
FeatureEvaluator
>
clone
()
const
;
virtual
int
getFeatureType
()
const
{
return
FeatureEvaluator
::
HOG
;
}
virtual
bool
setImage
(
const
Mat
&
image
,
Size
winSize
);
virtual
bool
setWindow
(
Point
pt
);
double
operator
()(
int
featureIdx
)
const
{
return
featuresPtr
[
featureIdx
].
calc
(
offset
);
}
virtual
double
calcOrd
(
int
featureIdx
)
const
{
return
(
*
this
)(
featureIdx
);
}
private
:
virtual
void
integralHistogram
(
const
Mat
&
srcImage
,
vector
<
Mat
>
&
histogram
,
Mat
&
norm
,
int
nbins
)
const
;
Size
origWinSize
;
Ptr
<
vector
<
Feature
>
>
features
;
Feature
*
featuresPtr
;
vector
<
Mat
>
hist
;
Mat
normSum
;
int
offset
;
};
inline
HOGEvaluator
::
Feature
::
Feature
()
{
rect
[
0
]
=
rect
[
1
]
=
rect
[
2
]
=
rect
[
3
]
=
Rect
();
pF
[
0
]
=
pF
[
1
]
=
pF
[
2
]
=
pF
[
3
]
=
0
;
pN
[
0
]
=
pN
[
1
]
=
pN
[
2
]
=
pN
[
3
]
=
0
;
featComponent
=
0
;
}
inline
float
HOGEvaluator
::
Feature
::
calc
(
int
offset
)
const
{
float
res
=
CALC_SUM
(
pF
,
offset
);
float
normFactor
=
CALC_SUM
(
pN
,
offset
);
res
=
(
res
>
0.001
f
)
?
(
res
/
(
normFactor
+
0.001
f
)
)
:
0.
f
;
return
res
;
}
inline
void
HOGEvaluator
::
Feature
::
updatePtrs
(
const
vector
<
Mat
>
&
_hist
,
const
Mat
&
_normSum
)
{
int
binIdx
=
featComponent
%
BIN_NUM
;
int
cellIdx
=
featComponent
/
BIN_NUM
;
Rect
normRect
=
Rect
(
rect
[
0
].
x
,
rect
[
0
].
y
,
2
*
rect
[
0
].
width
,
2
*
rect
[
0
].
height
);
const
float
*
featBuf
=
(
const
float
*
)
_hist
[
binIdx
].
data
;
size_t
featStep
=
_hist
[
0
].
step
/
sizeof
(
featBuf
[
0
]);
const
float
*
normBuf
=
(
const
float
*
)
_normSum
.
data
;
size_t
normStep
=
_normSum
.
step
/
sizeof
(
normBuf
[
0
]);
CV_SUM_PTRS
(
pF
[
0
],
pF
[
1
],
pF
[
2
],
pF
[
3
],
featBuf
,
rect
[
cellIdx
],
featStep
);
CV_SUM_PTRS
(
pN
[
0
],
pN
[
1
],
pN
[
2
],
pN
[
3
],
normBuf
,
normRect
,
normStep
);
}
//---------------------------------------------- HOGEvaluator -------------------------------------------
class
HOGEvaluator
:
public
FeatureEvaluator
{
public
:
struct
Feature
{
Feature
();
float
calc
(
int
offset
)
const
;
void
updatePtrs
(
const
vector
<
Mat
>&
_hist
,
const
Mat
&
_normSum
);
bool
read
(
const
FileNode
&
node
);
enum
{
CELL_NUM
=
4
,
BIN_NUM
=
9
};
Rect
rect
[
CELL_NUM
];
int
featComponent
;
//component index from 0 to 35
const
float
*
pF
[
4
];
//for feature calculation
const
float
*
pN
[
4
];
//for normalization calculation
};
HOGEvaluator
();
virtual
~
HOGEvaluator
();
virtual
bool
read
(
const
FileNode
&
node
);
virtual
Ptr
<
FeatureEvaluator
>
clone
()
const
;
virtual
int
getFeatureType
()
const
{
return
FeatureEvaluator
::
HOG
;
}
virtual
bool
setImage
(
const
Mat
&
image
,
Size
winSize
);
virtual
bool
setWindow
(
Point
pt
);
double
operator
()(
int
featureIdx
)
const
{
return
featuresPtr
[
featureIdx
].
calc
(
offset
);
}
virtual
double
calcOrd
(
int
featureIdx
)
const
{
return
(
*
this
)(
featureIdx
);
}
private
:
virtual
void
integralHistogram
(
const
Mat
&
srcImage
,
vector
<
Mat
>
&
histogram
,
Mat
&
norm
,
int
nbins
)
const
;
Size
origWinSize
;
Ptr
<
vector
<
Feature
>
>
features
;
Feature
*
featuresPtr
;
vector
<
Mat
>
hist
;
Mat
normSum
;
int
offset
;
};
inline
HOGEvaluator
::
Feature
::
Feature
()
{
rect
[
0
]
=
rect
[
1
]
=
rect
[
2
]
=
rect
[
3
]
=
Rect
();
pF
[
0
]
=
pF
[
1
]
=
pF
[
2
]
=
pF
[
3
]
=
0
;
pN
[
0
]
=
pN
[
1
]
=
pN
[
2
]
=
pN
[
3
]
=
0
;
featComponent
=
0
;
}
inline
float
HOGEvaluator
::
Feature
::
calc
(
int
offset
)
const
{
float
res
=
CALC_SUM
(
pF
,
offset
);
float
normFactor
=
CALC_SUM
(
pN
,
offset
);
res
=
(
res
>
0.001
f
)
?
(
res
/
(
normFactor
+
0.001
f
)
)
:
0.
f
;
return
res
;
}
inline
void
HOGEvaluator
::
Feature
::
updatePtrs
(
const
vector
<
Mat
>
&
_hist
,
const
Mat
&
_normSum
)
{
int
binIdx
=
featComponent
%
BIN_NUM
;
int
cellIdx
=
featComponent
/
BIN_NUM
;
Rect
normRect
=
Rect
(
rect
[
0
].
x
,
rect
[
0
].
y
,
2
*
rect
[
0
].
width
,
2
*
rect
[
0
].
height
);
const
float
*
featBuf
=
(
const
float
*
)
_hist
[
binIdx
].
data
;
size_t
featStep
=
_hist
[
0
].
step
/
sizeof
(
featBuf
[
0
]);
const
float
*
normBuf
=
(
const
float
*
)
_normSum
.
data
;
size_t
normStep
=
_normSum
.
step
/
sizeof
(
normBuf
[
0
]);
CV_SUM_PTRS
(
pF
[
0
],
pF
[
1
],
pF
[
2
],
pF
[
3
],
featBuf
,
rect
[
cellIdx
],
featStep
);
CV_SUM_PTRS
(
pN
[
0
],
pN
[
1
],
pN
[
2
],
pN
[
3
],
normBuf
,
normRect
,
normStep
);
}
...
...
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