Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
aaa43dc8
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,发现更多精彩内容 >>
提交
aaa43dc8
编写于
1月 29, 2016
作者:
V
Vladislav Sovrasov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add morphology python test, fix python3 compabtibility in kmeans test
上级
56571561
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
57 addition
and
8 deletion
+57
-8
modules/python/test/test.py
modules/python/test/test.py
+1
-0
modules/python/test/test_kmeans.py
modules/python/test/test_kmeans.py
+4
-7
modules/python/test/test_morphology.py
modules/python/test/test_morphology.py
+51
-0
modules/python/test/tests_common.py
modules/python/test/tests_common.py
+1
-1
未找到文件。
modules/python/test/test.py
浏览文件 @
aaa43dc8
...
...
@@ -28,6 +28,7 @@ from test_houghlines import houghlines_test
from
test_gaussian_mix
import
gaussian_mix_test
from
test_facedetect
import
facedetect_test
from
test_kmeans
import
kmeans_test
from
test_morphology
import
morphology_test
# Python 3 moved urlopen to urllib.requests
try
:
...
...
modules/python/test/test_kmeans.py
浏览文件 @
aaa43dc8
...
...
@@ -10,10 +10,13 @@ from __future__ import print_function
import
numpy
as
np
import
cv2
from
numpy
import
random
import
sys
PY3
=
sys
.
version_info
[
0
]
==
3
if
PY3
:
xrange
=
range
from
tests_common
import
NewOpenCVTests
def
make_gaussians
(
cluster_n
,
img_size
):
points
=
[]
ref_distrs
=
[]
...
...
@@ -53,12 +56,6 @@ class kmeans_test(NewOpenCVTests):
cluster_n
=
5
img_size
=
512
# generating bright palette
colors
=
np
.
zeros
((
1
,
cluster_n
,
3
),
np
.
uint8
)
colors
[
0
,:]
=
255
colors
[
0
,:,
0
]
=
np
.
arange
(
0
,
180
,
180.0
/
cluster_n
)
colors
=
cv2
.
cvtColor
(
colors
,
cv2
.
COLOR_HSV2BGR
)[
0
]
points
,
_
,
clusterSizes
=
make_gaussians
(
cluster_n
,
img_size
)
term_crit
=
(
cv2
.
TERM_CRITERIA_EPS
,
30
,
0.1
)
...
...
modules/python/test/test_morphology.py
0 → 100644
浏览文件 @
aaa43dc8
#!/usr/bin/env python
'''
Morphology operations.
'''
# Python 2/3 compatibility
from
__future__
import
print_function
import
sys
PY3
=
sys
.
version_info
[
0
]
==
3
import
numpy
as
np
import
cv2
from
tests_common
import
NewOpenCVTests
class
morphology_test
(
NewOpenCVTests
):
def
test_morphology
(
self
):
fn
=
'samples/data/baboon.jpg'
img
=
self
.
get_sample
(
fn
)
modes
=
[
'erode/dilate'
,
'open/close'
,
'blackhat/tophat'
,
'gradient'
]
str_modes
=
[
'ellipse'
,
'rect'
,
'cross'
]
referenceHashes
=
{
modes
[
0
]:
'1bd14fc814e41b80ce7816bc04f60b65'
,
modes
[
1
]
:
'1bd14fc814e41b80ce7816bc04f60b65'
,
modes
[
2
]
:
'cb18a5d28e77522dfec6a6255bc3847e'
,
modes
[
3
]
:
'84909517e4866aa079f4b2e2906bf47b'
}
def
update
(
cur_mode
):
cur_str_mode
=
str_modes
[
0
]
sz
=
10
iters
=
1
opers
=
cur_mode
.
split
(
'/'
)
if
len
(
opers
)
>
1
:
sz
=
sz
-
10
op
=
opers
[
sz
>
0
]
sz
=
abs
(
sz
)
else
:
op
=
opers
[
0
]
sz
=
sz
*
2
+
1
str_name
=
'MORPH_'
+
cur_str_mode
.
upper
()
oper_name
=
'MORPH_'
+
op
.
upper
()
st
=
cv2
.
getStructuringElement
(
getattr
(
cv2
,
str_name
),
(
sz
,
sz
))
return
cv2
.
morphologyEx
(
img
,
getattr
(
cv2
,
oper_name
),
st
,
iterations
=
iters
)
for
mode
in
modes
:
res
=
update
(
mode
)
self
.
assertEqual
(
self
.
hashimg
(
res
),
referenceHashes
[
mode
])
\ No newline at end of file
modules/python/test/tests_common.py
浏览文件 @
aaa43dc8
...
...
@@ -40,7 +40,7 @@ class NewOpenCVTests(unittest.TestCase):
def
hashimg
(
self
,
im
):
""" Compute a hash for an image, useful for image comparisons """
return
hashlib
.
md5
(
im
.
tostring
()).
digest
()
return
hashlib
.
md5
(
im
.
tostring
()).
hex
digest
()
if
sys
.
version_info
[:
2
]
==
(
2
,
6
):
def
assertLess
(
self
,
a
,
b
,
msg
=
None
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录