Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
0f5f5756
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,发现更多精彩内容 >>
提交
0f5f5756
编写于
8月 30, 2011
作者:
V
Vladislav Vinogradov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
optimized memory usage in BruteForceMatcher_GPU_base::knnMatch when k==2
上级
837f6578
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
23 addition
and
13 deletion
+23
-13
modules/gpu/src/brute_force_matcher.cpp
modules/gpu/src/brute_force_matcher.cpp
+19
-9
modules/gpu/src/cuda/brute_force_matcher.cu
modules/gpu/src/cuda/brute_force_matcher.cu
+4
-4
未找到文件。
modules/gpu/src/brute_force_matcher.cpp
浏览文件 @
0f5f5756
...
...
@@ -446,10 +446,17 @@ void cv::gpu::BruteForceMatcher_GPU_base::knnMatch(const GpuMat& queryDescs, con
const
int
nQuery
=
queryDescs
.
rows
;
const
int
nTrain
=
trainDescs
.
rows
;
if
(
k
==
2
)
{
ensureSizeIsEnough
(
1
,
nQuery
,
CV_32SC2
,
trainIdx
);
ensureSizeIsEnough
(
1
,
nQuery
,
CV_32FC2
,
distance
);
}
else
{
ensureSizeIsEnough
(
nQuery
,
k
,
CV_32S
,
trainIdx
);
ensureSizeIsEnough
(
nQuery
,
k
,
CV_32F
,
distance
);
if
(
k
!=
2
)
ensureSizeIsEnough
(
nQuery
,
nTrain
,
CV_32FC1
,
allDist
);
}
if
(
stream
)
{
...
...
@@ -491,23 +498,26 @@ void cv::gpu::BruteForceMatcher_GPU_base::knnMatchConvert(const Mat& trainIdx, c
if
(
trainIdx
.
empty
()
||
distance
.
empty
())
return
;
CV_Assert
(
trainIdx
.
type
()
==
CV_32SC1
);
CV_Assert
(
distance
.
type
()
==
CV_32FC1
&&
distance
.
size
()
==
trainIdx
.
size
());
CV_Assert
(
trainIdx
.
type
()
==
CV_32SC2
||
trainIdx
.
type
()
==
CV_32SC1
);
CV_Assert
(
distance
.
type
()
==
CV_32FC2
||
distance
.
type
()
==
CV_32FC1
);
CV_Assert
(
distance
.
size
()
==
trainIdx
.
size
());
CV_Assert
(
trainIdx
.
isContinuous
()
&&
distance
.
isContinuous
());
const
int
nQuery
=
distance
.
rows
;
const
int
k
=
trainIdx
.
cols
;
const
int
nQuery
=
trainIdx
.
type
()
==
CV_32SC2
?
trainIdx
.
cols
:
trainIdx
.
rows
;
const
int
k
=
trainIdx
.
type
()
==
CV_32SC2
?
2
:
trainIdx
.
cols
;
matches
.
clear
();
matches
.
reserve
(
nQuery
);
const
int
*
trainIdx_ptr
=
trainIdx
.
ptr
<
int
>
();
const
float
*
distance_ptr
=
distance
.
ptr
<
float
>
();
for
(
int
queryIdx
=
0
;
queryIdx
<
nQuery
;
++
queryIdx
)
{
matches
.
push_back
(
vector
<
DMatch
>
());
vector
<
DMatch
>&
curMatches
=
matches
.
back
();
curMatches
.
reserve
(
k
);
const
int
*
trainIdx_ptr
=
trainIdx
.
ptr
<
int
>
(
queryIdx
);
const
float
*
distance_ptr
=
distance
.
ptr
<
float
>
(
queryIdx
);
for
(
int
i
=
0
;
i
<
k
;
++
i
,
++
trainIdx_ptr
,
++
distance_ptr
)
{
int
trainIdx
=
*
trainIdx_ptr
;
...
...
modules/gpu/src/cuda/brute_force_matcher.cu
浏览文件 @
0f5f5756
...
...
@@ -452,7 +452,7 @@ namespace cv { namespace gpu { namespace bfmatcher
}
template
<
int
BLOCK_DIM_X
,
int
BLOCK_DIM_Y
,
typename
VecDiff
,
typename
Dist
,
typename
T
,
typename
Mask
>
__global__
void
knnMatch2
(
const
PtrStep_
<
T
>
query
,
const
DevMem2D_
<
T
>
train
,
const
Mask
m
,
PtrStep_
<
int2
>
trainIdx
,
PtrStep_
<
float2
>
distance
)
__global__
void
knnMatch2
(
const
PtrStep_
<
T
>
query
,
const
DevMem2D_
<
T
>
train
,
const
Mask
m
,
int2
*
trainIdx
,
float2
*
distance
)
{
typedef
typename
Dist
::
result_type
result_type
;
typedef
typename
Dist
::
value_type
value_type
;
...
...
@@ -520,8 +520,8 @@ namespace cv { namespace gpu { namespace bfmatcher
}
}
trainIdx
.
ptr
(
queryIdx
)[
0
]
=
make_int2
(
bestTrainIdx1
,
bestTrainIdx2
);
distance
.
ptr
(
queryIdx
)[
0
]
=
make_float2
(
distMin1
,
distMin2
);
trainIdx
[
queryIdx
]
=
make_int2
(
bestTrainIdx1
,
bestTrainIdx2
);
distance
[
queryIdx
]
=
make_float2
(
distMin1
,
distMin2
);
}
}
...
...
@@ -556,7 +556,7 @@ namespace cv { namespace gpu { namespace bfmatcher
const
dim3
threads
(
BLOCK_DIM_X
,
BLOCK_DIM_Y
,
1
);
knnMatch2
<
BLOCK_DIM_X
,
BLOCK_DIM_Y
,
VecDiffCachedRegister
<
BLOCK_DIM_X
,
MAX_LEN
,
LEN_EQ_MAX_LEN
,
typename
Dist
::
value_type
>
,
Dist
,
T
>
<<<
grid
,
threads
,
0
,
stream
>>>
(
query
,
train
,
mask
,
trainIdx
,
distance
);
<<<
grid
,
threads
,
0
,
stream
>>>
(
query
,
train
,
mask
,
trainIdx
.
data
,
distance
.
data
);
cudaSafeCall
(
cudaGetLastError
()
);
if
(
stream
==
0
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录