Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
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_contrib
Commits
2a32a5ad
Commit
2a32a5ad
authored
Mar 14, 2020
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2452 from r2d3:sl_python
parents
07bc8d6b
e967557e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
109 additions
and
8 deletions
+109
-8
histogramphaseunwrapping.hpp
...ude/opencv2/phase_unwrapping/histogramphaseunwrapping.hpp
+8
-7
pyopencv_phase_unwrapping.hpp
...hase_unwrapping/misc/python/pyopencv_phase_unwrapping.hpp
+3
-0
histogramphaseunwrapping.cpp
modules/phase_unwrapping/src/histogramphaseunwrapping.cpp
+3
-0
sinusoidalpattern.hpp
...ht/include/opencv2/structured_light/sinusoidalpattern.hpp
+1
-1
test_structured_light.py
...tructured_light/misc/python/test/test_structured_light.py
+94
-0
No files found.
modules/phase_unwrapping/include/opencv2/phase_unwrapping/histogramphaseunwrapping.hpp
View file @
2a32a5ad
...
...
@@ -75,20 +75,21 @@ public:
* @param nbrOfSmallBins Number of bins between 0 and "histThresh". Default value is 10.
* @param nbrOfLargeBins Number of bins between "histThresh" and 32*pi*pi (highest edge reliability value). Default value is 5.
*/
struct
CV_EXPORTS
Params
struct
CV_EXPORTS
_W_SIMPLE
Params
{
Params
();
int
width
;
int
height
;
float
histThresh
;
int
nbrOfSmallBins
;
int
nbrOfLargeBins
;
CV_WRAP
Params
();
CV_PROP_RW
int
width
;
CV_PROP_RW
int
height
;
CV_PROP_RW
float
histThresh
;
CV_PROP_RW
int
nbrOfSmallBins
;
CV_PROP_RW
int
nbrOfLargeBins
;
};
/**
* @brief Constructor
* @param parameters HistogramPhaseUnwrapping parameters HistogramPhaseUnwrapping::Params: width,height of the phase map and histogram characteristics.
*/
CV_WRAP
static
Ptr
<
HistogramPhaseUnwrapping
>
create
(
const
HistogramPhaseUnwrapping
::
Params
&
parameters
=
HistogramPhaseUnwrapping
::
Params
()
);
...
...
modules/phase_unwrapping/misc/python/pyopencv_phase_unwrapping.hpp
0 → 100644
View file @
2a32a5ad
#ifdef HAVE_OPENCV_PHASE_UNWRAPPING
typedef
cv
::
phase_unwrapping
::
HistogramPhaseUnwrapping
::
Params
HistogramPhaseUnwrapping_Params
;
#endif
modules/phase_unwrapping/src/histogramphaseunwrapping.cpp
View file @
2a32a5ad
...
...
@@ -712,7 +712,10 @@ void HistogramPhaseUnwrapping_Impl::addIncrement( OutputArray unwrappedPhaseMap
int
rows
=
params
.
height
;
int
cols
=
params
.
width
;
if
(
uPhaseMap
.
empty
()
)
{
uPhaseMap
.
create
(
rows
,
cols
,
CV_32FC1
);
uPhaseMap
=
Scalar
::
all
(
0
);
}
int
nbrOfPixels
=
static_cast
<
int
>
(
pixels
.
size
());
for
(
int
i
=
0
;
i
<
nbrOfPixels
;
++
i
)
{
...
...
modules/structured_light/include/opencv2/structured_light/sinusoidalpattern.hpp
View file @
2a32a5ad
...
...
@@ -119,7 +119,7 @@ public:
* @param shadowMask Mask used to discard shadow regions.
*/
CV_WRAP
virtual
void
unwrapPhaseMap
(
InputArray
OfArrays
wrappedPhaseMap
,
virtual
void
unwrapPhaseMap
(
InputArray
wrappedPhaseMap
,
OutputArray
unwrappedPhaseMap
,
cv
::
Size
camSize
,
InputArray
shadowMask
=
noArray
()
)
=
0
;
...
...
modules/structured_light/misc/python/test/test_structured_light.py
0 → 100644
View file @
2a32a5ad
#!/usr/bin/env python
# Python 2/3 compatibility
from
__future__
import
print_function
import
os
,
numpy
import
cv2
as
cv
from
tests_common
import
NewOpenCVTests
class
structured_light_test
(
NewOpenCVTests
):
def
test_unwrap
(
self
):
paramsPsp
=
cv
.
structured_light_SinusoidalPattern_Params
();
paramsFtp
=
cv
.
structured_light_SinusoidalPattern_Params
();
paramsFaps
=
cv
.
structured_light_SinusoidalPattern_Params
();
paramsPsp
.
methodId
=
cv
.
structured_light
.
PSP
;
paramsFtp
.
methodId
=
cv
.
structured_light
.
FTP
;
paramsFaps
.
methodId
=
cv
.
structured_light
.
FAPS
;
sinusPsp
=
cv
.
structured_light
.
SinusoidalPattern_create
(
paramsPsp
)
sinusFtp
=
cv
.
structured_light
.
SinusoidalPattern_create
(
paramsFtp
)
sinusFaps
=
cv
.
structured_light
.
SinusoidalPattern_create
(
paramsFaps
)
captures
=
[]
for
i
in
range
(
0
,
3
):
capture
=
self
.
get_sample
(
'/cv/structured_light/data/capture_sin_
%
d.jpg'
%
i
,
cv
.
IMREAD_GRAYSCALE
)
if
capture
is
None
:
raise
unittest
.
SkipTest
(
"Missing files with test data"
)
captures
.
append
(
capture
)
rows
,
cols
=
captures
[
0
]
.
shape
unwrappedPhaseMapPspRef
=
self
.
get_sample
(
'/cv/structured_light/data/unwrappedPspTest.jpg'
,
cv
.
IMREAD_GRAYSCALE
)
unwrappedPhaseMapFtpRef
=
self
.
get_sample
(
'/cv/structured_light/data/unwrappedFtpTest.jpg'
,
cv
.
IMREAD_GRAYSCALE
)
unwrappedPhaseMapFapsRef
=
self
.
get_sample
(
'/cv/structured_light/data/unwrappedFapsTest.jpg'
,
cv
.
IMREAD_GRAYSCALE
)
wrappedPhaseMap
,
shadowMask
=
sinusPsp
.
computePhaseMap
(
captures
);
unwrappedPhaseMap
=
sinusPsp
.
unwrapPhaseMap
(
wrappedPhaseMap
,
(
cols
,
rows
),
shadowMask
=
shadowMask
)
unwrappedPhaseMap8
=
unwrappedPhaseMap
*
1
+
128
unwrappedPhaseMap8
=
numpy
.
uint8
(
unwrappedPhaseMap8
)
sumOfDiff
=
0
count
=
0
for
i
in
range
(
rows
):
for
j
in
range
(
cols
):
ref
=
int
(
unwrappedPhaseMapPspRef
[
i
,
j
])
comp
=
int
(
unwrappedPhaseMap8
[
i
,
j
])
sumOfDiff
+=
(
ref
-
comp
)
count
+=
1
ratio
=
sumOfDiff
/
float
(
count
)
self
.
assertLessEqual
(
ratio
,
0.2
)
wrappedPhaseMap
,
shadowMask
=
sinusFtp
.
computePhaseMap
(
captures
);
unwrappedPhaseMap
=
sinusFtp
.
unwrapPhaseMap
(
wrappedPhaseMap
,
(
cols
,
rows
),
shadowMask
=
shadowMask
)
unwrappedPhaseMap8
=
unwrappedPhaseMap
*
1
+
128
unwrappedPhaseMap8
=
numpy
.
uint8
(
unwrappedPhaseMap8
)
sumOfDiff
=
0
count
=
0
for
i
in
range
(
rows
):
for
j
in
range
(
cols
):
ref
=
int
(
unwrappedPhaseMapFtpRef
[
i
,
j
])
comp
=
int
(
unwrappedPhaseMap8
[
i
,
j
])
sumOfDiff
+=
(
ref
-
comp
)
count
+=
1
ratio
=
sumOfDiff
/
float
(
count
)
self
.
assertLessEqual
(
ratio
,
0.2
)
wrappedPhaseMap
,
shadowMask2
=
sinusFaps
.
computePhaseMap
(
captures
);
unwrappedPhaseMap
=
sinusFaps
.
unwrapPhaseMap
(
wrappedPhaseMap
,
(
cols
,
rows
),
shadowMask
=
shadowMask
)
unwrappedPhaseMap8
=
unwrappedPhaseMap
*
1
+
128
unwrappedPhaseMap8
=
numpy
.
uint8
(
unwrappedPhaseMap8
)
sumOfDiff
=
0
count
=
0
for
i
in
range
(
rows
):
for
j
in
range
(
cols
):
ref
=
int
(
unwrappedPhaseMapFapsRef
[
i
,
j
])
comp
=
int
(
unwrappedPhaseMap8
[
i
,
j
])
sumOfDiff
+=
(
ref
-
comp
)
count
+=
1
ratio
=
sumOfDiff
/
float
(
count
)
self
.
assertLessEqual
(
ratio
,
0.2
)
if
__name__
==
'__main__'
:
NewOpenCVTests
.
bootstrap
()
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