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
85c904a4
Commit
85c904a4
authored
Mar 18, 2012
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed build in gpu module (SURF and ORB)
parent
46248851
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
49 additions
and
52 deletions
+49
-52
CMakeLists.txt
modules/gpu/CMakeLists.txt
+1
-1
gpu.hpp
modules/gpu/include/opencv2/gpu/gpu.hpp
+13
-9
orb.cpp
modules/gpu/src/orb.cpp
+0
-0
surf.cpp
modules/gpu/src/surf.cpp
+25
-39
precomp.hpp
modules/gpu/test/precomp.hpp
+1
-0
test_arithm.cpp
modules/gpu/test/test_arithm.cpp
+1
-1
test_features2d.cpp
modules/gpu/test/test_features2d.cpp
+2
-2
test_filters.cpp
modules/gpu/test/test_filters.cpp
+6
-0
No files found.
modules/gpu/CMakeLists.txt
View file @
85c904a4
...
...
@@ -3,7 +3,7 @@ if(ANDROID OR IOS)
endif
()
set
(
the_description
"GPU-accelerated Computer Vision"
)
ocv_add_module
(
gpu opencv_imgproc opencv_calib3d opencv_objdetect opencv_video
)
ocv_add_module
(
gpu opencv_imgproc opencv_calib3d opencv_objdetect opencv_video
opencv_nonfree
)
ocv_module_include_directories
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/cuda"
)
...
...
modules/gpu/include/opencv2/gpu/gpu.hpp
View file @
85c904a4
...
...
@@ -1566,13 +1566,12 @@ public:
void
releaseMemory
();
// SURF parameters;
int
extended
;
int
upright
;
// SURF parameters
double
hessianThreshold
;
int
nOctaves
;
int
nOctaveLayers
;
bool
extended
;
bool
upright
;
//! max keypoints = min(keypointsRatio * img.size().area(), 65535)
float
keypointsRatio
;
...
...
@@ -1662,9 +1661,8 @@ public:
};
//! Constructor
//! n_features - the number of desired features
//! detector_params - parameters to use
explicit
ORB_GPU
(
size_t
n_features
=
500
,
float
scaleFactor
=
1.2
f
,
int
nlevels
=
3
);
explicit
ORB_GPU
(
int
nFeatures
=
500
,
float
scaleFactor
=
1.2
f
,
int
nLevels
=
3
,
int
edgeThreshold
=
31
,
int
firstLevel
=
0
,
int
WTA_K
=
2
,
int
scoreType
=
0
,
int
patchSize
=
31
);
//! Compute the ORB features on an image
//! image - the image to compute the features (supports only CV_8UC1 images)
...
...
@@ -1690,7 +1688,6 @@ public:
//! returns the descriptor size in bytes
inline
int
descriptorSize
()
const
{
return
kBytes
;
}
void
setParams
(
size_t
n_features
,
float
scaleFactor
,
int
nlevels
);
inline
void
setFastParams
(
int
threshold
,
bool
nonmaxSupression
=
true
)
{
fastDetector_
.
threshold
=
threshold
;
...
...
@@ -1714,7 +1711,14 @@ private:
void
mergeKeyPoints
(
GpuMat
&
keypoints
);
ORB
params_
;
int
nFeatures_
;
float
scaleFactor_
;
int
nLevels_
;
int
edgeThreshold_
;
int
firstLevel_
;
int
WTA_K_
;
int
scoreType_
;
int
patchSize_
;
// The number of desired features per scale
std
::
vector
<
size_t
>
n_features_per_level_
;
...
...
modules/gpu/src/orb.cpp
View file @
85c904a4
This diff is collapsed.
Click to expand it.
modules/gpu/src/surf.cpp
View file @
85c904a4
...
...
@@ -109,32 +109,26 @@ namespace
return
(
HAAR_SIZE0
+
HAAR_SIZE_INC
*
layer
)
<<
octave
;
}
class
SURF_GPU_Invoker
:
private
CvSURFParams
class
SURF_GPU_Invoker
{
public
:
SURF_GPU_Invoker
(
SURF_GPU
&
surf
,
const
GpuMat
&
img
,
const
GpuMat
&
mask
)
:
CvSURFParams
(
surf
),
sum
(
surf
.
sum
),
mask1
(
surf
.
mask1
),
maskSum
(
surf
.
maskSum
),
intBuffer
(
surf
.
intBuffer
),
det
(
surf
.
det
),
trace
(
surf
.
trace
),
maxPosBuffer
(
surf
.
maxPosBuffer
),
surf_
(
surf
),
img_cols
(
img
.
cols
),
img_rows
(
img
.
rows
),
use_mask
(
!
mask
.
empty
())
{
CV_Assert
(
!
img
.
empty
()
&&
img
.
type
()
==
CV_8UC1
);
CV_Assert
(
mask
.
empty
()
||
(
mask
.
size
()
==
img
.
size
()
&&
mask
.
type
()
==
CV_8UC1
));
CV_Assert
(
nOctaves
>
0
&&
nOctaveLayers
>
0
);
CV_Assert
(
surf_
.
nOctaves
>
0
&&
surf_
.
nOctaveLayers
>
0
);
CV_Assert
(
TargetArchs
::
builtWith
(
GLOBAL_ATOMICS
)
&&
DeviceInfo
().
supports
(
GLOBAL_ATOMICS
));
const
int
min_size
=
calcSize
(
nOctaves
-
1
,
0
);
const
int
min_size
=
calcSize
(
surf_
.
nOctaves
-
1
,
0
);
CV_Assert
(
img_rows
-
min_size
>=
0
);
CV_Assert
(
img_cols
-
min_size
>=
0
);
const
int
layer_rows
=
img_rows
>>
(
nOctaves
-
1
);
const
int
layer_cols
=
img_cols
>>
(
nOctaves
-
1
);
const
int
min_margin
=
((
calcSize
((
nOctaves
-
1
),
2
)
>>
1
)
>>
(
nOctaves
-
1
))
+
1
;
const
int
layer_rows
=
img_rows
>>
(
surf_
.
nOctaves
-
1
);
const
int
layer_cols
=
img_cols
>>
(
surf_
.
nOctaves
-
1
);
const
int
min_margin
=
((
calcSize
((
surf_
.
nOctaves
-
1
),
2
)
>>
1
)
>>
(
surf_
.
nOctaves
-
1
))
+
1
;
CV_Assert
(
layer_rows
-
2
*
min_margin
>
0
);
CV_Assert
(
layer_cols
-
2
*
min_margin
>
0
);
...
...
@@ -143,44 +137,44 @@ namespace
CV_Assert
(
maxFeatures
>
0
);
counters
.
create
(
1
,
nOctaves
+
1
,
CV_32SC1
);
counters
.
create
(
1
,
surf_
.
nOctaves
+
1
,
CV_32SC1
);
counters
.
setTo
(
Scalar
::
all
(
0
));
loadGlobalConstants
(
maxCandidates
,
maxFeatures
,
img_rows
,
img_cols
,
nOctaveLayers
,
static_cast
<
float
>
(
hessianThreshold
));
loadGlobalConstants
(
maxCandidates
,
maxFeatures
,
img_rows
,
img_cols
,
surf_
.
nOctaveLayers
,
static_cast
<
float
>
(
surf_
.
hessianThreshold
));
bindImgTex
(
img
);
integralBuffered
(
img
,
su
m
,
intBuffer
);
bindSumTex
(
sum
);
integralBuffered
(
img
,
su
rf_
.
sum
,
surf_
.
intBuffer
);
bindSumTex
(
su
rf_
.
su
m
);
if
(
use_mask
)
{
min
(
mask
,
1.0
,
mask1
);
integralBuffered
(
mask1
,
maskSum
,
intBuffer
);
bindMaskSumTex
(
maskSum
);
min
(
mask
,
1.0
,
surf_
.
mask1
);
integralBuffered
(
surf_
.
mask1
,
surf_
.
maskSum
,
surf_
.
intBuffer
);
bindMaskSumTex
(
surf_
.
maskSum
);
}
}
void
detectKeypoints
(
GpuMat
&
keypoints
)
{
ensureSizeIsEnough
(
img_rows
*
(
nOctaveLayers
+
2
),
img_cols
,
CV_32FC1
,
det
);
ensureSizeIsEnough
(
img_rows
*
(
nOctaveLayers
+
2
),
img_cols
,
CV_32FC1
,
trace
);
ensureSizeIsEnough
(
img_rows
*
(
surf_
.
nOctaveLayers
+
2
),
img_cols
,
CV_32FC1
,
surf_
.
det
);
ensureSizeIsEnough
(
img_rows
*
(
surf_
.
nOctaveLayers
+
2
),
img_cols
,
CV_32FC1
,
surf_
.
trace
);
ensureSizeIsEnough
(
1
,
maxCandidates
,
CV_32SC4
,
maxPosBuffer
);
ensureSizeIsEnough
(
1
,
maxCandidates
,
CV_32SC4
,
surf_
.
maxPosBuffer
);
ensureSizeIsEnough
(
SURF_GPU
::
SF_FEATURE_STRIDE
,
maxFeatures
,
CV_32FC1
,
keypoints
);
keypoints
.
setTo
(
Scalar
::
all
(
0
));
for
(
int
octave
=
0
;
octave
<
nOctaves
;
++
octave
)
for
(
int
octave
=
0
;
octave
<
surf_
.
nOctaves
;
++
octave
)
{
const
int
layer_rows
=
img_rows
>>
octave
;
const
int
layer_cols
=
img_cols
>>
octave
;
loadOctaveConstants
(
octave
,
layer_rows
,
layer_cols
);
icvCalcLayerDetAndTrace_gpu
(
det
,
trace
,
img_rows
,
img_cols
,
octave
,
nOctaveLayers
);
icvCalcLayerDetAndTrace_gpu
(
surf_
.
det
,
surf_
.
trace
,
img_rows
,
img_cols
,
octave
,
surf_
.
nOctaveLayers
);
icvFindMaximaInLayer_gpu
(
det
,
trace
,
maxPosBuffer
.
ptr
<
int4
>
(),
counters
.
ptr
<
unsigned
int
>
()
+
1
+
octave
,
img_rows
,
img_cols
,
octave
,
use_mask
,
nOctaveLayers
);
icvFindMaximaInLayer_gpu
(
surf_
.
det
,
surf_
.
trace
,
surf_
.
maxPosBuffer
.
ptr
<
int4
>
(),
counters
.
ptr
<
unsigned
int
>
()
+
1
+
octave
,
img_rows
,
img_cols
,
octave
,
use_mask
,
surf_
.
nOctaveLayers
);
unsigned
int
maxCounter
;
cudaSafeCall
(
cudaMemcpy
(
&
maxCounter
,
counters
.
ptr
<
unsigned
int
>
()
+
1
+
octave
,
sizeof
(
unsigned
int
),
cudaMemcpyDeviceToHost
)
);
...
...
@@ -188,7 +182,7 @@ namespace
if
(
maxCounter
>
0
)
{
icvInterpolateKeypoint_gpu
(
det
,
maxPosBuffer
.
ptr
<
int4
>
(),
maxCounter
,
icvInterpolateKeypoint_gpu
(
surf_
.
det
,
surf_
.
maxPosBuffer
.
ptr
<
int4
>
(),
maxCounter
,
keypoints
.
ptr
<
float
>
(
SURF_GPU
::
SF_X
),
keypoints
.
ptr
<
float
>
(
SURF_GPU
::
SF_Y
),
keypoints
.
ptr
<
int
>
(
SURF_GPU
::
SF_LAPLACIAN
),
keypoints
.
ptr
<
float
>
(
SURF_GPU
::
SF_SIZE
),
keypoints
.
ptr
<
float
>
(
SURF_GPU
::
SF_HESSIAN
),
counters
.
ptr
<
unsigned
int
>
());
...
...
@@ -200,7 +194,7 @@ namespace
keypoints
.
cols
=
featureCounter
;
if
(
upright
)
if
(
surf_
.
upright
)
keypoints
.
row
(
SURF_GPU
::
SF_DIR
).
setTo
(
Scalar
::
all
(
90.0
));
else
findOrientation
(
keypoints
);
...
...
@@ -228,15 +222,7 @@ namespace
}
private
:
GpuMat
&
sum
;
GpuMat
&
mask1
;
GpuMat
&
maskSum
;
GpuMat
&
intBuffer
;
GpuMat
&
det
;
GpuMat
&
trace
;
GpuMat
&
maxPosBuffer
;
SURF_GPU
&
surf_
;
int
img_cols
,
img_rows
;
...
...
@@ -306,7 +292,7 @@ void cv::gpu::SURF_GPU::uploadKeypoints(const vector<KeyPoint>& keypoints, GpuMa
namespace
{
int
getPointOctave
(
float
size
,
const
CvSURFParams
&
params
)
int
getPointOctave
(
float
size
,
const
SURF_GPU
&
params
)
{
int
best_octave
=
0
;
float
min_diff
=
numeric_limits
<
float
>::
max
();
...
...
modules/gpu/test/precomp.hpp
View file @
85c904a4
...
...
@@ -61,6 +61,7 @@
#include "opencv2/ts/ts.hpp"
#include "opencv2/ts/ts_perf.hpp"
#include "opencv2/gpu/gpu.hpp"
#include "opencv2/nonfree/nonfree.hpp"
#include "utility.hpp"
#include "interpolation.hpp"
...
...
modules/gpu/test/test_arithm.cpp
View file @
85c904a4
...
...
@@ -385,7 +385,7 @@ TEST_P(Sqrt, Array)
gpuRes
.
download
(
dst
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst
,
0.0
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst
,
1e-6
);
}
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Sqrt
,
Combine
(
...
...
modules/gpu/test/test_features2d.cpp
View file @
85c904a4
...
...
@@ -135,7 +135,7 @@ TEST_P(SURF, Accuracy)
dev_descriptors
.
download
(
descriptors
);
cv
::
B
ruteForceMatcher
<
cv
::
L2
<
float
>
>
matcher
;
cv
::
B
FMatcher
matcher
(
cv
::
NORM_L2
)
;
std
::
vector
<
cv
::
DMatch
>
matches
;
matcher
.
match
(
cv
::
Mat
(
static_cast
<
int
>
(
keypoints_gold
.
size
()),
64
,
CV_32FC1
,
&
descriptors_gold
[
0
]),
descriptors
,
matches
);
...
...
@@ -696,7 +696,7 @@ TEST_P(ORB, Accuracy)
d_descriptors
.
download
(
descriptors
);
cv
::
B
ruteForceMatcher
<
cv
::
Hamming
>
matcher
;
cv
::
B
FMatcher
matcher
(
cv
::
NORM_HAMMING
)
;
std
::
vector
<
cv
::
DMatch
>
matches
;
matcher
.
match
(
descriptors_gold
,
descriptors
,
matches
);
...
...
modules/gpu/test/test_filters.cpp
View file @
85c904a4
...
...
@@ -334,6 +334,9 @@ PARAM_TEST_CASE(GaussianBlur, cv::gpu::DeviceInfo, cv::Size, UseRoi)
TEST_P
(
GaussianBlur
,
Rgba
)
{
if
(
!
devInfo
.
supports
(
cv
::
gpu
::
FEATURE_SET_COMPUTE_20
)
&&
ksize
.
height
>
16
)
return
;
cv
::
Mat
dst_rgba
;
cv
::
gpu
::
GpuMat
dev_dst_rgba
;
...
...
@@ -347,6 +350,9 @@ TEST_P(GaussianBlur, Rgba)
TEST_P
(
GaussianBlur
,
Gray
)
{
if
(
!
devInfo
.
supports
(
cv
::
gpu
::
FEATURE_SET_COMPUTE_20
)
&&
ksize
.
height
>
16
)
return
;
cv
::
Mat
dst_gray
;
cv
::
gpu
::
GpuMat
dev_dst_gray
;
...
...
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