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
d22b9475
Commit
d22b9475
authored
Jun 14, 2011
by
Alexander Shishkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed test_precornerdetect, test_findstereocorrespondence, test_calchist
parent
b9f5a2f4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
4 deletions
+65
-4
test.py
tests/python/test.py
+4
-4
test_functions.py
tests/python/test_functions.py
+61
-0
No files found.
tests/python/test.py
View file @
d22b9475
...
...
@@ -2107,8 +2107,8 @@ class DocumentFragmentTests(OpenCVTests):
sys
.
path
.
append
(
"../doc/python_fragments"
)
def
test_precornerdetect
(
self
):
from
precornerdetect
import
precornerdetect
im
=
self
.
get_sample
(
"samples/c/right01.jpg"
,
0
)
from
test_functions
import
precornerdetect
im
=
self
.
get_sample
(
"samples/c
pp
/right01.jpg"
,
0
)
imf
=
cv
.
CreateMat
(
im
.
rows
,
im
.
cols
,
cv
.
CV_32FC1
)
cv
.
ConvertScale
(
im
,
imf
)
(
r0
,
r1
)
=
precornerdetect
(
imf
)
...
...
@@ -2117,7 +2117,7 @@ class DocumentFragmentTests(OpenCVTests):
self
.
assertEqual
(
im
.
rows
,
r
.
rows
)
def
test_findstereocorrespondence
(
self
):
from
findstereocorrespondence
import
findstereocorrespondence
from
test_functions
import
findstereocorrespondence
(
l
,
r
)
=
[
self
.
get_sample
(
"doc/pics/tsukuba_
%
s.png"
%
c
,
cv
.
CV_LOAD_IMAGE_GRAYSCALE
)
for
c
in
"lr"
]
(
disparity_left
,
disparity_right
)
=
findstereocorrespondence
(
l
,
r
)
...
...
@@ -2127,7 +2127,7 @@ class DocumentFragmentTests(OpenCVTests):
# self.snap(disparity_left_visual)
def
test_calchist
(
self
):
from
calchist
import
hs_histogram
from
test_functions
import
hs_histogram
i1
=
self
.
get_sample
(
"samples/c/lena.jpg"
)
i2
=
self
.
get_sample
(
"doc/pics/building.jpg"
)
i3
=
cv
.
CloneMat
(
i1
)
...
...
tests/python/test_functions.py
0 → 100644
View file @
d22b9475
import
sys
import
cv
def
hs_histogram
(
src
):
# Convert to HSV
hsv
=
cv
.
CreateImage
(
cv
.
GetSize
(
src
),
8
,
3
)
cv
.
CvtColor
(
src
,
hsv
,
cv
.
CV_BGR2HSV
)
# Extract the H and S planes
h_plane
=
cv
.
CreateMat
(
src
.
rows
,
src
.
cols
,
cv
.
CV_8UC1
)
s_plane
=
cv
.
CreateMat
(
src
.
rows
,
src
.
cols
,
cv
.
CV_8UC1
)
cv
.
Split
(
hsv
,
h_plane
,
s_plane
,
None
,
None
)
planes
=
[
h_plane
,
s_plane
]
h_bins
=
30
s_bins
=
32
hist_size
=
[
h_bins
,
s_bins
]
# hue varies from 0 (~0 deg red) to 180 (~360 deg red again */
h_ranges
=
[
0
,
180
]
# saturation varies from 0 (black-gray-white) to
# 255 (pure spectrum color)
s_ranges
=
[
0
,
255
]
ranges
=
[
h_ranges
,
s_ranges
]
scale
=
10
hist
=
cv
.
CreateHist
([
h_bins
,
s_bins
],
cv
.
CV_HIST_ARRAY
,
ranges
,
1
)
cv
.
CalcHist
([
cv
.
GetImage
(
i
)
for
i
in
planes
],
hist
)
(
_
,
max_value
,
_
,
_
)
=
cv
.
GetMinMaxHistValue
(
hist
)
hist_img
=
cv
.
CreateImage
((
h_bins
*
scale
,
s_bins
*
scale
),
8
,
3
)
for
h
in
range
(
h_bins
):
for
s
in
range
(
s_bins
):
bin_val
=
cv
.
QueryHistValue_2D
(
hist
,
h
,
s
)
intensity
=
cv
.
Round
(
bin_val
*
255
/
max_value
)
cv
.
Rectangle
(
hist_img
,
(
h
*
scale
,
s
*
scale
),
((
h
+
1
)
*
scale
-
1
,
(
s
+
1
)
*
scale
-
1
),
cv
.
RGB
(
intensity
,
intensity
,
intensity
),
cv
.
CV_FILLED
)
return
hist_img
def
precornerdetect
(
image
):
# assume that the image is floating-point
corners
=
cv
.
CloneMat
(
image
)
cv
.
PreCornerDetect
(
image
,
corners
,
3
)
dilated_corners
=
cv
.
CloneMat
(
image
)
cv
.
Dilate
(
corners
,
dilated_corners
,
None
,
1
)
corner_mask
=
cv
.
CreateMat
(
image
.
rows
,
image
.
cols
,
cv
.
CV_8UC1
)
cv
.
Sub
(
corners
,
dilated_corners
,
corners
)
cv
.
CmpS
(
corners
,
0
,
corner_mask
,
cv
.
CV_CMP_GE
)
return
(
corners
,
corner_mask
)
def
findstereocorrespondence
(
image_left
,
image_right
):
# image_left and image_right are the input 8-bit single-channel images
# from the left and the right cameras, respectively
(
r
,
c
)
=
(
image_left
.
rows
,
image_left
.
cols
)
disparity_left
=
cv
.
CreateMat
(
r
,
c
,
cv
.
CV_16S
)
disparity_right
=
cv
.
CreateMat
(
r
,
c
,
cv
.
CV_16S
)
state
=
cv
.
CreateStereoGCState
(
16
,
2
)
cv
.
FindStereoCorrespondenceGC
(
image_left
,
image_right
,
disparity_left
,
disparity_right
,
state
,
0
)
return
(
disparity_left
,
disparity_right
)
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