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
34b3d31f
Commit
34b3d31f
authored
Apr 05, 2016
by
Vitaly Tuzov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for nonlocal data requirement in test2.py
parent
86a72593
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
94 deletions
+1
-94
test2.py
modules/python/test/test2.py
+1
-16
ticket_6.py
modules/python/test/ticket_6.py
+0
-78
No files found.
modules/python/test/test2.py
View file @
34b3d31f
...
...
@@ -8,22 +8,7 @@ import numpy as np
import
cv2
import
cv2.cv
as
cv
class
NewOpenCVTests
(
unittest
.
TestCase
):
def
get_sample
(
self
,
filename
,
iscolor
=
cv
.
CV_LOAD_IMAGE_COLOR
):
if
not
filename
in
self
.
image_cache
:
filedata
=
urllib2
.
urlopen
(
"https://raw.github.com/Itseez/opencv/2.4/"
+
filename
)
.
read
()
image
=
cv2
.
imdecode
(
np
.
fromstring
(
filedata
,
dtype
=
np
.
uint8
),
iscolor
)
self
.
assertFalse
(
image
is
None
)
self
.
image_cache
[
filename
]
=
image
return
self
.
image_cache
[
filename
]
def
setUp
(
self
):
self
.
image_cache
=
{}
def
hashimg
(
self
,
im
):
""" Compute a hash for an image, useful for image comparisons """
return
hashlib
.
md5
(
im
.
tostring
())
.
digest
()
from
tests_common
import
NewOpenCVTests
# Tests to run first; check the handful of basic operations that the later tests rely on
...
...
modules/python/test/ticket_6.py
deleted
100755 → 0
View file @
86a72593
#!/usr/bin/env python
import
urllib
import
cv2.cv
as
cv
import
Image
import
unittest
class
TestLoadImage
(
unittest
.
TestCase
):
def
setUp
(
self
):
open
(
"large.jpg"
,
"w"
)
.
write
(
urllib
.
urlopen
(
"http://www.cs.ubc.ca/labs/lci/curious_george/img/ROS_bug_imgs/IMG_3560.jpg"
)
.
read
())
def
test_load
(
self
):
pilim
=
Image
.
open
(
"large.jpg"
)
cvim
=
cv
.
LoadImage
(
"large.jpg"
)
self
.
assert_
(
len
(
pilim
.
tostring
())
==
len
(
cvim
.
tostring
()))
class
Creating
(
unittest
.
TestCase
):
size
=
(
640
,
480
)
repeat
=
100
def
test_0_Create
(
self
):
image
=
cv
.
CreateImage
(
self
.
size
,
cv
.
IPL_DEPTH_8U
,
1
)
cnt
=
cv
.
CountNonZero
(
image
)
self
.
assertEqual
(
cnt
,
0
,
msg
=
"Created image is not black. CountNonZero=
%
i"
%
cnt
)
def
test_2_CreateRepeat
(
self
):
cnt
=
0
for
i
in
range
(
self
.
repeat
):
image
=
cv
.
CreateImage
(
self
.
size
,
cv
.
IPL_DEPTH_8U
,
1
)
cnt
+=
cv
.
CountNonZero
(
image
)
self
.
assertEqual
(
cnt
,
0
,
msg
=
"Created images are not black. Mean CountNonZero=
%.3
f"
%
(
1.
*
cnt
/
self
.
repeat
))
def
test_2a_MemCreated
(
self
):
cnt
=
0
v
=
[]
for
i
in
range
(
self
.
repeat
):
image
=
cv
.
CreateImage
(
self
.
size
,
cv
.
IPL_DEPTH_8U
,
1
)
cv
.
FillPoly
(
image
,
[[(
0
,
0
),
(
0
,
100
),
(
100
,
0
)]],
0
)
cnt
+=
cv
.
CountNonZero
(
image
)
v
.
append
(
image
)
self
.
assertEqual
(
cnt
,
0
,
msg
=
"Memorized images are not black. Mean CountNonZero=
%.3
f"
%
(
1.
*
cnt
/
self
.
repeat
))
def
test_3_tostirng
(
self
):
image
=
cv
.
CreateImage
(
self
.
size
,
cv
.
IPL_DEPTH_8U
,
1
)
image
.
tostring
()
cnt
=
cv
.
CountNonZero
(
image
)
self
.
assertEqual
(
cnt
,
0
,
msg
=
"After tostring(): CountNonZero=
%
i"
%
cnt
)
def
test_40_tostringRepeat
(
self
):
cnt
=
0
image
=
cv
.
CreateImage
(
self
.
size
,
cv
.
IPL_DEPTH_8U
,
1
)
cv
.
Set
(
image
,
cv
.
Scalar
(
0
,
0
,
0
,
0
))
for
i
in
range
(
self
.
repeat
*
100
):
image
.
tostring
()
cnt
=
cv
.
CountNonZero
(
image
)
self
.
assertEqual
(
cnt
,
0
,
msg
=
"Repeating tostring(): Mean CountNonZero=
%.3
f"
%
(
1.
*
cnt
/
self
.
repeat
))
def
test_41_CreateToStringRepeat
(
self
):
cnt
=
0
for
i
in
range
(
self
.
repeat
*
100
):
image
=
cv
.
CreateImage
(
self
.
size
,
cv
.
IPL_DEPTH_8U
,
1
)
cv
.
Set
(
image
,
cv
.
Scalar
(
0
,
0
,
0
,
0
))
image
.
tostring
()
cnt
+=
cv
.
CountNonZero
(
image
)
self
.
assertEqual
(
cnt
,
0
,
msg
=
"Repeating create and tostring(): Mean CountNonZero=
%.3
f"
%
(
1.
*
cnt
/
self
.
repeat
))
def
test_4a_MemCreatedToString
(
self
):
cnt
=
0
v
=
[]
for
i
in
range
(
self
.
repeat
):
image
=
cv
.
CreateImage
(
self
.
size
,
cv
.
IPL_DEPTH_8U
,
1
)
cv
.
Set
(
image
,
cv
.
Scalar
(
0
,
0
,
0
,
0
))
image
.
tostring
()
cnt
+=
cv
.
CountNonZero
(
image
)
v
.
append
(
image
)
self
.
assertEqual
(
cnt
,
0
,
msg
=
"Repeating and memorizing after tostring(): Mean CountNonZero=
%.3
f"
%
(
1.
*
cnt
/
self
.
repeat
))
if
__name__
==
'__main__'
:
unittest
.
main
()
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