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
cb7cc816
Commit
cb7cc816
authored
Jan 29, 2016
by
Vladislav Sovrasov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add dft python test, fix platform depended result in morphology test
parent
aaa43dc8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
17 deletions
+56
-17
test.py
modules/python/test/test.py
+6
-13
test_calibration.py
modules/python/test/test_calibration.py
+0
-1
test_dft.py
modules/python/test/test_dft.py
+47
-0
test_morphology.py
modules/python/test/test_morphology.py
+3
-3
No files found.
modules/python/test/test.py
View file @
cb7cc816
...
...
@@ -17,19 +17,6 @@ import numpy as np
import
cv2
import
argparse
# local test modules
from
test_digits
import
digits_test
from
test_calibration
import
calibration_test
from
test_squares
import
squares_test
from
test_texture_flow
import
texture_flow_test
from
test_fitline
import
fitline_test
from
test_houghcircles
import
houghcircles_test
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
:
from
urllib.request
import
urlopen
...
...
@@ -40,6 +27,12 @@ from tests_common import NewOpenCVTests
# Tests to run first; check the handful of basic operations that the later tests rely on
basedir
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
def
load_tests
(
loader
,
tests
,
pattern
):
tests
.
addTests
(
loader
.
discover
(
basedir
,
pattern
=
'test_*.py'
))
return
tests
class
Hackathon244Tests
(
NewOpenCVTests
):
def
test_int_array
(
self
):
...
...
modules/python/test/test_calibration.py
View file @
cb7cc816
...
...
@@ -11,7 +11,6 @@ from __future__ import print_function
import
numpy
as
np
import
cv2
from
tests_common
import
NewOpenCVTests
class
calibration_test
(
NewOpenCVTests
):
...
...
modules/python/test/test_dft.py
0 → 100644
View file @
cb7cc816
#!/usr/bin/env python
'''
Test for disctrete fourier transform (dft)
'''
# Python 2/3 compatibility
from
__future__
import
print_function
import
cv2
import
numpy
as
np
import
sys
from
tests_common
import
NewOpenCVTests
class
dft_test
(
NewOpenCVTests
):
def
test_dft
(
self
):
img
=
self
.
get_sample
(
'samples/data/rubberwhale1.png'
,
0
)
eps
=
0.001
#test direct transform
refDft
=
np
.
fft
.
fft2
(
img
)
refDftShift
=
np
.
fft
.
fftshift
(
refDft
)
refMagnitide
=
np
.
log
(
1.0
+
np
.
abs
(
refDftShift
))
testDft
=
cv2
.
dft
(
np
.
float32
(
img
),
flags
=
cv2
.
DFT_COMPLEX_OUTPUT
)
testDftShift
=
np
.
fft
.
fftshift
(
testDft
)
testMagnitude
=
np
.
log
(
1.0
+
cv2
.
magnitude
(
testDftShift
[:,:,
0
],
testDftShift
[:,:,
1
]))
refMagnitide
=
cv2
.
normalize
(
refMagnitide
,
0.0
,
1.0
,
cv2
.
NORM_MINMAX
)
testMagnitude
=
cv2
.
normalize
(
testMagnitude
,
0.0
,
1.0
,
cv2
.
NORM_MINMAX
)
self
.
assertLess
(
cv2
.
norm
(
refMagnitide
-
testMagnitude
),
eps
)
#test inverse transform
img_back
=
np
.
fft
.
ifft2
(
refDft
)
img_back
=
np
.
abs
(
img_back
)
img_backTest
=
cv2
.
idft
(
testDft
)
img_backTest
=
cv2
.
magnitude
(
img_backTest
[:,:,
0
],
img_backTest
[:,:,
1
])
img_backTest
=
cv2
.
normalize
(
img_backTest
,
0.0
,
1.0
,
cv2
.
NORM_MINMAX
)
img_back
=
cv2
.
normalize
(
img_back
,
0.0
,
1.0
,
cv2
.
NORM_MINMAX
)
self
.
assertLess
(
cv2
.
norm
(
img_back
-
img_backTest
),
eps
)
\ No newline at end of file
modules/python/test/test_morphology.py
View file @
cb7cc816
...
...
@@ -18,14 +18,14 @@ class morphology_test(NewOpenCVTests):
def
test_morphology
(
self
):
fn
=
'samples/data/
baboon.jp
g'
fn
=
'samples/data/
rubberwhale1.pn
g'
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
'
}
referenceHashes
=
{
modes
[
0
]:
'
071a526425b79e45b4d0d71ef51b0562'
,
modes
[
1
]
:
'071a526425b79e45b4d0d71ef51b0562
'
,
modes
[
2
]
:
'
427e89f581b7df1b60a831b1ed4c8618'
,
modes
[
3
]
:
'0dd8ad251088a63d0dd022bcdc57361c
'
}
def
update
(
cur_mode
):
cur_str_mode
=
str_modes
[
0
]
...
...
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