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
5625d795
Commit
5625d795
authored
Jan 28, 2016
by
Vladislav Sovrasov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix loading images in python tests
parent
ab4d3753
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
28 additions
and
28 deletions
+28
-28
test.py
modules/python/test/test.py
+0
-2
test_calibration.py
modules/python/test/test_calibration.py
+7
-4
test_digits.py
modules/python/test/test_digits.py
+8
-8
test_facedetect.py
modules/python/test/test_facedetect.py
+4
-4
test_gaussian_mix.py
modules/python/test/test_gaussian_mix.py
+2
-2
test_houghcircles.py
modules/python/test/test_houghcircles.py
+2
-2
test_houghlines.py
modules/python/test/test_houghlines.py
+2
-2
test_squares.py
modules/python/test/test_squares.py
+1
-1
test_texture_flow.py
modules/python/test/test_texture_flow.py
+2
-3
No files found.
modules/python/test/test.py
View file @
5625d795
#!/usr/bin/env python
from
__future__
import
print_function
import
unittest
import
random
import
time
...
...
modules/python/test/test_calibration.py
View file @
5625d795
...
...
@@ -19,9 +19,12 @@ class calibration_test(NewOpenCVTests):
def
test_calibration
(
self
):
from
glob
import
glob
img_mask
=
'../../../samples/data/left*.jpg'
# default
img_names
=
glob
(
img_mask
)
img_names
=
[]
for
i
in
range
(
1
,
15
):
if
i
<
10
:
img_names
.
append
(
'samples/data/left0{}.jpg'
.
format
(
str
(
i
)))
else
:
img_names
.
append
(
'samples/data/left{}.jpg'
.
format
(
str
(
i
)))
square_size
=
1.0
pattern_size
=
(
9
,
6
)
...
...
@@ -34,7 +37,7 @@ class calibration_test(NewOpenCVTests):
h
,
w
=
0
,
0
img_names_undistort
=
[]
for
fn
in
img_names
:
img
=
cv2
.
imread
(
fn
,
0
)
img
=
self
.
get_sample
(
fn
,
0
)
if
img
is
None
:
continue
...
...
modules/python/test/test_digits.py
View file @
5625d795
...
...
@@ -36,7 +36,7 @@ from numpy.linalg import norm
SZ
=
20
# size of each digit is SZ x SZ
CLASS_N
=
10
DIGITS_FN
=
'
../../../
samples/data/digits.png'
DIGITS_FN
=
'samples/data/digits.png'
def
split2d
(
img
,
cell_size
,
flatten
=
True
):
h
,
w
=
img
.
shape
[:
2
]
...
...
@@ -47,12 +47,6 @@ def split2d(img, cell_size, flatten=True):
cells
=
cells
.
reshape
(
-
1
,
sy
,
sx
)
return
cells
def
load_digits
(
fn
):
digits_img
=
cv2
.
imread
(
fn
,
0
)
digits
=
split2d
(
digits_img
,
(
SZ
,
SZ
))
labels
=
np
.
repeat
(
np
.
arange
(
CLASS_N
),
len
(
digits
)
/
CLASS_N
)
return
digits
,
labels
def
deskew
(
img
):
m
=
cv2
.
moments
(
img
)
if
abs
(
m
[
'mu02'
])
<
1e-2
:
...
...
@@ -134,9 +128,15 @@ from tests_common import NewOpenCVTests
class
digits_test
(
NewOpenCVTests
):
def
load_digits
(
self
,
fn
):
digits_img
=
self
.
get_sample
(
fn
,
0
)
digits
=
split2d
(
digits_img
,
(
SZ
,
SZ
))
labels
=
np
.
repeat
(
np
.
arange
(
CLASS_N
),
len
(
digits
)
/
CLASS_N
)
return
digits
,
labels
def
test_digits
(
self
):
digits
,
labels
=
load_digits
(
DIGITS_FN
)
digits
,
labels
=
self
.
load_digits
(
DIGITS_FN
)
# shuffle digits
rand
=
np
.
random
.
RandomState
(
321
)
...
...
modules/python/test/test_facedetect.py
View file @
5625d795
...
...
@@ -36,13 +36,13 @@ class facedetect_test(NewOpenCVTests):
def
test_facedetect
(
self
):
import
sys
,
getopt
cascade_fn
=
"../../../data/haarcascades/haarcascade_frontalface_alt.xml"
nested_fn
=
"../../../data/haarcascades/haarcascade_eye.xml"
cascade_fn
=
self
.
repoPath
+
'/data/haarcascades/haarcascade_frontalface_alt.xml'
nested_fn
=
self
.
repoPath
+
'/data/haarcascades/haarcascade_eye.xml'
cascade
=
cv2
.
CascadeClassifier
(
cascade_fn
)
nested
=
cv2
.
CascadeClassifier
(
nested_fn
)
dirPath
=
'
../../../
samples/data/'
dirPath
=
'samples/data/'
samples
=
[
'lena.jpg'
,
'kate.jpg'
]
faces
=
[]
...
...
@@ -62,7 +62,7 @@ class facedetect_test(NewOpenCVTests):
for
sample
in
samples
:
img
=
cv2
.
imread
(
dirPath
+
sample
)
img
=
self
.
get_sample
(
dirPath
+
sample
)
gray
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2GRAY
)
gray
=
cv2
.
GaussianBlur
(
gray
,
(
3
,
3
),
1.1
)
...
...
modules/python/test/test_gaussian_mix.py
View file @
5625d795
...
...
@@ -31,7 +31,7 @@ from tests_common import NewOpenCVTests
class
gaussian_mix_test
(
NewOpenCVTests
):
def
test_gaussian_mix
(
self
):
np
.
random
.
seed
(
10
)
cluster_n
=
5
img_size
=
512
...
...
@@ -53,7 +53,7 @@ class gaussian_mix_test(NewOpenCVTests):
for
i
in
range
(
cluster_n
):
for
j
in
range
(
cluster_n
):
if
(
cv2
.
norm
(
means
[
i
]
-
ref_distrs
[
j
][
0
],
cv2
.
NORM_L2
)
/
cv2
.
norm
(
ref_distrs
[
j
][
0
],
cv2
.
NORM_L2
)
<
meanEps
and
if
(
cv2
.
norm
(
means
[
i
]
-
ref_distrs
[
j
][
0
],
cv2
.
NORM_L2
)
/
cv2
.
norm
(
ref_distrs
[
j
][
0
],
cv2
.
NORM_L2
)
<
meanEps
and
cv2
.
norm
(
covs
[
i
]
-
ref_distrs
[
j
][
1
],
cv2
.
NORM_L2
)
/
cv2
.
norm
(
ref_distrs
[
j
][
1
],
cv2
.
NORM_L2
)
<
covEps
):
matches_count
+=
1
...
...
modules/python/test/test_houghcircles.py
View file @
5625d795
...
...
@@ -17,9 +17,9 @@ class houghcircles_test(NewOpenCVTests):
def
test_houghcircles
(
self
):
fn
=
"
../../../
samples/data/board.jpg"
fn
=
"samples/data/board.jpg"
src
=
cv2
.
imread
(
fn
,
1
)
src
=
self
.
get_sample
(
fn
,
1
)
img
=
cv2
.
cvtColor
(
src
,
cv2
.
COLOR_BGR2GRAY
)
img
=
cv2
.
medianBlur
(
img
,
5
)
...
...
modules/python/test/test_houghlines.py
View file @
5625d795
...
...
@@ -26,9 +26,9 @@ class houghlines_test(NewOpenCVTests):
def
test_houghlines
(
self
):
fn
=
"
../../..
/samples/data/pic1.png"
fn
=
"/samples/data/pic1.png"
src
=
cv2
.
imread
(
fn
)
src
=
self
.
get_sample
(
fn
)
dst
=
cv2
.
Canny
(
src
,
50
,
200
)
lines
=
cv2
.
HoughLinesP
(
dst
,
1
,
math
.
pi
/
180.0
,
40
,
np
.
array
([]),
50
,
10
)[:,
0
,:]
...
...
modules/python/test/test_squares.py
View file @
5625d795
...
...
@@ -61,7 +61,7 @@ class squares_test(NewOpenCVTests):
def
test_squares
(
self
):
img
=
cv2
.
imread
(
'../../../
samples/data/pic1.png'
)
img
=
self
.
get_sample
(
'
samples/data/pic1.png'
)
squares
=
find_squares
(
img
)
testSquares
=
[
...
...
modules/python/test/test_texture_flow.py
View file @
5625d795
...
...
@@ -21,8 +21,7 @@ class texture_flow_test(NewOpenCVTests):
def
test_texture_flow
(
self
):
fn
=
'../../../samples/data/pic6.png'
img
=
cv2
.
imread
(
fn
)
img
=
self
.
get_sample
(
'samples/data/pic6.png'
)
gray
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2GRAY
)
h
,
w
=
img
.
shape
[:
2
]
...
...
@@ -43,7 +42,7 @@ class texture_flow_test(NewOpenCVTests):
eps
=
0.05
testTextureVectors
=
[[
0
,
0
],
[
0
,
0
],
[
0
,
0
],
[
0
,
0
],
[
0
,
0
],
testTextureVectors
=
[[
0
,
0
],
[
0
,
0
],
[
0
,
0
],
[
0
,
0
],
[
0
,
0
],
[
-
38
,
70
],
[
-
79
,
3
],
[
0
,
0
],
[
0
,
0
],
[
-
39
,
69
],
[
-
79
,
-
1
],
[
0
,
0
],
[
0
,
0
],
[
0
,
-
79
],
[
17
,
-
78
],
[
-
48
,
-
63
],
[
65
,
-
46
],
[
-
69
,
-
39
],
[
-
48
,
-
63
],
[
-
45
,
66
]]
...
...
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