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
9d3e7e02
Commit
9d3e7e02
authored
Dec 17, 2013
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
almost finished opencl-ization of cascade classifier
parent
d8513d62
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
181 additions
and
19 deletions
+181
-19
ocl.hpp
modules/core/include/opencv2/core/ocl.hpp
+55
-0
imgproc.hpp
modules/imgproc/include/opencv2/imgproc.hpp
+5
-0
smooth.cpp
modules/imgproc/src/smooth.cpp
+108
-0
objdetect.hpp
modules/objdetect/include/opencv2/objdetect.hpp
+1
-1
cascadedetect.cpp
modules/objdetect/src/cascadedetect.cpp
+0
-0
cascadedetect.hpp
modules/objdetect/src/cascadedetect.hpp
+12
-18
No files found.
modules/core/include/opencv2/core/ocl.hpp
View file @
9d3e7e02
...
...
@@ -402,6 +402,61 @@ public:
int
i
=
set
(
0
,
a0
);
i
=
set
(
i
,
a1
);
i
=
set
(
i
,
a2
);
i
=
set
(
i
,
a3
);
i
=
set
(
i
,
a4
);
i
=
set
(
i
,
a5
);
i
=
set
(
i
,
a6
);
i
=
set
(
i
,
a7
);
i
=
set
(
i
,
a8
);
i
=
set
(
i
,
a9
);
i
=
set
(
i
,
a10
);
set
(
i
,
a11
);
return
*
this
;
}
template
<
typename
_Tp0
,
typename
_Tp1
,
typename
_Tp2
,
typename
_Tp3
,
typename
_Tp4
,
typename
_Tp5
,
typename
_Tp6
,
typename
_Tp7
,
typename
_Tp8
,
typename
_Tp9
,
typename
_Tp10
,
typename
_Tp11
,
typename
_Tp12
>
Kernel
&
args
(
const
_Tp0
&
a0
,
const
_Tp1
&
a1
,
const
_Tp2
&
a2
,
const
_Tp3
&
a3
,
const
_Tp4
&
a4
,
const
_Tp5
&
a5
,
const
_Tp6
&
a6
,
const
_Tp7
&
a7
,
const
_Tp8
&
a8
,
const
_Tp9
&
a9
,
const
_Tp10
&
a10
,
const
_Tp11
&
a11
,
const
_Tp12
&
a12
)
{
int
i
=
set
(
0
,
a0
);
i
=
set
(
i
,
a1
);
i
=
set
(
i
,
a2
);
i
=
set
(
i
,
a3
);
i
=
set
(
i
,
a4
);
i
=
set
(
i
,
a5
);
i
=
set
(
i
,
a6
);
i
=
set
(
i
,
a7
);
i
=
set
(
i
,
a8
);
i
=
set
(
i
,
a9
);
i
=
set
(
i
,
a10
);
i
=
set
(
i
,
a11
);
set
(
i
,
a12
);
return
*
this
;
}
template
<
typename
_Tp0
,
typename
_Tp1
,
typename
_Tp2
,
typename
_Tp3
,
typename
_Tp4
,
typename
_Tp5
,
typename
_Tp6
,
typename
_Tp7
,
typename
_Tp8
,
typename
_Tp9
,
typename
_Tp10
,
typename
_Tp11
,
typename
_Tp12
,
typename
_Tp13
>
Kernel
&
args
(
const
_Tp0
&
a0
,
const
_Tp1
&
a1
,
const
_Tp2
&
a2
,
const
_Tp3
&
a3
,
const
_Tp4
&
a4
,
const
_Tp5
&
a5
,
const
_Tp6
&
a6
,
const
_Tp7
&
a7
,
const
_Tp8
&
a8
,
const
_Tp9
&
a9
,
const
_Tp10
&
a10
,
const
_Tp11
&
a11
,
const
_Tp12
&
a12
,
const
_Tp13
&
a13
)
{
int
i
=
set
(
0
,
a0
);
i
=
set
(
i
,
a1
);
i
=
set
(
i
,
a2
);
i
=
set
(
i
,
a3
);
i
=
set
(
i
,
a4
);
i
=
set
(
i
,
a5
);
i
=
set
(
i
,
a6
);
i
=
set
(
i
,
a7
);
i
=
set
(
i
,
a8
);
i
=
set
(
i
,
a9
);
i
=
set
(
i
,
a10
);
i
=
set
(
i
,
a11
);
i
=
set
(
i
,
a12
);
set
(
i
,
a13
);
return
*
this
;
}
template
<
typename
_Tp0
,
typename
_Tp1
,
typename
_Tp2
,
typename
_Tp3
,
typename
_Tp4
,
typename
_Tp5
,
typename
_Tp6
,
typename
_Tp7
,
typename
_Tp8
,
typename
_Tp9
,
typename
_Tp10
,
typename
_Tp11
,
typename
_Tp12
,
typename
_Tp13
,
typename
_Tp14
>
Kernel
&
args
(
const
_Tp0
&
a0
,
const
_Tp1
&
a1
,
const
_Tp2
&
a2
,
const
_Tp3
&
a3
,
const
_Tp4
&
a4
,
const
_Tp5
&
a5
,
const
_Tp6
&
a6
,
const
_Tp7
&
a7
,
const
_Tp8
&
a8
,
const
_Tp9
&
a9
,
const
_Tp10
&
a10
,
const
_Tp11
&
a11
,
const
_Tp12
&
a12
,
const
_Tp13
&
a13
,
const
_Tp14
&
a14
)
{
int
i
=
set
(
0
,
a0
);
i
=
set
(
i
,
a1
);
i
=
set
(
i
,
a2
);
i
=
set
(
i
,
a3
);
i
=
set
(
i
,
a4
);
i
=
set
(
i
,
a5
);
i
=
set
(
i
,
a6
);
i
=
set
(
i
,
a7
);
i
=
set
(
i
,
a8
);
i
=
set
(
i
,
a9
);
i
=
set
(
i
,
a10
);
i
=
set
(
i
,
a11
);
i
=
set
(
i
,
a12
);
i
=
set
(
i
,
a13
);
set
(
i
,
a14
);
return
*
this
;
}
template
<
typename
_Tp0
,
typename
_Tp1
,
typename
_Tp2
,
typename
_Tp3
,
typename
_Tp4
,
typename
_Tp5
,
typename
_Tp6
,
typename
_Tp7
,
typename
_Tp8
,
typename
_Tp9
,
typename
_Tp10
,
typename
_Tp11
,
typename
_Tp12
,
typename
_Tp13
,
typename
_Tp14
,
typename
_Tp15
>
Kernel
&
args
(
const
_Tp0
&
a0
,
const
_Tp1
&
a1
,
const
_Tp2
&
a2
,
const
_Tp3
&
a3
,
const
_Tp4
&
a4
,
const
_Tp5
&
a5
,
const
_Tp6
&
a6
,
const
_Tp7
&
a7
,
const
_Tp8
&
a8
,
const
_Tp9
&
a9
,
const
_Tp10
&
a10
,
const
_Tp11
&
a11
,
const
_Tp12
&
a12
,
const
_Tp13
&
a13
,
const
_Tp14
&
a14
,
const
_Tp15
&
a15
)
{
int
i
=
set
(
0
,
a0
);
i
=
set
(
i
,
a1
);
i
=
set
(
i
,
a2
);
i
=
set
(
i
,
a3
);
i
=
set
(
i
,
a4
);
i
=
set
(
i
,
a5
);
i
=
set
(
i
,
a6
);
i
=
set
(
i
,
a7
);
i
=
set
(
i
,
a8
);
i
=
set
(
i
,
a9
);
i
=
set
(
i
,
a10
);
i
=
set
(
i
,
a11
);
i
=
set
(
i
,
a12
);
i
=
set
(
i
,
a13
);
i
=
set
(
i
,
a14
);
set
(
i
,
a15
);
return
*
this
;
}
bool
run
(
int
dims
,
size_t
globalsize
[],
size_t
localsize
[],
bool
sync
,
const
Queue
&
q
=
Queue
());
...
...
modules/imgproc/include/opencv2/imgproc.hpp
View file @
9d3e7e02
...
...
@@ -1075,6 +1075,11 @@ CV_EXPORTS_W void boxFilter( InputArray src, OutputArray dst, int ddepth,
Size
ksize
,
Point
anchor
=
Point
(
-
1
,
-
1
),
bool
normalize
=
true
,
int
borderType
=
BORDER_DEFAULT
);
CV_EXPORTS_W
void
sqrBoxFilter
(
InputArray
_src
,
OutputArray
_dst
,
int
ddepth
,
Size
ksize
,
Point
anchor
=
Point
(
-
1
,
-
1
),
bool
normalize
=
true
,
int
borderType
=
BORDER_DEFAULT
);
//! a synonym for normalized box filter
CV_EXPORTS_W
void
blur
(
InputArray
src
,
OutputArray
dst
,
...
...
modules/imgproc/src/smooth.cpp
View file @
9d3e7e02
...
...
@@ -741,6 +741,114 @@ void cv::blur( InputArray src, OutputArray dst,
boxFilter
(
src
,
dst
,
-
1
,
ksize
,
anchor
,
true
,
borderType
);
}
/****************************************************************************************\
Squared Box Filter
\****************************************************************************************/
namespace
cv
{
template
<
typename
T
,
typename
ST
>
struct
SqrRowSum
:
public
BaseRowFilter
{
SqrRowSum
(
int
_ksize
,
int
_anchor
)
{
ksize
=
_ksize
;
anchor
=
_anchor
;
}
void
operator
()(
const
uchar
*
src
,
uchar
*
dst
,
int
width
,
int
cn
)
{
const
T
*
S
=
(
const
T
*
)
src
;
ST
*
D
=
(
ST
*
)
dst
;
int
i
=
0
,
k
,
ksz_cn
=
ksize
*
cn
;
width
=
(
width
-
1
)
*
cn
;
for
(
k
=
0
;
k
<
cn
;
k
++
,
S
++
,
D
++
)
{
ST
s
=
0
;
for
(
i
=
0
;
i
<
ksz_cn
;
i
+=
cn
)
{
ST
val
=
(
ST
)
S
[
i
];
s
+=
val
*
val
;
}
D
[
0
]
=
s
;
for
(
i
=
0
;
i
<
width
;
i
+=
cn
)
{
ST
val0
=
(
ST
)
S
[
i
],
val1
=
(
ST
)
S
[
i
+
ksz_cn
];
s
+=
val1
*
val1
-
val0
*
val0
;
D
[
i
+
cn
]
=
s
;
}
}
}
};
static
Ptr
<
BaseRowFilter
>
getSqrRowSumFilter
(
int
srcType
,
int
sumType
,
int
ksize
,
int
anchor
)
{
int
sdepth
=
CV_MAT_DEPTH
(
srcType
),
ddepth
=
CV_MAT_DEPTH
(
sumType
);
CV_Assert
(
CV_MAT_CN
(
sumType
)
==
CV_MAT_CN
(
srcType
)
);
if
(
anchor
<
0
)
anchor
=
ksize
/
2
;
if
(
sdepth
==
CV_8U
&&
ddepth
==
CV_32S
)
return
makePtr
<
SqrRowSum
<
uchar
,
int
>
>
(
ksize
,
anchor
);
if
(
sdepth
==
CV_8U
&&
ddepth
==
CV_64F
)
return
makePtr
<
SqrRowSum
<
uchar
,
double
>
>
(
ksize
,
anchor
);
if
(
sdepth
==
CV_16U
&&
ddepth
==
CV_64F
)
return
makePtr
<
SqrRowSum
<
ushort
,
double
>
>
(
ksize
,
anchor
);
if
(
sdepth
==
CV_16S
&&
ddepth
==
CV_64F
)
return
makePtr
<
SqrRowSum
<
short
,
double
>
>
(
ksize
,
anchor
);
if
(
sdepth
==
CV_32F
&&
ddepth
==
CV_64F
)
return
makePtr
<
SqrRowSum
<
float
,
double
>
>
(
ksize
,
anchor
);
if
(
sdepth
==
CV_64F
&&
ddepth
==
CV_64F
)
return
makePtr
<
SqrRowSum
<
double
,
double
>
>
(
ksize
,
anchor
);
CV_Error_
(
CV_StsNotImplemented
,
(
"Unsupported combination of source format (=%d), and buffer format (=%d)"
,
srcType
,
sumType
));
return
Ptr
<
BaseRowFilter
>
();
}
}
void
cv
::
sqrBoxFilter
(
InputArray
_src
,
OutputArray
_dst
,
int
ddepth
,
Size
ksize
,
Point
anchor
,
bool
normalize
,
int
borderType
)
{
Mat
src
=
_src
.
getMat
();
int
sdepth
=
src
.
depth
(),
cn
=
src
.
channels
();
if
(
ddepth
<
0
)
ddepth
=
sdepth
<
CV_32F
?
CV_32F
:
CV_64F
;
_dst
.
create
(
src
.
size
(),
CV_MAKETYPE
(
ddepth
,
cn
)
);
Mat
dst
=
_dst
.
getMat
();
if
(
borderType
!=
BORDER_CONSTANT
&&
normalize
)
{
if
(
src
.
rows
==
1
)
ksize
.
height
=
1
;
if
(
src
.
cols
==
1
)
ksize
.
width
=
1
;
}
int
sumType
=
CV_64F
;
if
(
sdepth
==
CV_8U
)
sumType
=
CV_32S
;
sumType
=
CV_MAKETYPE
(
sumType
,
cn
);
int
srcType
=
CV_MAKETYPE
(
sdepth
,
cn
);
int
dstType
=
CV_MAKETYPE
(
ddepth
,
cn
);
Ptr
<
BaseRowFilter
>
rowFilter
=
getSqrRowSumFilter
(
srcType
,
sumType
,
ksize
.
width
,
anchor
.
x
);
Ptr
<
BaseColumnFilter
>
columnFilter
=
getColumnSumFilter
(
sumType
,
dstType
,
ksize
.
height
,
anchor
.
y
,
normalize
?
1.
/
(
ksize
.
width
*
ksize
.
height
)
:
1
);
Ptr
<
FilterEngine
>
f
=
makePtr
<
FilterEngine
>
(
Ptr
<
BaseFilter
>
(),
rowFilter
,
columnFilter
,
srcType
,
dstType
,
sumType
,
borderType
);
f
->
apply
(
src
,
dst
);
}
/****************************************************************************************\
Gaussian Blur
\****************************************************************************************/
...
...
modules/objdetect/include/opencv2/objdetect.hpp
View file @
9d3e7e02
...
...
@@ -135,7 +135,7 @@ public:
virtual
Ptr
<
FeatureEvaluator
>
clone
()
const
;
virtual
int
getFeatureType
()
const
;
virtual
bool
setImage
(
InputArray
img
,
Size
origWinSize
);
virtual
bool
setImage
(
InputArray
img
,
Size
origWinSize
,
Size
sumSize
);
virtual
bool
setWindow
(
Point
p
);
virtual
double
calcOrd
(
int
featureIdx
)
const
;
...
...
modules/objdetect/src/cascadedetect.cpp
View file @
9d3e7e02
This diff is collapsed.
Click to expand it.
modules/objdetect/src/cascadedetect.hpp
View file @
9d3e7e02
...
...
@@ -42,21 +42,20 @@ public:
bool
isOldFormatCascade
()
const
;
Size
getOriginalWindowSize
()
const
;
int
getFeatureType
()
const
;
bool
setImage
(
InputArray
);
void
*
getOldCascade
();
void
setMaskGenerator
(
const
Ptr
<
MaskGenerator
>&
maskGenerator
);
Ptr
<
MaskGenerator
>
getMaskGenerator
();
protected
:
enum
{
SUM_ALIGN
=
16
};
bool
detectSingleScale
(
InputArray
image
,
Size
processingRectSize
,
int
yStep
,
double
factor
,
std
::
vector
<
Rect
>&
candidates
,
std
::
vector
<
int
>&
rejectLevels
,
std
::
vector
<
double
>&
levelWeights
,
bool
outputRejectLevels
=
false
);
Size
sumSize0
,
bool
outputRejectLevels
=
false
);
bool
ocl_detectSingleScale
(
InputArray
image
,
Size
processingRectSize
,
int
yStep
,
double
factor
,
std
::
vector
<
Rect
>&
candidates
,
std
::
vector
<
int
>&
rejectLevels
,
std
::
vector
<
double
>&
levelWeights
,
bool
outputRejectLevels
=
false
);
int
yStep
,
double
factor
,
Size
sumSize0
);
void
detectMultiScaleNoGrouping
(
InputArray
image
,
std
::
vector
<
Rect
>&
candidates
,
...
...
@@ -86,7 +85,6 @@ protected:
template
<
class
FEval
>
friend
int
predictCategoricalStump
(
CascadeClassifierImpl
&
cascade
,
Ptr
<
FeatureEvaluator
>
&
featureEvaluator
,
double
&
weight
);
bool
setImage
(
Ptr
<
FeatureEvaluator
>&
feval
,
const
Mat
&
image
);
int
runAt
(
Ptr
<
FeatureEvaluator
>&
feval
,
Point
pt
,
double
&
weight
);
class
Data
...
...
@@ -134,7 +132,7 @@ protected:
Ptr
<
MaskGenerator
>
maskGenerator
;
UMat
ugrayImage
,
uimageBuffer
;
UMat
ufacepos
,
ustages
,
uclassifiers
,
unodes
,
uleaves
,
usubsets
;
UMat
ufacepos
,
ustages
,
uclassifiers
,
unodes
,
uleaves
,
usubsets
,
uparams
;
ocl
::
Kernel
cascadeKernel
;
bool
tryOpenCL
;
...
...
@@ -270,10 +268,9 @@ public:
virtual
Ptr
<
FeatureEvaluator
>
clone
()
const
;
virtual
int
getFeatureType
()
const
{
return
FeatureEvaluator
::
HAAR
;
}
virtual
bool
setImage
(
InputArray
,
Size
origWinSize
);
virtual
bool
setImage
(
InputArray
,
Size
origWinSize
,
Size
sumSize
);
virtual
bool
setWindow
(
Point
pt
);
virtual
bool
setUMat
(
InputArray
,
Size
origWinSize
,
Size
origImgSize
);
virtual
Rect
getNormRect
()
const
;
virtual
void
getUMats
(
std
::
vector
<
UMat
>&
bufs
);
double
operator
()(
int
featureIdx
)
const
...
...
@@ -282,22 +279,19 @@ public:
{
return
(
*
this
)(
featureIdx
);
}
protected
:
Size
origWinSize
,
origImgSize
;
Size
origWinSize
,
sumSize0
;
Ptr
<
std
::
vector
<
Feature
>
>
features
;
Ptr
<
std
::
vector
<
OptFeature
>
>
optfeatures
;
OptFeature
*
optfeaturesPtr
;
// optimization
bool
hasTiltedFeatures
;
Mat
sum0
,
sqsum0
;
Mat
sum
,
sqsum
,
tilted
;
UMat
usum
,
usqsum
,
fbuf
;
Mat
sum0
,
sum
,
sqsum0
,
sqsum
;
UMat
usum0
,
usum
,
usqsum0
,
usqsum
,
ufbuf
;
Rect
normrect
;
int
nofs
[
4
];
int
nqofs
[
4
];
const
int
*
pwin
;
const
double
*
pqwin
;
double
varianceNormFactor
;
};
...
...
@@ -376,7 +370,7 @@ public:
virtual
Ptr
<
FeatureEvaluator
>
clone
()
const
;
virtual
int
getFeatureType
()
const
{
return
FeatureEvaluator
::
LBP
;
}
virtual
bool
setImage
(
InputArray
image
,
Size
_origWinSize
);
virtual
bool
setImage
(
InputArray
image
,
Size
_origWinSize
,
Size
);
virtual
bool
setWindow
(
Point
pt
);
int
operator
()(
int
featureIdx
)
const
...
...
@@ -453,7 +447,7 @@ public:
virtual
bool
read
(
const
FileNode
&
node
);
virtual
Ptr
<
FeatureEvaluator
>
clone
()
const
;
virtual
int
getFeatureType
()
const
{
return
FeatureEvaluator
::
HOG
;
}
virtual
bool
setImage
(
InputArray
image
,
Size
winSize
);
virtual
bool
setImage
(
InputArray
image
,
Size
winSize
,
Size
);
virtual
bool
setWindow
(
Point
pt
);
double
operator
()(
int
featureIdx
)
const
{
...
...
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