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
6211920c
Commit
6211920c
authored
Feb 07, 2017
by
Vladislav Sovrasov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reg: enable wrappers for all methods
parent
51464723
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
26 deletions
+51
-26
mapper.hpp
modules/reg/include/opencv2/reg/mapper.hpp
+3
-3
mapperpyramid.hpp
modules/reg/include/opencv2/reg/mapperpyramid.hpp
+30
-3
mapshift.hpp
modules/reg/include/opencv2/reg/mapshift.hpp
+2
-1
mapperpyramid.cpp
modules/reg/src/mapperpyramid.cpp
+3
-3
mapshift.cpp
modules/reg/src/mapshift.cpp
+3
-1
test_reg.cpp
modules/reg/test/test_reg.cpp
+10
-15
No files found.
modules/reg/include/opencv2/reg/mapper.hpp
View file @
6211920c
...
...
@@ -47,7 +47,7 @@ namespace reg {
//! @addtogroup reg
//! @{
/** @brief Base class for modelling an algorithm for calculating a
/** @brief Base class for modelling an algorithm for calculating a
map
The class is only used to define the common interface for any possible mapping algorithm.
*/
...
...
@@ -60,8 +60,8 @@ public:
* Calculate mapping between two images
* \param[in] img1 Reference image
* \param[in] img2 Warped image
* \param[in
,out] res Map from img1 to img2, stored in a smart pointer. If present as input,
*
it is an initial rough estimation that the mapper will try to refine
.
* \param[in
] If present, it is an initial rough estimation that the mapper will try to refine.
*
\return Map from img1 to img2, stored in a smart pointer
.
*/
CV_WRAP
virtual
cv
::
Ptr
<
Map
>
calculate
(
InputArray
img1
,
InputArray
img2
,
cv
::
Ptr
<
Map
>
init
=
cv
::
Ptr
<
Map
>
())
const
=
0
;
...
...
modules/reg/include/opencv2/reg/mapperpyramid.hpp
View file @
6211920c
...
...
@@ -39,7 +39,9 @@
#define MAPPERPYRAMID_H_
#include "mapper.hpp"
#include "mapaffine.hpp"
#include "mapprojec.hpp"
#include "mapshift.hpp"
namespace
cv
{
namespace
reg
{
...
...
@@ -63,14 +65,39 @@ public:
CV_WRAP
cv
::
Ptr
<
Map
>
getMap
()
const
;
CV_
WRAP
unsigned
numLev_
;
/*!< Number of levels of the pyramid */
CV_
WRAP
unsigned
numIterPerScale_
;
/*!< Number of iterations at a given scale of the pyramid */
CV_
PROP_RW
int
numLev_
;
/*!< Number of levels of the pyramid */
CV_
PROP_RW
int
numIterPerScale_
;
/*!< Number of iterations at a given scale of the pyramid */
private
:
MapperPyramid
&
operator
=
(
const
MapperPyramid
&
);
const
Mapper
&
baseMapper_
;
/*!< Mapper used in inner level */
};
/*!
* Converts a pointer to a Map returned by MapperPyramid::calculate into the specified Map pointer type
*/
class
CV_EXPORTS_W
MapTypeCaster
{
public
:
CV_WRAP
static
Ptr
<
MapAffine
>
toAffine
(
Ptr
<
Map
>
sourceMap
)
{
MapAffine
&
affineMap
=
dynamic_cast
<
MapAffine
&>
(
*
sourceMap
);
return
Ptr
<
MapAffine
>
(
new
MapAffine
(
affineMap
));
}
CV_WRAP
static
Ptr
<
MapShift
>
toShift
(
Ptr
<
Map
>
sourceMap
)
{
MapShift
&
shiftMap
=
dynamic_cast
<
MapShift
&>
(
*
sourceMap
);
return
Ptr
<
MapShift
>
(
new
MapShift
(
shiftMap
));
}
CV_WRAP
static
Ptr
<
MapProjec
>
toProjec
(
Ptr
<
Map
>
sourceMap
)
{
MapProjec
&
projecMap
=
dynamic_cast
<
MapProjec
&>
(
*
sourceMap
);
return
Ptr
<
MapProjec
>
(
new
MapProjec
(
projecMap
));
}
};
//! @}
}}
// namespace cv::reg
...
...
modules/reg/include/opencv2/reg/mapshift.hpp
View file @
6211920c
...
...
@@ -62,7 +62,8 @@ public:
* Constructor providing explicit values
* \param[in] shift Displacement
*/
MapShift
(
const
cv
::
Vec
<
double
,
2
>&
shift
);
CV_WRAP
MapShift
(
InputArray
shift
);
/*!
* Destructor
...
...
modules/reg/src/mapperpyramid.cpp
View file @
6211920c
...
...
@@ -73,20 +73,20 @@ Ptr<Map> MapperPyramid::calculate(InputArray _img1, InputArray image2, Ptr<Map>
vector
<
Mat
>
pyrIm1
(
numLev_
),
pyrIm2
(
numLev_
);
pyrIm1
[
0
]
=
img1
;
pyrIm2
[
0
]
=
img2
;
for
(
size_
t
im_i
=
1
;
im_i
<
numLev_
;
++
im_i
)
{
for
(
in
t
im_i
=
1
;
im_i
<
numLev_
;
++
im_i
)
{
pyrDown
(
pyrIm1
[
im_i
-
1
],
pyrIm1
[
im_i
]);
pyrDown
(
pyrIm2
[
im_i
-
1
],
pyrIm2
[
im_i
]);
}
Mat
currRef
,
currImg
;
for
(
size_
t
lv_i
=
0
;
lv_i
<
numLev_
;
++
lv_i
)
{
for
(
in
t
lv_i
=
0
;
lv_i
<
numLev_
;
++
lv_i
)
{
currRef
=
pyrIm1
[
numLev_
-
1
-
lv_i
];
currImg
=
pyrIm2
[
numLev_
-
1
-
lv_i
];
// Scale the transformation as we are incresing the resolution in each iteration
if
(
lv_i
!=
0
)
{
ident
->
scale
(
2.
);
}
for
(
size_
t
it_i
=
0
;
it_i
<
numIterPerScale_
;
++
it_i
)
{
for
(
in
t
it_i
=
0
;
it_i
<
numIterPerScale_
;
++
it_i
)
{
ident
=
baseMapper_
.
calculate
(
currRef
,
currImg
,
ident
);
}
}
...
...
modules/reg/src/mapshift.cpp
View file @
6211920c
...
...
@@ -51,8 +51,10 @@ MapShift::MapShift() : shift_()
}
////////////////////////////////////////////////////////////////////////////////////////////////////
MapShift
::
MapShift
(
const
Vec
<
double
,
2
>&
shift
)
:
shift_
(
shift
)
MapShift
::
MapShift
(
InputArray
shift
)
{
Mat
shiftMat
=
shift
.
getMat
();
shiftMat
.
copyTo
(
shift_
);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
...
...
modules/reg/test/test_reg.cpp
View file @
6211920c
...
...
@@ -88,11 +88,10 @@ void RegTest::testShift()
// Register
Ptr
<
Mapper
>
mapper
=
makePtr
<
MapperGradShift
>
();
MapperPyramid
mappPyr
(
mapper
);
Ptr
<
Map
>
mapPtr
;
mapPtr
=
mappPyr
.
calculate
(
img1
,
img2
,
mapPtr
);
Ptr
<
Map
>
mapPtr
=
mappPyr
.
calculate
(
img1
,
img2
);
// Print result
MapShift
*
mapShift
=
dynamic_cast
<
MapShift
*>
(
mapPtr
.
get
()
);
Ptr
<
MapShift
>
mapShift
=
MapTypeCaster
::
toShift
(
mapPtr
);
#if REG_DEBUG_OUTPUT
cout
<<
endl
<<
"--- Testing shift mapper ---"
<<
endl
;
cout
<<
Mat
(
shift
)
<<
endl
;
...
...
@@ -121,11 +120,10 @@ void RegTest::testEuclidean()
// Register
Ptr
<
Mapper
>
mapper
=
makePtr
<
MapperGradEuclid
>
();
MapperPyramid
mappPyr
(
mapper
);
Ptr
<
Map
>
mapPtr
;
mapPtr
=
mappPyr
.
calculate
(
img1
,
img2
,
mapPtr
);
Ptr
<
Map
>
mapPtr
=
mappPyr
.
calculate
(
img1
,
img2
);
// Print result
MapAffine
*
mapAff
=
dynamic_cast
<
MapAffine
*>
(
mapPtr
.
get
()
);
Ptr
<
MapAffine
>
mapAff
=
MapTypeCaster
::
toAffine
(
mapPtr
);
#if REG_DEBUG_OUTPUT
cout
<<
endl
<<
"--- Testing Euclidean mapper ---"
<<
endl
;
cout
<<
Mat
(
linTr
)
<<
endl
;
...
...
@@ -160,11 +158,10 @@ void RegTest::testSimilarity()
// Register
Ptr
<
Mapper
>
mapper
=
makePtr
<
MapperGradSimilar
>
();
MapperPyramid
mappPyr
(
mapper
);
Ptr
<
Map
>
mapPtr
;
mapPtr
=
mappPyr
.
calculate
(
img1
,
img2
,
mapPtr
);
Ptr
<
Map
>
mapPtr
=
mappPyr
.
calculate
(
img1
,
img2
);
// Print result
MapAffine
*
mapAff
=
dynamic_cast
<
MapAffine
*>
(
mapPtr
.
get
()
);
Ptr
<
MapAffine
>
mapAff
=
MapTypeCaster
::
toAffine
(
mapPtr
);
#if REG_DEBUG_OUTPUT
cout
<<
endl
<<
"--- Testing similarity mapper ---"
<<
endl
;
cout
<<
Mat
(
linTr
)
<<
endl
;
...
...
@@ -196,11 +193,10 @@ void RegTest::testAffine()
// Register
Ptr
<
Mapper
>
mapper
=
makePtr
<
MapperGradAffine
>
();
MapperPyramid
mappPyr
(
mapper
);
Ptr
<
Map
>
mapPtr
;
mapPtr
=
mappPyr
.
calculate
(
img1
,
img2
,
mapPtr
);
Ptr
<
Map
>
mapPtr
=
mappPyr
.
calculate
(
img1
,
img2
);
// Print result
MapAffine
*
mapAff
=
dynamic_cast
<
MapAffine
*>
(
mapPtr
.
get
()
);
Ptr
<
MapAffine
>
mapAff
=
MapTypeCaster
::
toAffine
(
mapPtr
);
#if REG_DEBUG_OUTPUT
cout
<<
endl
<<
"--- Testing affine mapper ---"
<<
endl
;
cout
<<
Mat
(
linTr
)
<<
endl
;
...
...
@@ -232,11 +228,10 @@ void RegTest::testProjective()
// Register
Ptr
<
Mapper
>
mapper
=
makePtr
<
MapperGradProj
>
();
MapperPyramid
mappPyr
(
mapper
);
Ptr
<
Map
>
mapPtr
;
mapPtr
=
mappPyr
.
calculate
(
img1
,
img2
,
mapPtr
);
Ptr
<
Map
>
mapPtr
=
mappPyr
.
calculate
(
img1
,
img2
);
// Print result
MapProjec
*
mapProj
=
dynamic_cast
<
MapProjec
*>
(
mapPtr
.
get
()
);
Ptr
<
MapProjec
>
mapProj
=
MapTypeCaster
::
toProjec
(
mapPtr
);
mapProj
->
normalize
();
#if REG_DEBUG_OUTPUT
cout
<<
endl
<<
"--- Testing projective transformation mapper ---"
<<
endl
;
...
...
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