Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
22b028b6
Commit
22b028b6
authored
Feb 24, 2016
by
Vladislav Sovrasov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix warnings in python3
parent
e4fed417
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
32 deletions
+15
-32
test.py
modules/python/test/test.py
+2
-1
test_grabcut.py
modules/python/test/test_grabcut.py
+5
-5
test_watershed.py
modules/python/test/test_watershed.py
+3
-21
tst_scene_render.py
modules/python/test/tst_scene_render.py
+5
-5
No files found.
modules/python/test/test.py
View file @
22b028b6
...
...
@@ -136,7 +136,7 @@ if __name__ == '__main__':
try
:
NewOpenCVTests
.
extraTestDataPath
=
os
.
environ
[
'OPENCV_TEST_DATA_PATH'
]
except
KeyError
:
p
ass
p
rint
(
'Missing opencv extra repository. Some of tests may fail.'
)
random
.
seed
(
0
)
unit_argv
=
[
sys
.
argv
[
0
]]
+
other
;
unittest
.
main
(
argv
=
unit_argv
)
\ No newline at end of file
modules/python/test/test_grabcut.py
View file @
22b028b6
...
...
@@ -35,8 +35,8 @@ class grabcut_test(NewOpenCVTests):
exp_mask1
=
self
.
get_sample
(
"cv/grabcut/exp_mask1py.png"
,
0
)
exp_mask2
=
self
.
get_sample
(
"cv/grabcut/exp_mask2py.png"
,
0
)
if
img
==
None
:
self
.
assert
Equal
(
0
,
1
,
'Missing test data'
)
if
img
is
None
:
self
.
assert
True
(
False
,
'Missing test data'
)
rect
=
(
24
,
126
,
459
,
168
)
mask
=
np
.
zeros
(
img
.
shape
[:
2
],
dtype
=
np
.
uint8
)
...
...
@@ -45,10 +45,10 @@ class grabcut_test(NewOpenCVTests):
cv2
.
grabCut
(
img
,
mask
,
rect
,
bgdModel
,
fgdModel
,
0
,
cv2
.
GC_INIT_WITH_RECT
)
cv2
.
grabCut
(
img
,
mask
,
rect
,
bgdModel
,
fgdModel
,
2
,
cv2
.
GC_EVAL
)
if
mask_prob
==
None
:
if
mask_prob
is
None
:
mask_prob
=
mask
.
copy
()
cv2
.
imwrite
(
self
.
extraTestDataPath
+
'/cv/grabcut/mask_probpy.png'
,
mask_prob
)
if
exp_mask1
==
None
:
if
exp_mask1
is
None
:
exp_mask1
=
self
.
scaleMask
(
mask
)
cv2
.
imwrite
(
self
.
extraTestDataPath
+
'/cv/grabcut/exp_mask1py.png'
,
exp_mask1
)
...
...
@@ -60,7 +60,7 @@ class grabcut_test(NewOpenCVTests):
cv2
.
grabCut
(
img
,
mask
,
rect
,
bgdModel
,
fgdModel
,
0
,
cv2
.
GC_INIT_WITH_MASK
)
cv2
.
grabCut
(
img
,
mask
,
rect
,
bgdModel
,
fgdModel
,
1
,
cv2
.
GC_EVAL
)
if
exp_mask2
==
None
:
if
exp_mask2
is
None
:
exp_mask2
=
self
.
scaleMask
(
mask
)
cv2
.
imwrite
(
self
.
extraTestDataPath
+
'/cv/grabcut/exp_mask2py.png'
,
exp_mask2
)
...
...
modules/python/test/test_watershed.py
View file @
22b028b6
#!/usr/bin/env python
'''
Watershed segmentation
=========
This program demonstrates the watershed segmentation algorithm
in OpenCV: watershed().
Usage
-----
watershed.py [image filename]
Keys
----
1-7 - switch marker color
SPACE - update segmentation
r - reset
a - toggle autoupdate
ESC - exit
Watershed segmentation test
'''
# Python 2/3 compatibility
from
__future__
import
print_function
...
...
@@ -37,14 +19,14 @@ class watershed_test(NewOpenCVTests):
markers
=
self
.
get_sample
(
'cv/watershed/wshed_exp.png'
,
0
)
refSegments
=
self
.
get_sample
(
'cv/watershed/wshed_segments.png'
)
if
img
==
None
or
markers
==
None
:
if
img
is
None
or
markers
is
None
:
self
.
assertEqual
(
0
,
1
,
'Missing test data'
)
colors
=
np
.
int32
(
list
(
np
.
ndindex
(
3
,
3
,
3
))
)
*
122
cv2
.
watershed
(
img
,
np
.
int32
(
markers
))
segments
=
colors
[
np
.
maximum
(
markers
,
0
)]
if
refSegments
==
None
:
if
refSegments
is
None
:
refSegments
=
segments
.
copy
()
cv2
.
imwrite
(
self
.
extraTestDataPath
+
'/cv/watershed/wshed_segments.png'
,
refSegments
)
...
...
modules/python/test/tst_scene_render.py
View file @
22b028b6
...
...
@@ -21,7 +21,7 @@ class TestSceneRender():
self
.
noise
=
noise
self
.
speed
=
speed
if
bgImg
!=
None
:
if
bgImg
is
not
None
:
self
.
sceneBg
=
bgImg
.
copy
()
else
:
self
.
sceneBg
=
np
.
zeros
(
defaultSize
,
defaultSize
,
np
.
uint8
)
...
...
@@ -29,7 +29,7 @@ class TestSceneRender():
self
.
w
=
self
.
sceneBg
.
shape
[
0
]
self
.
h
=
self
.
sceneBg
.
shape
[
1
]
if
fgImg
!=
None
:
if
fgImg
is
not
None
:
self
.
foreground
=
fgImg
.
copy
()
self
.
center
=
self
.
currentCenter
=
(
int
(
self
.
w
/
2
-
fgImg
.
shape
[
0
]
/
2
),
int
(
self
.
h
/
2
-
fgImg
.
shape
[
1
]
/
2
))
...
...
@@ -53,7 +53,7 @@ class TestSceneRender():
def
getRectInTime
(
self
,
time
):
if
self
.
foreground
!=
None
:
if
self
.
foreground
is
not
None
:
tmp
=
np
.
array
(
self
.
center
)
+
np
.
array
((
self
.
getXOffset
(
time
),
self
.
getYOffset
(
time
)))
x0
,
y0
=
tmp
x1
,
y1
=
tmp
+
self
.
foreground
.
shape
[
0
:
2
]
...
...
@@ -65,7 +65,7 @@ class TestSceneRender():
def
getCurrentRect
(
self
):
if
self
.
foreground
!=
None
:
if
self
.
foreground
is
not
None
:
x0
=
self
.
currentCenter
[
0
]
y0
=
self
.
currentCenter
[
1
]
...
...
@@ -80,7 +80,7 @@ class TestSceneRender():
def
getNextFrame
(
self
):
img
=
self
.
sceneBg
.
copy
()
if
self
.
foreground
!=
None
:
if
self
.
foreground
is
not
None
:
self
.
currentCenter
=
(
self
.
center
[
0
]
+
self
.
getXOffset
(
self
.
time
),
self
.
center
[
1
]
+
self
.
getYOffset
(
self
.
time
))
img
[
self
.
currentCenter
[
0
]:
self
.
currentCenter
[
0
]
+
self
.
foreground
.
shape
[
0
],
self
.
currentCenter
[
1
]:
self
.
currentCenter
[
1
]
+
self
.
foreground
.
shape
[
1
]]
=
self
.
foreground
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment