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
d23a4f50
Commit
d23a4f50
authored
Nov 28, 2012
by
marina.kolpakova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add resize
parent
8ef19e76
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
3 deletions
+44
-3
icf-sc.cu
modules/gpu/src/cuda/icf-sc.cu
+35
-0
softcascade.cpp
modules/gpu/src/softcascade.cpp
+9
-3
No files found.
modules/gpu/src/cuda/icf-sc.cu
View file @
d23a4f50
...
@@ -50,6 +50,41 @@
...
@@ -50,6 +50,41 @@
namespace cv { namespace gpu { namespace device {
namespace cv { namespace gpu { namespace device {
namespace icf {
namespace icf {
template <int FACTOR>
__device__ __forceinline__ uchar shrink(const uchar* ptr, const int pitch, const int y, const int x)
{
int out = 0;
#pragma unroll
for(int dy = 0; dy < FACTOR; ++dy)
#pragma unroll
for(int dx = 0; dx < FACTOR; ++dx)
{
out += ptr[dy * pitch + dx];
}
return static_cast<uchar>(out / (FACTOR * FACTOR));
}
template<int FACTOR>
__global__ void shrink(const uchar* __restrict__ hogluv, const int inPitch,
uchar* __restrict__ shrank, const int outPitch )
{
const int y = blockIdx.y * blockDim.y + threadIdx.y;
const int x = blockIdx.x * blockDim.x + threadIdx.x;
const uchar* ptr = hogluv + (FACTOR * y) * inPitch + (FACTOR * x);
shrank[ y * outPitch + x] = shrink<FACTOR>(ptr, inPitch, y, x);
}
void shrink(const cv::gpu::PtrStepSzb& channels, cv::gpu::PtrStepSzb shrunk)
{
dim3 block(32, 8);
dim3 grid(shrunk.cols / 32, shrunk.rows / 8);
shrink<4><<<grid, block>>>((uchar*)channels.ptr(), channels.step, (uchar*)shrunk.ptr(), shrunk.step);
cudaSafeCall(cudaDeviceSynchronize());
}
__device__ __forceinline__ void luv(const float& b, const float& g, const float& r, uchar& __l, uchar& __u, uchar& __v)
__device__ __forceinline__ void luv(const float& b, const float& g, const float& r, uchar& __l, uchar& __u, uchar& __v)
{
{
// rgb -> XYZ
// rgb -> XYZ
...
...
modules/gpu/src/softcascade.cpp
View file @
d23a4f50
...
@@ -96,6 +96,8 @@ namespace icf {
...
@@ -96,6 +96,8 @@ namespace icf {
void
bgr2Luv
(
const
PtrStepSzb
&
bgr
,
PtrStepSzb
luv
);
void
bgr2Luv
(
const
PtrStepSzb
&
bgr
,
PtrStepSzb
luv
);
void
gray2hog
(
const
PtrStepSzb
&
gray
,
PtrStepSzb
mag
,
const
int
bins
);
void
gray2hog
(
const
PtrStepSzb
&
gray
,
PtrStepSzb
mag
,
const
int
bins
);
void
shrink
(
const
cv
::
gpu
::
PtrStepSzb
&
channels
,
cv
::
gpu
::
PtrStepSzb
shrunk
);
}
}
namespace
imgproc
{
namespace
imgproc
{
...
@@ -669,13 +671,15 @@ struct SeparablePreprocessor : public cv::gpu::SCascade::Preprocessor
...
@@ -669,13 +671,15 @@ struct SeparablePreprocessor : public cv::gpu::SCascade::Preprocessor
{
{
SeparablePreprocessor
(
const
int
s
,
const
int
b
)
:
cv
::
gpu
::
SCascade
::
Preprocessor
(),
shrinkage
(
s
),
bins
(
b
)
{}
SeparablePreprocessor
(
const
int
s
,
const
int
b
)
:
cv
::
gpu
::
SCascade
::
Preprocessor
(),
shrinkage
(
s
),
bins
(
b
)
{}
virtual
void
apply
(
InputArray
_frame
,
OutputArray
_
channels
,
Stream
&
s
=
Stream
::
Null
())
virtual
void
apply
(
InputArray
_frame
,
OutputArray
_
shrunk
,
Stream
&
s
=
Stream
::
Null
())
{
{
const
GpuMat
frame
=
_frame
.
getGpuMat
();
const
GpuMat
frame
=
_frame
.
getGpuMat
();
cv
::
gpu
::
GaussianBlur
(
frame
,
bgr
,
cv
::
Size
(
3
,
3
),
-
1.0
);
cv
::
gpu
::
GaussianBlur
(
frame
,
bgr
,
cv
::
Size
(
3
,
3
),
-
1.0
);
_channels
.
create
(
frame
.
rows
*
(
4
+
bins
),
frame
.
cols
,
CV_8UC1
);
_shrunk
.
create
(
frame
.
rows
*
(
4
+
bins
)
/
shrinkage
,
frame
.
cols
/
shrinkage
,
CV_8UC1
);
GpuMat
channels
=
_channels
.
getGpuMat
();
GpuMat
shrunk
=
_shrunk
.
getGpuMat
();
channels
.
create
(
frame
.
rows
*
(
4
+
bins
),
frame
.
cols
,
CV_8UC1
);
setZero
(
channels
,
s
);
setZero
(
channels
,
s
);
cv
::
gpu
::
cvtColor
(
bgr
,
gray
,
CV_BGR2GRAY
);
cv
::
gpu
::
cvtColor
(
bgr
,
gray
,
CV_BGR2GRAY
);
...
@@ -683,6 +687,7 @@ struct SeparablePreprocessor : public cv::gpu::SCascade::Preprocessor
...
@@ -683,6 +687,7 @@ struct SeparablePreprocessor : public cv::gpu::SCascade::Preprocessor
cv
::
gpu
::
GpuMat
luv
(
channels
,
cv
::
Rect
(
0
,
bgr
.
rows
*
(
bins
+
1
),
bgr
.
cols
,
bgr
.
rows
*
3
));
cv
::
gpu
::
GpuMat
luv
(
channels
,
cv
::
Rect
(
0
,
bgr
.
rows
*
(
bins
+
1
),
bgr
.
cols
,
bgr
.
rows
*
3
));
cv
::
gpu
::
device
::
icf
::
bgr2Luv
(
bgr
,
luv
);
cv
::
gpu
::
device
::
icf
::
bgr2Luv
(
bgr
,
luv
);
cv
::
gpu
::
device
::
icf
::
shrink
(
channels
,
shrunk
);
}
}
private
:
private
:
...
@@ -691,6 +696,7 @@ private:
...
@@ -691,6 +696,7 @@ private:
GpuMat
bgr
;
GpuMat
bgr
;
GpuMat
gray
;
GpuMat
gray
;
GpuMat
channels
;
};
};
}
}
...
...
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