Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
bd13e947
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bd13e947
编写于
3月 27, 2012
作者:
V
Vladislav Vinogradov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added assertion on device features (global atomics) into gpu tests
上级
4a996111
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
483 addition
and
343 deletion
+483
-343
modules/gpu/src/brute_force_matcher.cpp
modules/gpu/src/brute_force_matcher.cpp
+98
-96
modules/gpu/src/cuda/surf.cu
modules/gpu/src/cuda/surf.cu
+126
-142
modules/gpu/src/fast.cpp
modules/gpu/src/fast.cpp
+9
-6
modules/gpu/src/surf.cpp
modules/gpu/src/surf.cpp
+6
-4
modules/gpu/test/test_features2d.cpp
modules/gpu/test/test_features2d.cpp
+224
-90
modules/gpu/test/test_filters.cpp
modules/gpu/test/test_filters.cpp
+20
-5
未找到文件。
modules/gpu/src/brute_force_matcher.cpp
浏览文件 @
bd13e947
此差异已折叠。
点击以展开。
modules/gpu/src/cuda/surf.cu
浏览文件 @
bd13e947
此差异已折叠。
点击以展开。
modules/gpu/src/fast.cpp
浏览文件 @
bd13e947
...
...
@@ -59,7 +59,7 @@ int cv::gpu::FAST_GPU::getKeyPoints(GpuMat&) { throw_nogpu(); return 0; }
#else
/* !defined (HAVE_CUDA) */
cv
::
gpu
::
FAST_GPU
::
FAST_GPU
(
int
_threshold
,
bool
_nonmaxSupression
,
double
_keypointsRatio
)
:
cv
::
gpu
::
FAST_GPU
::
FAST_GPU
(
int
_threshold
,
bool
_nonmaxSupression
,
double
_keypointsRatio
)
:
nonmaxSupression
(
_nonmaxSupression
),
threshold
(
_threshold
),
keypointsRatio
(
_keypointsRatio
),
count_
(
0
)
{
}
...
...
@@ -109,9 +109,9 @@ void cv::gpu::FAST_GPU::operator ()(const GpuMat& img, const GpuMat& mask, GpuMa
keypoints
.
cols
=
getKeyPoints
(
keypoints
);
}
namespace
cv
{
namespace
gpu
{
namespace
device
namespace
cv
{
namespace
gpu
{
namespace
device
{
namespace
fast
namespace
fast
{
int
calcKeypoints_gpu
(
DevMem2Db
img
,
DevMem2Db
mask
,
short2
*
kpLoc
,
int
maxKeypoints
,
DevMem2Di
score
,
int
threshold
);
int
nonmaxSupression_gpu
(
const
short2
*
kpLoc
,
int
count
,
DevMem2Di
score
,
short2
*
loc
,
float
*
response
);
...
...
@@ -124,7 +124,9 @@ int cv::gpu::FAST_GPU::calcKeyPointsLocation(const GpuMat& img, const GpuMat& ma
CV_Assert
(
img
.
type
()
==
CV_8UC1
);
CV_Assert
(
mask
.
empty
()
||
(
mask
.
type
()
==
CV_8UC1
&&
mask
.
size
()
==
img
.
size
()));
CV_Assert
(
TargetArchs
::
builtWith
(
GLOBAL_ATOMICS
)
&&
DeviceInfo
().
supports
(
GLOBAL_ATOMICS
));
if
(
!
TargetArchs
::
builtWith
(
GLOBAL_ATOMICS
)
||
!
DeviceInfo
().
supports
(
GLOBAL_ATOMICS
))
CV_Error
(
CV_StsNotImplemented
,
"The device doesn't support global atomics"
);
int
maxKeypoints
=
static_cast
<
int
>
(
keypointsRatio
*
img
.
size
().
area
());
...
...
@@ -146,7 +148,8 @@ int cv::gpu::FAST_GPU::getKeyPoints(GpuMat& keypoints)
{
using
namespace
cv
::
gpu
::
device
::
fast
;
CV_Assert
(
TargetArchs
::
builtWith
(
GLOBAL_ATOMICS
)
&&
DeviceInfo
().
supports
(
GLOBAL_ATOMICS
));
if
(
!
TargetArchs
::
builtWith
(
GLOBAL_ATOMICS
)
||
!
DeviceInfo
().
supports
(
GLOBAL_ATOMICS
))
CV_Error
(
CV_StsNotImplemented
,
"The device doesn't support global atomics"
);
if
(
count_
==
0
)
return
0
;
...
...
@@ -160,7 +163,7 @@ int cv::gpu::FAST_GPU::getKeyPoints(GpuMat& keypoints)
kpLoc_
.
colRange
(
0
,
count_
).
copyTo
(
locRow
);
keypoints
.
row
(
1
).
setTo
(
Scalar
::
all
(
0
));
return
count_
;
return
count_
;
}
void
cv
::
gpu
::
FAST_GPU
::
release
()
...
...
modules/gpu/src/surf.cpp
浏览文件 @
bd13e947
...
...
@@ -120,7 +120,9 @@ namespace
CV_Assert
(
!
img
.
empty
()
&&
img
.
type
()
==
CV_8UC1
);
CV_Assert
(
mask
.
empty
()
||
(
mask
.
size
()
==
img
.
size
()
&&
mask
.
type
()
==
CV_8UC1
));
CV_Assert
(
surf_
.
nOctaves
>
0
&&
surf_
.
nOctaveLayers
>
0
);
CV_Assert
(
TargetArchs
::
builtWith
(
GLOBAL_ATOMICS
)
&&
DeviceInfo
().
supports
(
GLOBAL_ATOMICS
));
if
(
!
TargetArchs
::
builtWith
(
GLOBAL_ATOMICS
)
||
!
DeviceInfo
().
supports
(
GLOBAL_ATOMICS
))
CV_Error
(
CV_StsNotImplemented
,
"The device doesn't support global atomics"
);
const
int
min_size
=
calcSize
(
surf_
.
nOctaves
-
1
,
0
);
CV_Assert
(
img_rows
-
min_size
>=
0
);
...
...
@@ -184,8 +186,8 @@ namespace
{
icvInterpolateKeypoint_gpu
(
surf_
.
det
,
surf_
.
maxPosBuffer
.
ptr
<
int4
>
(),
maxCounter
,
keypoints
.
ptr
<
float
>
(
SURF_GPU
::
X_ROW
),
keypoints
.
ptr
<
float
>
(
SURF_GPU
::
Y_ROW
),
keypoints
.
ptr
<
int
>
(
SURF_GPU
::
LAPLACIAN_ROW
),
keypoints
.
ptr
<
int
>
(
SURF_GPU
::
OCTAVE_ROW
),
keypoints
.
ptr
<
float
>
(
SURF_GPU
::
SIZE_ROW
),
keypoints
.
ptr
<
float
>
(
SURF_GPU
::
HESSIAN_ROW
),
keypoints
.
ptr
<
int
>
(
SURF_GPU
::
LAPLACIAN_ROW
),
keypoints
.
ptr
<
int
>
(
SURF_GPU
::
OCTAVE_ROW
),
keypoints
.
ptr
<
float
>
(
SURF_GPU
::
SIZE_ROW
),
keypoints
.
ptr
<
float
>
(
SURF_GPU
::
HESSIAN_ROW
),
counters
.
ptr
<
unsigned
int
>
());
}
}
...
...
@@ -306,7 +308,7 @@ void cv::gpu::SURF_GPU::downloadKeypoints(const GpuMat& keypointsGPU, vector<Key
Mat
keypointsCPU
(
keypointsGPU
);
keypoints
.
resize
(
nFeatures
);
float
*
kp_x
=
keypointsCPU
.
ptr
<
float
>
(
SURF_GPU
::
X_ROW
);
float
*
kp_y
=
keypointsCPU
.
ptr
<
float
>
(
SURF_GPU
::
Y_ROW
);
int
*
kp_laplacian
=
keypointsCPU
.
ptr
<
int
>
(
SURF_GPU
::
LAPLACIAN_ROW
);
...
...
modules/gpu/test/test_features2d.cpp
浏览文件 @
bd13e947
...
...
@@ -108,6 +108,25 @@ testing::AssertionResult assertKeyPointsEquals(const char* gold_expr, const char
#define ASSERT_KEYPOINTS_EQ(gold, actual) EXPECT_PRED_FORMAT2(assertKeyPointsEquals, gold, actual);
int
getMatchedPointsCount
(
std
::
vector
<
cv
::
KeyPoint
>&
gold
,
std
::
vector
<
cv
::
KeyPoint
>&
actual
)
{
std
::
sort
(
actual
.
begin
(),
actual
.
end
(),
KeyPointLess
());
std
::
sort
(
gold
.
begin
(),
gold
.
end
(),
KeyPointLess
());
int
validCount
=
0
;
for
(
size_t
i
=
0
;
i
<
gold
.
size
();
++
i
)
{
const
cv
::
KeyPoint
&
p1
=
gold
[
i
];
const
cv
::
KeyPoint
&
p2
=
actual
[
i
];
if
(
keyPointsEquals
(
p1
,
p2
))
++
validCount
;
}
return
validCount
;
}
int
getMatchedPointsCount
(
const
std
::
vector
<
cv
::
KeyPoint
>&
keypoints1
,
const
std
::
vector
<
cv
::
KeyPoint
>&
keypoints2
,
const
std
::
vector
<
cv
::
DMatch
>&
matches
)
{
int
validCount
=
0
;
...
...
@@ -170,20 +189,39 @@ TEST_P(SURF, Detector)
surf
.
upright
=
upright
;
surf
.
keypointsRatio
=
0.05
f
;
std
::
vector
<
cv
::
KeyPoint
>
keypoints
;
surf
(
loadMat
(
image
),
cv
::
gpu
::
GpuMat
(),
keypoints
);
if
(
!
supportFeature
(
devInfo
,
cv
::
gpu
::
GLOBAL_ATOMICS
))
{
try
{
std
::
vector
<
cv
::
KeyPoint
>
keypoints
;
surf
(
loadMat
(
image
),
cv
::
gpu
::
GpuMat
(),
keypoints
);
}
catch
(
const
cv
::
Exception
&
e
)
{
ASSERT_EQ
(
CV_StsNotImplemented
,
e
.
code
);
}
}
else
{
std
::
vector
<
cv
::
KeyPoint
>
keypoints
;
surf
(
loadMat
(
image
),
cv
::
gpu
::
GpuMat
(),
keypoints
);
cv
::
SURF
surf_gold
;
surf_gold
.
hessianThreshold
=
hessianThreshold
;
surf_gold
.
nOctaves
=
nOctaves
;
surf_gold
.
nOctaveLayers
=
nOctaveLayers
;
surf_gold
.
extended
=
extended
;
surf_gold
.
upright
=
upright
;
cv
::
SURF
surf_gold
;
surf_gold
.
hessianThreshold
=
hessianThreshold
;
surf_gold
.
nOctaves
=
nOctaves
;
surf_gold
.
nOctaveLayers
=
nOctaveLayers
;
surf_gold
.
extended
=
extended
;
surf_gold
.
upright
=
upright
;
std
::
vector
<
cv
::
KeyPoint
>
keypoints_gold
;
surf_gold
(
image
,
cv
::
noArray
(),
keypoints_gold
);
std
::
vector
<
cv
::
KeyPoint
>
keypoints_gold
;
surf_gold
(
image
,
cv
::
noArray
(),
keypoints_gold
);
ASSERT_KEYPOINTS_EQ
(
keypoints_gold
,
keypoints
);
ASSERT_EQ
(
keypoints_gold
.
size
(),
keypoints
.
size
());
int
matchedCount
=
getMatchedPointsCount
(
keypoints_gold
,
keypoints
);
double
matchedRatio
=
static_cast
<
double
>
(
matchedCount
)
/
keypoints_gold
.
size
();
EXPECT_GT
(
matchedRatio
,
0.95
);
}
}
TEST_P
(
SURF
,
Detector_Masked
)
...
...
@@ -202,20 +240,39 @@ TEST_P(SURF, Detector_Masked)
surf
.
upright
=
upright
;
surf
.
keypointsRatio
=
0.05
f
;
std
::
vector
<
cv
::
KeyPoint
>
keypoints
;
surf
(
loadMat
(
image
),
loadMat
(
mask
),
keypoints
);
if
(
!
supportFeature
(
devInfo
,
cv
::
gpu
::
GLOBAL_ATOMICS
))
{
try
{
std
::
vector
<
cv
::
KeyPoint
>
keypoints
;
surf
(
loadMat
(
image
),
loadMat
(
mask
),
keypoints
);
}
catch
(
const
cv
::
Exception
&
e
)
{
ASSERT_EQ
(
CV_StsNotImplemented
,
e
.
code
);
}
}
else
{
std
::
vector
<
cv
::
KeyPoint
>
keypoints
;
surf
(
loadMat
(
image
),
loadMat
(
mask
),
keypoints
);
cv
::
SURF
surf_gold
;
surf_gold
.
hessianThreshold
=
hessianThreshold
;
surf_gold
.
nOctaves
=
nOctaves
;
surf_gold
.
nOctaveLayers
=
nOctaveLayers
;
surf_gold
.
extended
=
extended
;
surf_gold
.
upright
=
upright
;
cv
::
SURF
surf_gold
;
surf_gold
.
hessianThreshold
=
hessianThreshold
;
surf_gold
.
nOctaves
=
nOctaves
;
surf_gold
.
nOctaveLayers
=
nOctaveLayers
;
surf_gold
.
extended
=
extended
;
surf_gold
.
upright
=
upright
;
std
::
vector
<
cv
::
KeyPoint
>
keypoints_gold
;
surf_gold
(
image
,
mask
,
keypoints_gold
);
std
::
vector
<
cv
::
KeyPoint
>
keypoints_gold
;
surf_gold
(
image
,
mask
,
keypoints_gold
);
ASSERT_EQ
(
keypoints_gold
.
size
(),
keypoints
.
size
());
int
matchedCount
=
getMatchedPointsCount
(
keypoints_gold
,
keypoints
);
double
matchedRatio
=
static_cast
<
double
>
(
matchedCount
)
/
keypoints_gold
.
size
();
ASSERT_KEYPOINTS_EQ
(
keypoints_gold
,
keypoints
);
EXPECT_GT
(
matchedRatio
,
0.95
);
}
}
TEST_P
(
SURF
,
Descriptor
)
...
...
@@ -238,23 +295,39 @@ TEST_P(SURF, Descriptor)
surf_gold
.
extended
=
extended
;
surf_gold
.
upright
=
upright
;
std
::
vector
<
cv
::
KeyPoint
>
keypoints
;
surf_gold
(
image
,
cv
::
noArray
(),
keypoints
);
if
(
!
supportFeature
(
devInfo
,
cv
::
gpu
::
GLOBAL_ATOMICS
))
{
try
{
std
::
vector
<
cv
::
KeyPoint
>
keypoints
;
cv
::
gpu
::
GpuMat
descriptors
;
surf
(
loadMat
(
image
),
cv
::
gpu
::
GpuMat
(),
keypoints
,
descriptors
);
}
catch
(
const
cv
::
Exception
&
e
)
{
ASSERT_EQ
(
CV_StsNotImplemented
,
e
.
code
);
}
}
else
{
std
::
vector
<
cv
::
KeyPoint
>
keypoints
;
surf_gold
(
image
,
cv
::
noArray
(),
keypoints
);
cv
::
gpu
::
GpuMat
descriptors
;
surf
(
loadMat
(
image
),
cv
::
gpu
::
GpuMat
(),
keypoints
,
descriptors
,
true
);
cv
::
gpu
::
GpuMat
descriptors
;
surf
(
loadMat
(
image
),
cv
::
gpu
::
GpuMat
(),
keypoints
,
descriptors
,
true
);
cv
::
Mat
descriptors_gold
;
surf_gold
(
image
,
cv
::
noArray
(),
keypoints
,
descriptors_gold
,
true
);
cv
::
Mat
descriptors_gold
;
surf_gold
(
image
,
cv
::
noArray
(),
keypoints
,
descriptors_gold
,
true
);
cv
::
BFMatcher
matcher
(
cv
::
NORM_L2
);
std
::
vector
<
cv
::
DMatch
>
matches
;
matcher
.
match
(
descriptors_gold
,
cv
::
Mat
(
descriptors
),
matches
);
cv
::
BFMatcher
matcher
(
cv
::
NORM_L2
);
std
::
vector
<
cv
::
DMatch
>
matches
;
matcher
.
match
(
descriptors_gold
,
cv
::
Mat
(
descriptors
),
matches
);
int
matchedCount
=
getMatchedPointsCount
(
keypoints
,
keypoints
,
matches
);
double
matchedRatio
=
static_cast
<
double
>
(
matchedCount
)
/
keypoints
.
size
();
int
matchedCount
=
getMatchedPointsCount
(
keypoints
,
keypoints
,
matches
);
double
matchedRatio
=
static_cast
<
double
>
(
matchedCount
)
/
keypoints
.
size
();
EXPECT_GT
(
matchedRatio
,
0.35
);
EXPECT_GT
(
matchedRatio
,
0.35
);
}
}
INSTANTIATE_TEST_CASE_P
(
GPU_Features2D
,
SURF
,
testing
::
Combine
(
...
...
@@ -295,13 +368,28 @@ TEST_P(FAST, Accuracy)
cv
::
gpu
::
FAST_GPU
fast
(
threshold
);
fast
.
nonmaxSupression
=
nonmaxSupression
;
std
::
vector
<
cv
::
KeyPoint
>
keypoints
;
fast
(
loadMat
(
image
),
cv
::
gpu
::
GpuMat
(),
keypoints
);
if
(
!
supportFeature
(
devInfo
,
cv
::
gpu
::
GLOBAL_ATOMICS
))
{
try
{
std
::
vector
<
cv
::
KeyPoint
>
keypoints
;
fast
(
loadMat
(
image
),
cv
::
gpu
::
GpuMat
(),
keypoints
);
}
catch
(
const
cv
::
Exception
&
e
)
{
ASSERT_EQ
(
CV_StsNotImplemented
,
e
.
code
);
}
}
else
{
std
::
vector
<
cv
::
KeyPoint
>
keypoints
;
fast
(
loadMat
(
image
),
cv
::
gpu
::
GpuMat
(),
keypoints
);
std
::
vector
<
cv
::
KeyPoint
>
keypoints_gold
;
cv
::
FAST
(
image
,
keypoints_gold
,
threshold
,
nonmaxSupression
);
std
::
vector
<
cv
::
KeyPoint
>
keypoints_gold
;
cv
::
FAST
(
image
,
keypoints_gold
,
threshold
,
nonmaxSupression
);
ASSERT_KEYPOINTS_EQ
(
keypoints_gold
,
keypoints
);
ASSERT_KEYPOINTS_EQ
(
keypoints_gold
,
keypoints
);
}
}
INSTANTIATE_TEST_CASE_P
(
GPU_Features2D
,
FAST
,
testing
::
Combine
(
...
...
@@ -364,24 +452,40 @@ TEST_P(ORB, Accuracy)
cv
::
gpu
::
ORB_GPU
orb
(
nFeatures
,
scaleFactor
,
nLevels
,
edgeThreshold
,
firstLevel
,
WTA_K
,
scoreType
,
patchSize
);
orb
.
blurForDescriptor
=
blurForDescriptor
;
std
::
vector
<
cv
::
KeyPoint
>
keypoints
;
cv
::
gpu
::
GpuMat
descriptors
;
orb
(
loadMat
(
image
),
loadMat
(
mask
),
keypoints
,
descriptors
);
if
(
!
supportFeature
(
devInfo
,
cv
::
gpu
::
GLOBAL_ATOMICS
))
{
try
{
std
::
vector
<
cv
::
KeyPoint
>
keypoints
;
cv
::
gpu
::
GpuMat
descriptors
;
orb
(
loadMat
(
image
),
loadMat
(
mask
),
keypoints
,
descriptors
);
}
catch
(
const
cv
::
Exception
&
e
)
{
ASSERT_EQ
(
CV_StsNotImplemented
,
e
.
code
);
}
}
else
{
std
::
vector
<
cv
::
KeyPoint
>
keypoints
;
cv
::
gpu
::
GpuMat
descriptors
;
orb
(
loadMat
(
image
),
loadMat
(
mask
),
keypoints
,
descriptors
);
cv
::
ORB
orb_gold
(
nFeatures
,
scaleFactor
,
nLevels
,
edgeThreshold
,
firstLevel
,
WTA_K
,
scoreType
,
patchSize
);
cv
::
ORB
orb_gold
(
nFeatures
,
scaleFactor
,
nLevels
,
edgeThreshold
,
firstLevel
,
WTA_K
,
scoreType
,
patchSize
);
std
::
vector
<
cv
::
KeyPoint
>
keypoints_gold
;
cv
::
Mat
descriptors_gold
;
orb_gold
(
image
,
mask
,
keypoints_gold
,
descriptors_gold
);
std
::
vector
<
cv
::
KeyPoint
>
keypoints_gold
;
cv
::
Mat
descriptors_gold
;
orb_gold
(
image
,
mask
,
keypoints_gold
,
descriptors_gold
);
cv
::
BFMatcher
matcher
(
cv
::
NORM_HAMMING
);
std
::
vector
<
cv
::
DMatch
>
matches
;
matcher
.
match
(
descriptors_gold
,
cv
::
Mat
(
descriptors
),
matches
);
cv
::
BFMatcher
matcher
(
cv
::
NORM_HAMMING
);
std
::
vector
<
cv
::
DMatch
>
matches
;
matcher
.
match
(
descriptors_gold
,
cv
::
Mat
(
descriptors
),
matches
);
int
matchedCount
=
getMatchedPointsCount
(
keypoints_gold
,
keypoints
,
matches
);
double
matchedRatio
=
static_cast
<
double
>
(
matchedCount
)
/
keypoints
.
size
();
int
matchedCount
=
getMatchedPointsCount
(
keypoints_gold
,
keypoints
,
matches
);
double
matchedRatio
=
static_cast
<
double
>
(
matchedCount
)
/
keypoints
.
size
();
EXPECT_GT
(
matchedRatio
,
0.35
);
EXPECT_GT
(
matchedRatio
,
0.35
);
}
}
INSTANTIATE_TEST_CASE_P
(
GPU_Features2D
,
ORB
,
testing
::
Combine
(
...
...
@@ -713,25 +817,40 @@ TEST_P(BruteForceMatcher, RadiusMatch)
cv
::
gpu
::
BruteForceMatcher_GPU_base
matcher
(
distType
);
std
::
vector
<
std
::
vector
<
cv
::
DMatch
>
>
matches
;
matcher
.
radiusMatch
(
loadMat
(
query
),
loadMat
(
train
),
matches
,
radius
);
if
(
!
supportFeature
(
devInfo
,
cv
::
gpu
::
GLOBAL_ATOMICS
))
{
try
{
std
::
vector
<
std
::
vector
<
cv
::
DMatch
>
>
matches
;
matcher
.
radiusMatch
(
loadMat
(
query
),
loadMat
(
train
),
matches
,
radius
);
}
catch
(
const
cv
::
Exception
&
e
)
{
ASSERT_EQ
(
CV_StsNotImplemented
,
e
.
code
);
}
}
else
{
std
::
vector
<
std
::
vector
<
cv
::
DMatch
>
>
matches
;
matcher
.
radiusMatch
(
loadMat
(
query
),
loadMat
(
train
),
matches
,
radius
);
ASSERT_EQ
(
static_cast
<
size_t
>
(
queryDescCount
),
matches
.
size
());
ASSERT_EQ
(
static_cast
<
size_t
>
(
queryDescCount
),
matches
.
size
());
int
badCount
=
0
;
for
(
size_t
i
=
0
;
i
<
matches
.
size
();
i
++
)
{
if
((
int
)
matches
[
i
].
size
()
!=
1
)
badCount
++
;
else
int
badCount
=
0
;
for
(
size_t
i
=
0
;
i
<
matches
.
size
();
i
++
)
{
cv
::
DMatch
match
=
matches
[
i
][
0
];
if
((
match
.
queryIdx
!=
(
int
)
i
)
||
(
match
.
trainIdx
!=
(
int
)
i
*
countFactor
)
||
(
match
.
imgIdx
!=
0
))
if
((
int
)
matches
[
i
].
size
()
!=
1
)
badCount
++
;
else
{
cv
::
DMatch
match
=
matches
[
i
][
0
];
if
((
match
.
queryIdx
!=
(
int
)
i
)
||
(
match
.
trainIdx
!=
(
int
)
i
*
countFactor
)
||
(
match
.
imgIdx
!=
0
))
badCount
++
;
}
}
}
ASSERT_EQ
(
0
,
badCount
);
ASSERT_EQ
(
0
,
badCount
);
}
}
TEST_P
(
BruteForceMatcher
,
RadiusMatchAdd
)
...
...
@@ -756,42 +875,57 @@ TEST_P(BruteForceMatcher, RadiusMatchAdd)
masks
[
mi
].
col
(
di
*
countFactor
).
setTo
(
cv
::
Scalar
::
all
(
0
));
}
std
::
vector
<
std
::
vector
<
cv
::
DMatch
>
>
matches
;
matcher
.
radiusMatch
(
cv
::
gpu
::
GpuMat
(
query
),
matches
,
radius
,
masks
);
if
(
!
supportFeature
(
devInfo
,
cv
::
gpu
::
GLOBAL_ATOMICS
))
{
try
{
std
::
vector
<
std
::
vector
<
cv
::
DMatch
>
>
matches
;
matcher
.
radiusMatch
(
cv
::
gpu
::
GpuMat
(
query
),
matches
,
radius
,
masks
);
}
catch
(
const
cv
::
Exception
&
e
)
{
ASSERT_EQ
(
CV_StsNotImplemented
,
e
.
code
);
}
}
else
{
std
::
vector
<
std
::
vector
<
cv
::
DMatch
>
>
matches
;
matcher
.
radiusMatch
(
cv
::
gpu
::
GpuMat
(
query
),
matches
,
radius
,
masks
);
ASSERT_EQ
(
static_cast
<
size_t
>
(
queryDescCount
),
matches
.
size
());
ASSERT_EQ
(
static_cast
<
size_t
>
(
queryDescCount
),
matches
.
size
());
int
badCount
=
0
;
int
shift
=
matcher
.
isMaskSupported
()
?
1
:
0
;
int
needMatchCount
=
matcher
.
isMaskSupported
()
?
n
-
1
:
n
;
for
(
size_t
i
=
0
;
i
<
matches
.
size
();
i
++
)
{
if
((
int
)
matches
[
i
].
size
()
!=
needMatchCount
)
badCount
++
;
else
int
badCount
=
0
;
int
shift
=
matcher
.
isMaskSupported
()
?
1
:
0
;
int
needMatchCount
=
matcher
.
isMaskSupported
()
?
n
-
1
:
n
;
for
(
size_t
i
=
0
;
i
<
matches
.
size
();
i
++
)
{
int
localBadCount
=
0
;
for
(
int
k
=
0
;
k
<
needMatchCount
;
k
++
)
if
((
int
)
matches
[
i
].
size
()
!=
needMatchCount
)
badCount
++
;
else
{
cv
::
DMatch
match
=
matches
[
i
][
k
];
int
localBadCount
=
0
;
for
(
int
k
=
0
;
k
<
needMatchCount
;
k
++
)
{
if
((
int
)
i
<
queryDescCount
/
2
)
cv
::
DMatch
match
=
matches
[
i
][
k
];
{
if
((
match
.
queryIdx
!=
(
int
)
i
)
||
(
match
.
trainIdx
!=
(
int
)
i
*
countFactor
+
k
+
shift
)
||
(
match
.
imgIdx
!=
0
)
)
localBadCount
++
;
}
else
{
if
((
match
.
queryIdx
!=
(
int
)
i
)
||
(
match
.
trainIdx
!=
((
int
)
i
-
queryDescCount
/
2
)
*
countFactor
+
k
+
shift
)
||
(
match
.
imgIdx
!=
1
)
)
localBadCount
++
;
if
((
int
)
i
<
queryDescCount
/
2
)
{
if
((
match
.
queryIdx
!=
(
int
)
i
)
||
(
match
.
trainIdx
!=
(
int
)
i
*
countFactor
+
k
+
shift
)
||
(
match
.
imgIdx
!=
0
)
)
localBadCount
++
;
}
else
{
if
((
match
.
queryIdx
!=
(
int
)
i
)
||
(
match
.
trainIdx
!=
((
int
)
i
-
queryDescCount
/
2
)
*
countFactor
+
k
+
shift
)
||
(
match
.
imgIdx
!=
1
)
)
localBadCount
++
;
}
}
}
badCount
+=
localBadCount
>
0
?
1
:
0
;
}
badCount
+=
localBadCount
>
0
?
1
:
0
;
}
}
ASSERT_EQ
(
0
,
badCount
);
ASSERT_EQ
(
0
,
badCount
);
}
}
INSTANTIATE_TEST_CASE_P
(
GPU_Features2D
,
BruteForceMatcher
,
testing
::
Combine
(
...
...
modules/gpu/test/test_filters.cpp
浏览文件 @
bd13e947
...
...
@@ -258,13 +258,28 @@ TEST_P(GaussianBlur, Accuracy)
double
sigma1
=
randomDouble
(
0.1
,
1.0
);
double
sigma2
=
randomDouble
(
0.1
,
1.0
);
cv
::
gpu
::
GpuMat
dst
=
createMat
(
size
,
type
,
useRoi
);
cv
::
gpu
::
GaussianBlur
(
loadMat
(
src
,
useRoi
),
dst
,
ksize
,
sigma1
,
sigma2
,
borderType
);
if
(
ksize
.
height
>
16
&&
!
supportFeature
(
devInfo
,
cv
::
gpu
::
FEATURE_SET_COMPUTE_20
))
{
try
{
cv
::
gpu
::
GpuMat
dst
;
cv
::
gpu
::
GaussianBlur
(
loadMat
(
src
),
dst
,
ksize
,
sigma1
,
sigma2
,
borderType
);
}
catch
(
const
cv
::
Exception
&
e
)
{
ASSERT_EQ
(
CV_StsNotImplemented
,
e
.
code
);
}
}
else
{
cv
::
gpu
::
GpuMat
dst
=
createMat
(
size
,
type
,
useRoi
);
cv
::
gpu
::
GaussianBlur
(
loadMat
(
src
,
useRoi
),
dst
,
ksize
,
sigma1
,
sigma2
,
borderType
);
cv
::
Mat
dst_gold
;
cv
::
GaussianBlur
(
src
,
dst_gold
,
ksize
,
sigma1
,
sigma2
,
borderType
);
cv
::
Mat
dst_gold
;
cv
::
GaussianBlur
(
src
,
dst_gold
,
ksize
,
sigma1
,
sigma2
,
borderType
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst
,
4.0
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst
,
4.0
);
}
}
INSTANTIATE_TEST_CASE_P
(
GPU_Filter
,
GaussianBlur
,
testing
::
Combine
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录