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
6801f475
Commit
6801f475
authored
Jun 25, 2012
by
Marina Kolpakova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LBP: implemented first version of device side part
parent
71f94e12
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
19 deletions
+75
-19
gpu.hpp
modules/gpu/include/opencv2/gpu/gpu.hpp
+3
-1
cascadeclassifier.cpp
modules/gpu/src/cascadeclassifier.cpp
+4
-13
lbp.cu
modules/gpu/src/cuda/lbp.cu
+39
-2
lbp.hpp
modules/gpu/src/opencv2/gpu/device/lbp.hpp
+29
-3
No files found.
modules/gpu/include/opencv2/gpu/gpu.hpp
View file @
6801f475
...
...
@@ -1454,12 +1454,14 @@ private:
int
subsetSize
;
int
nodeStep
;
//
located on gpu
//
gpu representation of classifier
GpuMat
stage_mat
;
GpuMat
trees_mat
;
GpuMat
nodes_mat
;
GpuMat
leaves_mat
;
GpuMat
subsets_mat
;
// current integral image
GpuMat
integral
;
};
...
...
modules/gpu/src/cascadeclassifier.cpp
View file @
6801f475
...
...
@@ -59,7 +59,6 @@ struct Stage
struct
DTreeNode
{
int
featureIdx
;
//float threshold; // for ordered features only
int
left
;
int
right
;
DTreeNode
(
int
f
=
0
,
int
l
=
0
,
int
r
=
0
)
:
featureIdx
(
f
),
left
(
l
),
right
(
r
)
{}
...
...
@@ -271,7 +270,8 @@ namespace cv { namespace gpu { namespace device
{
namespace
lbp
{
void
CascadeClassify
(
DevMem2Db
image
,
DevMem2Db
objects
,
double
scaleFactor
=
1.2
,
int
minNeighbors
=
4
,
cudaStream_t
stream
=
0
);
void
cascadeClassify
(
const
DevMem2Db
stages
,
const
DevMem2Di
trees
,
const
DevMem2Db
nodes
,
const
DevMem2Df
leaves
,
const
DevMem2Di
subsets
,
const
DevMem2Db
integral
,
int
workWidth
,
int
workHeight
,
int
step
,
int
subsetSize
,
DevMem2D_
<
int4
>
objects
,
int
minNeighbors
=
4
,
cudaStream_t
stream
=
0
);
}
}}}
...
...
@@ -308,17 +308,8 @@ int cv::gpu::CascadeClassifier_GPU_LBP::detectMultiScale(const GpuMat& image, Gp
int
step
=
(
factor
<=
2.
)
+
1
;
int
stripCount
=
1
,
stripSize
=
processingRectSize
.
height
;
int
y1
=
0
;
int
y2
=
processingRectSize
.
height
;
for
(
int
y
=
y1
;
y
<
y2
;
y
+=
step
)
for
(
int
x
=
0
;
x
<
processingRectSize
.
width
;
x
+=
step
)
{
//ToDO: classify
int
result
=
0
;
}
cv
::
gpu
::
device
::
lbp
::
cascadeClassify
(
stage_mat
,
trees_mat
,
nodes_mat
,
leaves_mat
,
subsets_mat
,
integral
,
processingRectSize
.
width
,
processingRectSize
.
height
,
step
,
subsetSize
,
objects
,
minNeighbors
);
}
// TODO: reject levels
...
...
modules/gpu/src/cuda/lbp.cu
View file @
6801f475
...
...
@@ -40,15 +40,51 @@
//
//M*/
#include <opencv2/gpu/device/
detail/
lbp.hpp>
#include <opencv2/gpu/device/lbp.hpp>
namespace cv { namespace gpu { namespace device
{
namespace lbp
{
void CascadeClassify(DevMem2Db image, DevMem2Db objects, double scaleFactor=1.2, int minNeighbors=4, cudaStream_t stream)
__global__ void lbp_classify(const DevMem2D_< ::cv::gpu::device::Stage> stages, const DevMem2Di trees, const DevMem2Db nodes, const DevMem2Df leaves, const DevMem2Di subsets,
const DevMem2Db integral, float step, int subsetSize, DevMem2D_<int4> objects)
{
unsigned int x = threadIdx.x;
unsigned int y = blockIdx.x;
int nodeOfs = 0, leafOfs = 0;
::cv::gpu::device::Feature feature;
for (int s = 0; s < stages.cols; s++ )
{
::cv::gpu::device::Stage stage = stages(0, s);
int sum = 0;
for (int w = 0; w < stage.ntrees; w++)
{
::cv::gpu::device::ClNode node = nodes(0, nodeOfs);
char c = feature();// TODO: inmplement it
const int subsetIdx = (nodeOfs * subsetSize);
int idx = subsetIdx + ((c >> 5) & ( 1 << (c & 31)) ? leafOfs : leafOfs + 1);
sum += leaves(0, subsets(0, idx) );
nodeOfs++;
leafOfs += 2;
}
if (sum < stage.threshold)
return; // nothing matched
return;//mathed
}
}
void cascadeClassify(const DevMem2Db bstages, const DevMem2Di trees, const DevMem2Db nodes, const DevMem2Df leaves, const DevMem2Di subsets,
const DevMem2Db integral, int workWidth, int workHeight, int step, int subsetSize, DevMem2D_<int4> objects, int minNeighbors, cudaStream_t stream)
{
printf("CascadeClassify");
int blocks = ceilf(workHeight / (float)step);
int threads = ceilf(workWidth / (float)step);
DevMem2D_< ::cv::gpu::device::Stage> stages = DevMem2D_< ::cv::gpu::device::Stage>(bstages);
lbp_classify<<<blocks, threads>>>(stages, trees, nodes, leaves, subsets, integral, step, subsetSize, objects);
}
}
}}}
\ No newline at end of file
modules/gpu/src/opencv2/gpu/device/lbp.hpp
View file @
6801f475
...
...
@@ -43,6 +43,13 @@
#ifndef __OPENCV_GPU_DEVICE_LBP_HPP_
#define __OPENCV_GPU_DEVICE_LBP_HPP_
#include "internal_shared.hpp"
// #include "opencv2/gpu/device/border_interpolate.hpp"
// #include "opencv2/gpu/device/vec_traits.hpp"
// #include "opencv2/gpu/device/vec_math.hpp"
// #include "opencv2/gpu/device/saturate_cast.hpp"
// #include "opencv2/gpu/device/filters.hpp"
// #define CALC_SUM_(p0, p1, p2, p3, offset) \
// ((p0)[offset] - (p1)[offset] - (p2)[offset] + (p3)[offset])
...
...
@@ -53,16 +60,34 @@
namespace
cv
{
namespace
gpu
{
namespace
device
{
struct
Stage
{
int
first
;
int
ntrees
;
float
threshold
;
__device__
__forceinline__
Stage
(
int
f
=
0
,
int
n
=
0
,
float
t
=
0.
f
)
:
first
(
f
),
ntrees
(
n
),
threshold
(
t
)
{}
__device__
__forceinline__
Stage
(
const
Stage
&
other
)
:
first
(
other
.
first
),
ntrees
(
other
.
ntrees
),
threshold
(
other
.
threshold
)
{}
};
struct
ClNode
{
int
featureIdx
;
int
left
;
int
right
;
__device__
__forceinline__
ClNode
(
int
f
=
0
,
int
l
=
0
,
int
r
=
0
)
:
featureIdx
(
f
),
left
(
l
),
right
(
r
)
{}
__device__
__forceinline__
ClNode
(
const
ClNode
&
other
)
:
featureIdx
(
other
.
featureIdx
),
left
(
other
.
left
),
right
(
other
.
right
)
{}
};
struct
Feature
{
__device__
__forceinline__
Feature
(
const
Feature
&
other
)
{(
void
)
other
;}
__device__
__forceinline__
Feature
()
{}
__device__
__forceinline__
char
operator
()
(
volatile
int
*
ptr
,
int
offset
)
__device__
__forceinline__
char
operator
()
(
)
//(
volatile int* ptr, int offset)
{
return
char
(
0
);
}
}
}
// namespaces
}
;
}
}
}
// namespaces
#endif
\ No newline at end of file
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