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
8adc6201
Commit
8adc6201
authored
Nov 17, 2010
by
Alexey Spizhevoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added getDescriptors function (draft version)
parent
2d015584
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
20 deletions
+66
-20
gpu.hpp
modules/gpu/include/opencv2/gpu/gpu.hpp
+8
-1
hog.cu
modules/gpu/src/cuda/hog.cu
+3
-1
hog.cpp
modules/gpu/src/hog.cpp
+55
-18
No files found.
modules/gpu/include/opencv2/gpu/gpu.hpp
View file @
8adc6201
...
...
@@ -1001,13 +1001,15 @@ namespace cv
void
setSVMDetector
(
const
vector
<
float
>&
detector
);
bool
checkDetectorSize
()
const
;
void
computeGradient
(
const
GpuMat
&
img
,
GpuMat
&
grad
,
GpuMat
&
qangle
);
void
detect
(
const
GpuMat
&
img
,
vector
<
Point
>&
found_locations
,
double
hit_threshold
=
0
,
Size
win_stride
=
Size
(),
Size
padding
=
Size
());
void
detectMultiScale
(
const
GpuMat
&
img
,
vector
<
Rect
>&
found_locations
,
double
hit_threshold
=
0
,
Size
win_stride
=
Size
(),
Size
padding
=
Size
(),
double
scale0
=
1.05
,
int
group_threshold
=
2
);
////TODO: test it
//void getDescriptors(const GpuMat& img, Size win_stride, vector<GpuMat>& descriptors)
Size
win_size
;
Size
block_size
;
Size
block_stride
;
...
...
@@ -1032,6 +1034,11 @@ namespace cv
private
:
static
int
numPartsWithin
(
int
size
,
int
part_size
,
int
stride
);
static
Size
numPartsWithin
(
Size
size
,
Size
part_size
,
Size
stride
);
void
computeBlockHistograms
(
const
GpuMat
&
img
);
void
computeGradient
(
const
GpuMat
&
img
,
GpuMat
&
grad
,
GpuMat
&
qangle
);
GpuMat
grad
,
qangle
;
};
}
...
...
modules/gpu/src/cuda/hog.cu
View file @
8adc6201
...
...
@@ -423,11 +423,13 @@ void classify_hists(int win_height, int win_width, int block_stride_y, int block
img_win_width, img_block_width, win_block_stride_x, win_block_stride_y,
block_hists, coefs, free_coef, threshold, labels);
cudaSafeCall(cudaThreadSynchronize());
}
}
//------------------------------------------------------------
// Gradients computation
template <int nthreads>
__global__ void compute_gradients_8UC4_kernel(int height, int width, const PtrElemStep img,
float angle_scale, PtrElemStepf grad, PtrElemStep qangle)
...
...
modules/gpu/src/hog.cpp
View file @
8adc6201
...
...
@@ -53,8 +53,6 @@ void cv::gpu::HOGDescriptor::setSVMDetector(const vector<float>&) { throw_nogpu(
void
cv
::
gpu
::
HOGDescriptor
::
computeGradient
(
const
GpuMat
&
,
GpuMat
&
,
GpuMat
&
)
{
throw_nogpu
();
}
void
cv
::
gpu
::
HOGDescriptor
::
detect
(
const
GpuMat
&
,
vector
<
Point
>&
,
double
,
Size
,
Size
)
{
throw_nogpu
();
}
void
cv
::
gpu
::
HOGDescriptor
::
detectMultiScale
(
const
GpuMat
&
,
vector
<
Rect
>&
,
double
,
Size
,
Size
,
double
,
int
)
{
throw_nogpu
();
}
int
cv
::
gpu
::
HOGDescriptor
::
numPartsWithin
(
int
,
int
,
int
)
{
throw_nogpu
();
return
0
;
}
cv
::
Size
cv
::
gpu
::
HOGDescriptor
::
numPartsWithin
(
cv
::
Size
,
cv
::
Size
,
cv
::
Size
)
{
throw_nogpu
();
return
cv
::
Size
();
}
std
::
vector
<
float
>
cv
::
gpu
::
HOGDescriptor
::
getDefaultPeopleDetector
()
{
throw_nogpu
();
return
std
::
vector
<
float
>
();
}
std
::
vector
<
float
>
cv
::
gpu
::
HOGDescriptor
::
getPeopleDetector_48x96
()
{
throw_nogpu
();
return
std
::
vector
<
float
>
();
}
std
::
vector
<
float
>
cv
::
gpu
::
HOGDescriptor
::
getPeopleDetector_64x128
()
{
throw_nogpu
();
return
std
::
vector
<
float
>
();
}
...
...
@@ -197,15 +195,68 @@ void cv::gpu::HOGDescriptor::computeGradient(const GpuMat& img, GpuMat& grad, Gp
}
void
cv
::
gpu
::
HOGDescriptor
::
computeBlockHistograms
(
const
GpuMat
&
img
)
{
computeGradient
(
img
,
grad
,
qangle
);
size_t
block_hist_size
=
getBlockHistogramSize
();
Size
blocks_per_img
=
numPartsWithin
(
img
.
size
(),
block_size
,
block_stride
);
block_hists
.
create
(
1
,
block_hist_size
*
blocks_per_img
.
area
(),
CV_32F
);
hog
::
compute_hists
(
nbins
,
block_stride
.
width
,
block_stride
.
height
,
img
.
rows
,
img
.
cols
,
grad
,
qangle
,
(
float
)
getWinSigma
(),
block_hists
.
ptr
<
float
>
());
hog
::
normalize_hists
(
nbins
,
block_stride
.
width
,
block_stride
.
height
,
img
.
rows
,
img
.
cols
,
block_hists
.
ptr
<
float
>
(),
(
float
)
threshold_L2hys
);
}
////TODO: test it
//void cv::gpu::HOGDescriptor::getDescriptors(const GpuMat& img, Size win_stride,
// vector<GpuMat>& descriptors)
//{
// CV_Assert(win_stride.width % block_stride.width == 0 &&
// win_stride.height % block_stride.height == 0);
//
// computeBlockHistograms(img);
//
// Size blocks_per_img = numPartsWithin(img.size(), block_size, block_stride);
// GpuMat hists_reshaped = block_hists.reshape(0, blocks_per_img.height);
//
// const int block_hist_size = getBlockHistogramSize();
// Size blocks_per_win = numPartsWithin(win_size, block_size, block_stride);
// Size wins_per_img = numPartsWithin(img.size(), win_size, win_stride);
//
// descriptors.resize(wins_per_img.area());
// for (int i = 0; i < wins_per_img.height; ++i)
// {
// for (int j = 0; j < wins_per_img.width; ++j)
// {
// Range rows;
// rows.start = i * (blocks_per_win.height + 1);
// rows.end = rows.start + blocks_per_win.height;
//
// Range cols;
// cols.start = j * (blocks_per_win.width + 1) * block_hist_size;
// cols.end = cols.start + blocks_per_win.width * block_hist_size;
//
// descriptors[i * wins_per_img.width + j] = hists_reshaped(rows, cols);
// }
// }
//}
void
cv
::
gpu
::
HOGDescriptor
::
detect
(
const
GpuMat
&
img
,
vector
<
Point
>&
hits
,
double
hit_threshold
,
Size
win_stride
,
Size
padding
)
{
CV_Assert
(
padding
==
Size
(
0
,
0
));
hits
.
clear
();
if
(
detector
.
empty
())
return
;
GpuMat
grad
,
qangle
;
computeGradient
(
img
,
grad
,
qangle
);
computeBlockHistograms
(
img
);
if
(
win_stride
==
Size
())
win_stride
=
block_stride
;
...
...
@@ -213,22 +264,8 @@ void cv::gpu::HOGDescriptor::detect(const GpuMat& img, vector<Point>& hits, doub
CV_Assert
(
win_stride
.
width
%
block_stride
.
width
==
0
&&
win_stride
.
height
%
block_stride
.
height
==
0
);
CV_Assert
(
padding
==
Size
(
0
,
0
));
size_t
block_hist_size
=
getBlockHistogramSize
();
Size
blocks_per_win
=
numPartsWithin
(
win_size
,
block_size
,
block_stride
);
Size
wins_per_img
=
numPartsWithin
(
img
.
size
(),
win_size
,
win_stride
);
Size
blocks_per_img
=
numPartsWithin
(
img
.
size
(),
block_size
,
block_stride
);
labels
.
create
(
1
,
wins_per_img
.
area
(),
CV_8U
);
block_hists
.
create
(
1
,
block_hist_size
*
blocks_per_img
.
area
(),
CV_32F
);
hog
::
compute_hists
(
nbins
,
block_stride
.
width
,
block_stride
.
height
,
img
.
rows
,
img
.
cols
,
grad
,
qangle
,
(
float
)
getWinSigma
(),
block_hists
.
ptr
<
float
>
());
hog
::
normalize_hists
(
nbins
,
block_stride
.
width
,
block_stride
.
height
,
img
.
rows
,
img
.
cols
,
block_hists
.
ptr
<
float
>
(),
(
float
)
threshold_L2hys
);
hog
::
classify_hists
(
win_size
.
height
,
win_size
.
width
,
block_stride
.
height
,
block_stride
.
width
,
win_stride
.
height
,
win_stride
.
width
,
img
.
rows
,
img
.
cols
,
block_hists
.
ptr
<
float
>
(),
...
...
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