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
bada364e
Commit
bada364e
authored
Dec 06, 2014
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3481 from mshabunin:python-test
parents
893deb40
84379140
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
2 deletions
+24
-2
test.py
modules/python/test/test.py
+24
-2
No files found.
modules/python/test/test.py
View file @
bada364e
...
...
@@ -15,6 +15,7 @@ import operator
import
functools
import
numpy
as
np
import
cv2
import
argparse
# Python 3 moved urlopen to urllib.requests
try
:
...
...
@@ -24,9 +25,21 @@ except ImportError:
class
NewOpenCVTests
(
unittest
.
TestCase
):
# path to local repository folder containing 'samples' folder
repoPath
=
None
# github repository url
repoUrl
=
'https://raw.github.com/Itseez/opencv/master'
def
get_sample
(
self
,
filename
,
iscolor
=
cv2
.
IMREAD_COLOR
):
if
not
filename
in
self
.
image_cache
:
filedata
=
urlopen
(
"https://raw.github.com/Itseez/opencv/master/"
+
filename
)
.
read
()
filedata
=
None
if
NewOpenCVTests
.
repoPath
is
not
None
:
candidate
=
NewOpenCVTests
.
repoPath
+
'/'
+
filename
if
os
.
path
.
isfile
(
candidate
):
with
open
(
candidate
,
'rb'
)
as
f
:
filedata
=
f
.
read
()
if
filedata
is
None
:
filedata
=
urlopen
(
NewOpenCVTests
.
repoUrl
+
'/'
+
filename
)
.
read
()
self
.
image_cache
[
filename
]
=
cv2
.
imdecode
(
np
.
fromstring
(
filedata
,
dtype
=
np
.
uint8
),
iscolor
)
return
self
.
image_cache
[
filename
]
...
...
@@ -133,6 +146,15 @@ class Hackathon244Tests(NewOpenCVTests):
self
.
assertLessEqual
(
abs
(
mr
-
mr0
),
5
)
if
__name__
==
'__main__'
:
parser
=
argparse
.
ArgumentParser
(
description
=
'run OpenCV python tests'
)
parser
.
add_argument
(
'--repo'
,
help
=
'use sample image files from local git repository (path to folder), '
'if not set, samples will be downloaded from github.com'
)
parser
.
add_argument
(
'--data'
,
help
=
'<not used> use data files from local folder (path to folder), '
'if not set, data files will be downloaded from docs.opencv.org'
)
args
,
other
=
parser
.
parse_known_args
()
print
(
"Testing OpenCV"
,
cv2
.
__version__
)
print
(
"Local repo path:"
,
args
.
repo
)
NewOpenCVTests
.
repoPath
=
args
.
repo
random
.
seed
(
0
)
unittest
.
main
()
unit_argv
=
[
sys
.
argv
[
0
]]
+
other
;
unittest
.
main
(
argv
=
unit_argv
)
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