Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
66cc440c
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,发现更多精彩内容 >>
提交
66cc440c
编写于
1月 30, 2014
作者:
A
Andrey Pavlenko
提交者:
OpenCV Buildbot
1月 30, 2014
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2226 from ilya-lavrenov:tapi_calcHist
上级
afa62c41
231bc17d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
190 addition
and
41 deletion
+190
-41
modules/core/src/matrix.cpp
modules/core/src/matrix.cpp
+38
-0
modules/imgproc/perf/opencl/perf_imgproc.cpp
modules/imgproc/perf/opencl/perf_imgproc.cpp
+40
-0
modules/imgproc/src/histogram.cpp
modules/imgproc/src/histogram.cpp
+62
-35
modules/imgproc/test/ocl/test_histogram.cpp
modules/imgproc/test/ocl/test_histogram.cpp
+50
-6
未找到文件。
modules/core/src/matrix.cpp
浏览文件 @
66cc440c
...
...
@@ -1650,6 +1650,16 @@ int _InputArray::dims(int i) const
return
vv
[
i
].
dims
;
}
if
(
k
==
STD_VECTOR_UMAT
)
{
const
std
::
vector
<
UMat
>&
vv
=
*
(
const
std
::
vector
<
UMat
>*
)
obj
;
if
(
i
<
0
)
return
1
;
CV_Assert
(
i
<
(
int
)
vv
.
size
()
);
return
vv
[
i
].
dims
;
}
if
(
k
==
OPENGL_BUFFER
)
{
CV_Assert
(
i
<
0
);
...
...
@@ -1701,6 +1711,16 @@ size_t _InputArray::total(int i) const
return
vv
[
i
].
total
();
}
if
(
k
==
STD_VECTOR_UMAT
)
{
const
std
::
vector
<
UMat
>&
vv
=
*
(
const
std
::
vector
<
UMat
>*
)
obj
;
if
(
i
<
0
)
return
vv
.
size
();
CV_Assert
(
i
<
(
int
)
vv
.
size
()
);
return
vv
[
i
].
total
();
}
return
size
(
i
).
area
();
}
...
...
@@ -1723,6 +1743,18 @@ int _InputArray::type(int i) const
if
(
k
==
NONE
)
return
-
1
;
if
(
k
==
STD_VECTOR_UMAT
)
{
const
std
::
vector
<
UMat
>&
vv
=
*
(
const
std
::
vector
<
UMat
>*
)
obj
;
if
(
vv
.
empty
()
)
{
CV_Assert
((
flags
&
FIXED_TYPE
)
!=
0
);
return
CV_MAT_TYPE
(
flags
);
}
CV_Assert
(
i
<
(
int
)
vv
.
size
()
);
return
vv
[
i
>=
0
?
i
:
0
].
type
();
}
if
(
k
==
STD_VECTOR_MAT
)
{
const
std
::
vector
<
Mat
>&
vv
=
*
(
const
std
::
vector
<
Mat
>*
)
obj
;
...
...
@@ -1793,6 +1825,12 @@ bool _InputArray::empty() const
return
vv
.
empty
();
}
if
(
k
==
STD_VECTOR_UMAT
)
{
const
std
::
vector
<
UMat
>&
vv
=
*
(
const
std
::
vector
<
UMat
>*
)
obj
;
return
vv
.
empty
();
}
if
(
k
==
OPENGL_BUFFER
)
return
((
const
ogl
::
Buffer
*
)
obj
)
->
empty
();
...
...
modules/imgproc/perf/opencl/perf_imgproc.cpp
浏览文件 @
66cc440c
...
...
@@ -61,6 +61,8 @@ OCL_PERF_TEST_P(EqualizeHistFixture, EqualizeHist, OCL_TEST_SIZES)
const
Size
srcSize
=
GetParam
();
const
double
eps
=
1
;
checkDeviceMaxMemoryAllocSize
(
srcSize
,
CV_8UC1
);
UMat
src
(
srcSize
,
CV_8UC1
),
dst
(
srcSize
,
CV_8UC1
);
declare
.
in
(
src
,
WARMUP_RNG
).
out
(
dst
);
...
...
@@ -69,6 +71,30 @@ OCL_PERF_TEST_P(EqualizeHistFixture, EqualizeHist, OCL_TEST_SIZES)
SANITY_CHECK
(
dst
,
eps
);
}
///////////// calcHist ////////////////////////
typedef
TestBaseWithParam
<
Size
>
CalcHistFixture
;
OCL_PERF_TEST_P
(
CalcHistFixture
,
CalcHist
,
OCL_TEST_SIZES
)
{
const
Size
srcSize
=
GetParam
();
const
std
::
vector
<
int
>
channels
(
1
,
0
);
std
::
vector
<
float
>
ranges
(
2
);
std
::
vector
<
int
>
histSize
(
1
,
256
);
ranges
[
0
]
=
0
;
ranges
[
1
]
=
256
;
checkDeviceMaxMemoryAllocSize
(
srcSize
,
CV_8UC1
);
UMat
src
(
srcSize
,
CV_8UC1
),
hist
(
256
,
1
,
CV_32FC1
);
declare
.
in
(
src
,
WARMUP_RNG
).
out
(
hist
);
OCL_TEST_CYCLE
()
cv
::
calcHist
(
std
::
vector
<
UMat
>
(
1
,
src
),
channels
,
noArray
(),
hist
,
histSize
,
ranges
,
false
);
SANITY_CHECK
(
hist
);
}
/////////// CopyMakeBorder //////////////////////
CV_ENUM
(
Border
,
BORDER_CONSTANT
,
BORDER_REPLICATE
,
BORDER_REFLECT
,
BORDER_WRAP
,
BORDER_REFLECT_101
)
...
...
@@ -83,6 +109,8 @@ OCL_PERF_TEST_P(CopyMakeBorderFixture, CopyMakeBorder,
const
Size
srcSize
=
get
<
0
>
(
params
);
const
int
type
=
get
<
1
>
(
params
),
borderType
=
get
<
2
>
(
params
);
checkDeviceMaxMemoryAllocSize
(
srcSize
,
type
);
UMat
src
(
srcSize
,
type
),
dst
;
const
Size
dstSize
=
srcSize
+
Size
(
12
,
12
);
dst
.
create
(
dstSize
,
type
);
...
...
@@ -105,6 +133,8 @@ OCL_PERF_TEST_P(CornerMinEigenValFixture, CornerMinEigenVal,
const
int
type
=
get
<
1
>
(
params
),
borderType
=
BORDER_REFLECT
;
const
int
blockSize
=
7
,
apertureSize
=
1
+
2
*
3
;
checkDeviceMaxMemoryAllocSize
(
srcSize
,
type
);
UMat
src
(
srcSize
,
type
),
dst
(
srcSize
,
CV_32FC1
);
declare
.
in
(
src
,
WARMUP_RNG
).
out
(
dst
);
...
...
@@ -124,6 +154,8 @@ OCL_PERF_TEST_P(CornerHarrisFixture, CornerHarris,
const
Size
srcSize
=
get
<
0
>
(
params
);
const
int
type
=
get
<
1
>
(
params
),
borderType
=
BORDER_REFLECT
;
checkDeviceMaxMemoryAllocSize
(
srcSize
,
type
);
UMat
src
(
srcSize
,
type
),
dst
(
srcSize
,
CV_32FC1
);
declare
.
in
(
src
,
WARMUP_RNG
).
out
(
dst
);
...
...
@@ -143,6 +175,8 @@ OCL_PERF_TEST_P(PreCornerDetectFixture, PreCornerDetect,
const
Size
srcSize
=
get
<
0
>
(
params
);
const
int
type
=
get
<
1
>
(
params
),
borderType
=
BORDER_REFLECT
;
checkDeviceMaxMemoryAllocSize
(
srcSize
,
type
);
UMat
src
(
srcSize
,
type
),
dst
(
srcSize
,
CV_32FC1
);
declare
.
in
(
src
,
WARMUP_RNG
).
out
(
dst
);
...
...
@@ -162,6 +196,8 @@ OCL_PERF_TEST_P(IntegralFixture, Integral1, ::testing::Combine(OCL_TEST_SIZES, O
const
Size
srcSize
=
get
<
0
>
(
params
);
const
int
ddepth
=
get
<
1
>
(
params
);
checkDeviceMaxMemoryAllocSize
(
srcSize
,
ddepth
);
UMat
src
(
srcSize
,
CV_8UC1
),
dst
(
srcSize
+
Size
(
1
,
1
),
ddepth
);
declare
.
in
(
src
,
WARMUP_RNG
).
out
(
dst
);
...
...
@@ -186,6 +222,8 @@ OCL_PERF_TEST_P(ThreshFixture, Threshold,
const
int
threshType
=
get
<
2
>
(
params
);
const
double
maxValue
=
220.0
,
threshold
=
50
;
checkDeviceMaxMemoryAllocSize
(
srcSize
,
srcType
);
UMat
src
(
srcSize
,
srcType
),
dst
(
srcSize
,
srcType
);
declare
.
in
(
src
,
WARMUP_RNG
).
out
(
dst
);
...
...
@@ -202,6 +240,8 @@ OCL_PERF_TEST_P(CLAHEFixture, CLAHE, OCL_TEST_SIZES)
{
const
Size
srcSize
=
GetParam
();
checkDeviceMaxMemoryAllocSize
(
srcSize
,
CV_8UC1
);
UMat
src
(
srcSize
,
CV_8UC1
),
dst
(
srcSize
,
CV_8UC1
);
const
double
clipLimit
=
40.0
;
declare
.
in
(
src
,
WARMUP_RNG
).
out
(
dst
);
...
...
modules/imgproc/src/histogram.cpp
浏览文件 @
66cc440c
...
...
@@ -1399,6 +1399,61 @@ static void calcHist( const Mat* images, int nimages, const int* channels,
}
}
#ifdef HAVE_OPENCL
enum
{
BINS
=
256
};
static
bool
ocl_calcHist1
(
InputArray
_src
,
OutputArray
_hist
,
int
ddepth
=
CV_32S
)
{
int
compunits
=
ocl
::
Device
::
getDefault
().
maxComputeUnits
();
size_t
wgs
=
ocl
::
Device
::
getDefault
().
maxWorkGroupSize
();
ocl
::
Kernel
k1
(
"calculate_histogram"
,
ocl
::
imgproc
::
histogram_oclsrc
,
format
(
"-D BINS=%d -D HISTS_COUNT=%d -D WGS=%d"
,
BINS
,
compunits
,
wgs
));
if
(
k1
.
empty
())
return
false
;
_hist
.
create
(
BINS
,
1
,
ddepth
);
UMat
src
=
_src
.
getUMat
(),
ghist
(
1
,
BINS
*
compunits
,
CV_32SC1
),
hist
=
ddepth
==
CV_32S
?
_hist
.
getUMat
()
:
UMat
(
BINS
,
1
,
CV_32SC1
);
k1
.
args
(
ocl
::
KernelArg
::
ReadOnly
(
src
),
ocl
::
KernelArg
::
PtrWriteOnly
(
ghist
),
(
int
)
src
.
total
());
size_t
globalsize
=
compunits
*
wgs
;
if
(
!
k1
.
run
(
1
,
&
globalsize
,
&
wgs
,
false
))
return
false
;
ocl
::
Kernel
k2
(
"merge_histogram"
,
ocl
::
imgproc
::
histogram_oclsrc
,
format
(
"-D BINS=%d -D HISTS_COUNT=%d -D WGS=%d"
,
BINS
,
compunits
,
(
int
)
wgs
));
if
(
k2
.
empty
())
return
false
;
k2
.
args
(
ocl
::
KernelArg
::
PtrReadOnly
(
ghist
),
ocl
::
KernelArg
::
PtrWriteOnly
(
hist
));
if
(
!
k2
.
run
(
1
,
&
wgs
,
&
wgs
,
false
))
return
false
;
if
(
hist
.
depth
()
!=
ddepth
)
hist
.
convertTo
(
_hist
,
ddepth
);
else
_hist
.
getUMatRef
()
=
hist
;
return
true
;
}
static
bool
ocl_calcHist
(
InputArrayOfArrays
images
,
OutputArray
hist
)
{
std
::
vector
<
UMat
>
v
;
images
.
getUMatVector
(
v
);
return
ocl_calcHist1
(
v
[
0
],
hist
,
CV_32F
);
}
#endif
}
void
cv
::
calcHist
(
const
Mat
*
images
,
int
nimages
,
const
int
*
channels
,
...
...
@@ -1417,6 +1472,12 @@ void cv::calcHist( InputArrayOfArrays images, const std::vector<int>& channels,
const
std
::
vector
<
float
>&
ranges
,
bool
accumulate
)
{
CV_OCL_RUN
(
images
.
total
()
==
1
&&
channels
.
size
()
==
1
&&
images
.
channels
(
0
)
==
1
&&
channels
[
0
]
==
0
&&
images
.
isUMatVector
()
&&
mask
.
empty
()
&&
!
accumulate
&&
histSize
.
size
()
==
1
&&
histSize
[
0
]
==
BINS
&&
ranges
.
size
()
==
2
&&
ranges
[
0
]
==
0
&&
ranges
[
1
]
==
256
,
ocl_calcHist
(
images
,
hist
))
int
i
,
dims
=
(
int
)
histSize
.
size
(),
rsz
=
(
int
)
ranges
.
size
(),
csz
=
(
int
)
channels
.
size
();
int
nimages
=
(
int
)
images
.
total
();
...
...
@@ -3290,47 +3351,13 @@ CV_IMPL void cvEqualizeHist( const CvArr* srcarr, CvArr* dstarr )
namespace
cv
{
enum
{
BINS
=
256
};
static
bool
ocl_calcHist
(
InputArray
_src
,
OutputArray
_hist
)
{
int
compunits
=
ocl
::
Device
::
getDefault
().
maxComputeUnits
();
size_t
wgs
=
ocl
::
Device
::
getDefault
().
maxWorkGroupSize
();
ocl
::
Kernel
k1
(
"calculate_histogram"
,
ocl
::
imgproc
::
histogram_oclsrc
,
format
(
"-D BINS=%d -D HISTS_COUNT=%d -D WGS=%d"
,
BINS
,
compunits
,
wgs
));
if
(
k1
.
empty
())
return
false
;
_hist
.
create
(
1
,
BINS
,
CV_32SC1
);
UMat
src
=
_src
.
getUMat
(),
hist
=
_hist
.
getUMat
(),
ghist
(
1
,
BINS
*
compunits
,
CV_32SC1
);
k1
.
args
(
ocl
::
KernelArg
::
ReadOnly
(
src
),
ocl
::
KernelArg
::
PtrWriteOnly
(
ghist
),
(
int
)
src
.
total
());
size_t
globalsize
=
compunits
*
wgs
;
if
(
!
k1
.
run
(
1
,
&
globalsize
,
&
wgs
,
false
))
return
false
;
ocl
::
Kernel
k2
(
"merge_histogram"
,
ocl
::
imgproc
::
histogram_oclsrc
,
format
(
"-D BINS=%d -D HISTS_COUNT=%d -D WGS=%d"
,
BINS
,
compunits
,
(
int
)
wgs
));
if
(
k2
.
empty
())
return
false
;
k2
.
args
(
ocl
::
KernelArg
::
PtrReadOnly
(
ghist
),
ocl
::
KernelArg
::
PtrWriteOnly
(
hist
));
return
k2
.
run
(
1
,
&
wgs
,
&
wgs
,
false
);
}
static
bool
ocl_equalizeHist
(
InputArray
_src
,
OutputArray
_dst
)
{
size_t
wgs
=
std
::
min
<
size_t
>
(
ocl
::
Device
::
getDefault
().
maxWorkGroupSize
(),
BINS
);
// calculation of histogram
UMat
hist
;
if
(
!
ocl_calcHist
(
_src
,
hist
))
if
(
!
ocl_calcHist
1
(
_src
,
hist
))
return
false
;
UMat
lut
(
1
,
256
,
CV_8UC1
);
...
...
modules/imgproc/test/ocl/test_histogram.cpp
浏览文件 @
66cc440c
...
...
@@ -144,11 +144,6 @@ PARAM_TEST_CASE(CalcBackProject, MatDepth, int, bool)
scale
=
randomDouble
(
0.1
,
1
);
}
void
Near
()
{
OCL_EXPECT_MATS_NEAR
(
dst
,
0.0
)
}
};
//////////////////////////////// CalcBackProject //////////////////////////////////////////////
...
...
@@ -162,13 +157,62 @@ OCL_TEST_P(CalcBackProject, Mat)
OCL_OFF
(
cv
::
calcBackProject
(
images_roi
,
channels
,
hist_roi
,
dst_roi
,
ranges
,
scale
));
OCL_ON
(
cv
::
calcBackProject
(
uimages_roi
,
channels
,
uhist_roi
,
udst_roi
,
ranges
,
scale
));
Near
();
OCL_EXPECT_MATS_NEAR
(
dst
,
0.0
)
}
}
//////////////////////////////// CalcHist //////////////////////////////////////////////
PARAM_TEST_CASE
(
CalcHist
,
bool
)
{
bool
useRoi
;
TEST_DECLARE_INPUT_PARAMETER
(
src
)
TEST_DECLARE_OUTPUT_PARAMETER
(
hist
)
virtual
void
SetUp
()
{
useRoi
=
GET_PARAM
(
0
);
}
virtual
void
random_roi
()
{
Size
roiSize
=
randomSize
(
1
,
MAX_VALUE
);
Border
srcBorder
=
randomBorder
(
0
,
useRoi
?
MAX_VALUE
:
0
);
randomSubMat
(
src
,
src_roi
,
roiSize
,
srcBorder
,
CV_8UC1
,
0
,
256
);
Border
histBorder
=
randomBorder
(
0
,
useRoi
?
MAX_VALUE
:
0
);
randomSubMat
(
hist
,
hist_roi
,
Size
(
1
,
256
),
histBorder
,
CV_32SC1
,
0
,
MAX_VALUE
);
UMAT_UPLOAD_INPUT_PARAMETER
(
src
)
UMAT_UPLOAD_OUTPUT_PARAMETER
(
hist
)
}
};
OCL_TEST_P
(
CalcHist
,
Mat
)
{
const
std
::
vector
<
int
>
channels
(
1
,
0
);
std
::
vector
<
float
>
ranges
(
2
);
std
::
vector
<
int
>
histSize
(
1
,
256
);
ranges
[
0
]
=
0
;
ranges
[
1
]
=
256
;
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
random_roi
();
OCL_OFF
(
cv
::
calcHist
(
std
::
vector
<
Mat
>
(
1
,
src_roi
),
channels
,
noArray
(),
hist_roi
,
histSize
,
ranges
,
false
));
OCL_ON
(
cv
::
calcHist
(
std
::
vector
<
UMat
>
(
1
,
usrc_roi
),
channels
,
noArray
(),
uhist_roi
,
histSize
,
ranges
,
false
));
OCL_EXPECT_MATS_NEAR
(
hist
,
0.0
)
}
}
/////////////////////////////////////////////////////////////////////////////////////
OCL_INSTANTIATE_TEST_CASE_P
(
Imgproc
,
CalcBackProject
,
Combine
(
Values
((
MatDepth
)
CV_8U
),
Values
(
1
,
2
),
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Imgproc
,
CalcHist
,
Values
(
true
,
false
));
}
}
// namespace cvtest::ocl
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录