Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
435c97c7
O
Opencv
项目概览
Greenplum
/
Opencv
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
435c97c7
编写于
12月 10, 2019
作者:
M
Maksim Shabunin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
imgproc: add parameter checks in calcHist and calcBackProj
上级
939099b9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
48 addition
and
3 deletion
+48
-3
modules/imgproc/src/histogram.cpp
modules/imgproc/src/histogram.cpp
+11
-3
modules/imgproc/test/test_histograms.cpp
modules/imgproc/test/test_histograms.cpp
+37
-0
未找到文件。
modules/imgproc/src/histogram.cpp
浏览文件 @
435c97c7
...
...
@@ -75,8 +75,8 @@ calcHistLookupTables_8u( const Mat& hist, const SparseMat& shist,
int
sz
=
!
issparse
?
hist
.
size
[
i
]
:
shist
.
size
(
i
);
size_t
step
=
!
issparse
?
hist
.
step
[
i
]
:
1
;
double
v_lo
=
ranges
[
i
][
0
]
;
double
v_hi
=
ranges
[
i
][
1
]
;
double
v_lo
=
ranges
?
ranges
[
i
][
0
]
:
0
;
double
v_hi
=
ranges
?
ranges
[
i
][
1
]
:
256
;
for
(
j
=
low
;
j
<
high
;
j
++
)
{
...
...
@@ -183,7 +183,7 @@ static void histPrepareImages( const Mat* images, int nimages, const int* channe
imsize
.
height
=
1
;
}
if
(
!
ranges
)
if
(
!
ranges
)
// implicit uniform ranges for 8U
{
CV_Assert
(
depth
==
CV_8U
);
...
...
@@ -951,6 +951,8 @@ void cv::calcHist( const Mat* images, int nimages, const int* channels,
{
CV_INSTRUMENT_REGION
();
CV_Assert
(
images
&&
nimages
>
0
);
CV_OVX_RUN
(
images
&&
histSize
&&
nimages
==
1
&&
images
[
0
].
type
()
==
CV_8UC1
&&
dims
==
1
&&
_mask
.
getMat
().
empty
()
&&
...
...
@@ -1261,6 +1263,8 @@ void cv::calcHist( const Mat* images, int nimages, const int* channels,
{
CV_INSTRUMENT_REGION
();
CV_Assert
(
images
&&
nimages
>
0
);
Mat
mask
=
_mask
.
getMat
();
calcHist
(
images
,
nimages
,
channels
,
mask
,
hist
,
dims
,
histSize
,
ranges
,
uniform
,
accumulate
,
false
);
...
...
@@ -1608,6 +1612,8 @@ void cv::calcBackProject( const Mat* images, int nimages, const int* channels,
{
CV_INSTRUMENT_REGION
();
CV_Assert
(
images
&&
nimages
>
0
);
Mat
hist
=
_hist
.
getMat
();
std
::
vector
<
uchar
*>
ptrs
;
std
::
vector
<
int
>
deltas
;
...
...
@@ -1777,6 +1783,8 @@ void cv::calcBackProject( const Mat* images, int nimages, const int* channels,
{
CV_INSTRUMENT_REGION
();
CV_Assert
(
images
&&
nimages
>
0
);
std
::
vector
<
uchar
*>
ptrs
;
std
::
vector
<
int
>
deltas
;
std
::
vector
<
double
>
uniranges
;
...
...
modules/imgproc/test/test_histograms.cpp
浏览文件 @
435c97c7
...
...
@@ -1957,5 +1957,42 @@ TEST(Imgproc_Hist_Calc, calcHist_regression_11544)
}
}
TEST
(
Imgproc_Hist_Calc
,
badarg
)
{
const
int
channels
[]
=
{
0
};
float
range1
[]
=
{
0
,
10
};
float
range2
[]
=
{
10
,
20
};
const
float
*
ranges
[]
=
{
range1
,
range2
};
Mat
img
=
cv
::
Mat
::
zeros
(
10
,
10
,
CV_8UC1
);
Mat
imgInt
=
cv
::
Mat
::
zeros
(
10
,
10
,
CV_32SC1
);
Mat
hist
;
const
int
hist_size
[]
=
{
100
};
// base run
EXPECT_NO_THROW
(
cv
::
calcHist
(
&
img
,
1
,
channels
,
noArray
(),
hist
,
1
,
hist_size
,
ranges
,
true
));
// bad parameters
EXPECT_THROW
(
cv
::
calcHist
(
NULL
,
1
,
channels
,
noArray
(),
hist
,
1
,
hist_size
,
ranges
,
true
),
cv
::
Exception
);
EXPECT_THROW
(
cv
::
calcHist
(
&
img
,
0
,
channels
,
noArray
(),
hist
,
1
,
hist_size
,
ranges
,
true
),
cv
::
Exception
);
EXPECT_THROW
(
cv
::
calcHist
(
&
img
,
1
,
NULL
,
noArray
(),
hist
,
2
,
hist_size
,
ranges
,
true
),
cv
::
Exception
);
EXPECT_THROW
(
cv
::
calcHist
(
&
img
,
1
,
channels
,
noArray
(),
noArray
(),
1
,
hist_size
,
ranges
,
true
),
cv
::
Exception
);
EXPECT_THROW
(
cv
::
calcHist
(
&
img
,
1
,
channels
,
noArray
(),
hist
,
-
1
,
hist_size
,
ranges
,
true
),
cv
::
Exception
);
EXPECT_THROW
(
cv
::
calcHist
(
&
img
,
1
,
channels
,
noArray
(),
hist
,
1
,
NULL
,
ranges
,
true
),
cv
::
Exception
);
EXPECT_THROW
(
cv
::
calcHist
(
&
imgInt
,
1
,
channels
,
noArray
(),
hist
,
1
,
hist_size
,
NULL
,
true
),
cv
::
Exception
);
// special case
EXPECT_NO_THROW
(
cv
::
calcHist
(
&
img
,
1
,
channels
,
noArray
(),
hist
,
1
,
hist_size
,
NULL
,
true
));
Mat
backProj
;
// base run
EXPECT_NO_THROW
(
cv
::
calcBackProject
(
&
img
,
1
,
channels
,
hist
,
backProj
,
ranges
,
1
,
true
));
// bad parameters
EXPECT_THROW
(
cv
::
calcBackProject
(
NULL
,
1
,
channels
,
hist
,
backProj
,
ranges
,
1
,
true
),
cv
::
Exception
);
EXPECT_THROW
(
cv
::
calcBackProject
(
&
img
,
0
,
channels
,
hist
,
backProj
,
ranges
,
1
,
true
),
cv
::
Exception
);
EXPECT_THROW
(
cv
::
calcBackProject
(
&
img
,
1
,
channels
,
noArray
(),
backProj
,
ranges
,
1
,
true
),
cv
::
Exception
);
EXPECT_THROW
(
cv
::
calcBackProject
(
&
img
,
1
,
channels
,
hist
,
noArray
(),
ranges
,
1
,
true
),
cv
::
Exception
);
EXPECT_THROW
(
cv
::
calcBackProject
(
&
imgInt
,
1
,
channels
,
hist
,
backProj
,
NULL
,
1
,
true
),
cv
::
Exception
);
// special case
EXPECT_NO_THROW
(
cv
::
calcBackProject
(
&
img
,
1
,
channels
,
hist
,
backProj
,
NULL
,
1
,
true
));
}
}}
// namespace
/* End Of File */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录