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
51464723
Commit
51464723
authored
Feb 06, 2017
by
Vladislav Sovrasov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reg: enable wrapping for all significant methods
parent
97dab3b5
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
93 additions
and
61 deletions
+93
-61
mapaffine.hpp
modules/reg/include/opencv2/reg/mapaffine.hpp
+8
-0
mapper.hpp
modules/reg/include/opencv2/reg/mapper.hpp
+1
-1
mappergradaffine.hpp
modules/reg/include/opencv2/reg/mappergradaffine.hpp
+1
-1
mappergradeuclid.hpp
modules/reg/include/opencv2/reg/mappergradeuclid.hpp
+1
-1
mappergradproj.hpp
modules/reg/include/opencv2/reg/mappergradproj.hpp
+1
-1
mappergradshift.hpp
modules/reg/include/opencv2/reg/mappergradshift.hpp
+1
-1
mappergradsimilar.hpp
modules/reg/include/opencv2/reg/mappergradsimilar.hpp
+1
-1
mapperpyramid.hpp
modules/reg/include/opencv2/reg/mapperpyramid.hpp
+2
-2
mapprojec.hpp
modules/reg/include/opencv2/reg/mapprojec.hpp
+5
-1
mapshift.hpp
modules/reg/include/opencv2/reg/mapshift.hpp
+4
-0
mappergradaffine.cpp
modules/reg/src/mappergradaffine.cpp
+9
-6
mappergradeuclid.cpp
modules/reg/src/mappergradeuclid.cpp
+10
-7
mappergradproj.cpp
modules/reg/src/mappergradproj.cpp
+10
-7
mappergradshift.cpp
modules/reg/src/mappergradshift.cpp
+10
-7
mappergradsimilar.cpp
modules/reg/src/mappergradsimilar.cpp
+10
-7
mapperpyramid.cpp
modules/reg/src/mapperpyramid.cpp
+9
-8
test_reg.cpp
modules/reg/test/test_reg.cpp
+10
-10
No files found.
modules/reg/include/opencv2/reg/mapaffine.hpp
View file @
51464723
...
@@ -85,6 +85,10 @@ public:
...
@@ -85,6 +85,10 @@ public:
return
linTr_
;
return
linTr_
;
}
}
CV_WRAP
void
getLinTr
(
OutputArray
linTr
)
const
{
Mat
(
linTr_
).
copyTo
(
linTr
);
}
/*!
/*!
* Return displacement part of the affine transformation
* Return displacement part of the affine transformation
* \return Displacement part of the affine transformation
* \return Displacement part of the affine transformation
...
@@ -93,6 +97,10 @@ public:
...
@@ -93,6 +97,10 @@ public:
return
shift_
;
return
shift_
;
}
}
CV_WRAP
void
getShift
(
OutputArray
shift
)
const
{
Mat
(
shift_
).
copyTo
(
shift
);
}
private
:
private
:
cv
::
Matx
<
double
,
2
,
2
>
linTr_
;
cv
::
Matx
<
double
,
2
,
2
>
linTr_
;
cv
::
Vec
<
double
,
2
>
shift_
;
cv
::
Vec
<
double
,
2
>
shift_
;
...
...
modules/reg/include/opencv2/reg/mapper.hpp
View file @
51464723
...
@@ -63,7 +63,7 @@ public:
...
@@ -63,7 +63,7 @@ public:
* \param[in,out] res Map from img1 to img2, stored in a smart pointer. If present as input,
* \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.
* it is an initial rough estimation that the mapper will try to refine.
*/
*/
virtual
void
calculate
(
InputArray
img1
,
InputArray
img2
,
cv
::
Ptr
<
Map
>&
res
)
const
=
0
;
CV_WRAP
virtual
cv
::
Ptr
<
Map
>
calculate
(
InputArray
img1
,
InputArray
img2
,
cv
::
Ptr
<
Map
>
init
=
cv
::
Ptr
<
Map
>
()
)
const
=
0
;
/*
/*
* Returns a map compatible with the Mapper class
* Returns a map compatible with the Mapper class
...
...
modules/reg/include/opencv2/reg/mappergradaffine.hpp
View file @
51464723
...
@@ -55,7 +55,7 @@ public:
...
@@ -55,7 +55,7 @@ public:
CV_WRAP
MapperGradAffine
();
CV_WRAP
MapperGradAffine
();
~
MapperGradAffine
(
void
);
~
MapperGradAffine
(
void
);
virtual
void
calculate
(
InputArray
img1
,
InputArray
img2
,
cv
::
Ptr
<
Map
>&
res
)
const
;
CV_WRAP
virtual
cv
::
Ptr
<
Map
>
calculate
(
InputArray
img1
,
InputArray
img2
,
cv
::
Ptr
<
Map
>
init
=
cv
::
Ptr
<
Map
>
()
)
const
;
CV_WRAP
cv
::
Ptr
<
Map
>
getMap
()
const
;
CV_WRAP
cv
::
Ptr
<
Map
>
getMap
()
const
;
};
};
...
...
modules/reg/include/opencv2/reg/mappergradeuclid.hpp
View file @
51464723
...
@@ -55,7 +55,7 @@ public:
...
@@ -55,7 +55,7 @@ public:
CV_WRAP
MapperGradEuclid
();
CV_WRAP
MapperGradEuclid
();
~
MapperGradEuclid
();
~
MapperGradEuclid
();
virtual
void
calculate
(
InputArray
img1
,
InputArray
img2
,
cv
::
Ptr
<
Map
>&
res
)
const
;
CV_WRAP
virtual
cv
::
Ptr
<
Map
>
calculate
(
InputArray
img1
,
InputArray
img2
,
cv
::
Ptr
<
Map
>
init
=
cv
::
Ptr
<
Map
>
()
)
const
;
CV_WRAP
cv
::
Ptr
<
Map
>
getMap
()
const
;
CV_WRAP
cv
::
Ptr
<
Map
>
getMap
()
const
;
};
};
...
...
modules/reg/include/opencv2/reg/mappergradproj.hpp
View file @
51464723
...
@@ -55,7 +55,7 @@ public:
...
@@ -55,7 +55,7 @@ public:
CV_WRAP
MapperGradProj
();
CV_WRAP
MapperGradProj
();
~
MapperGradProj
();
~
MapperGradProj
();
virtual
void
calculate
(
InputArray
img1
,
InputArray
img2
,
cv
::
Ptr
<
Map
>&
res
)
const
;
CV_WRAP
virtual
cv
::
Ptr
<
Map
>
calculate
(
InputArray
img1
,
InputArray
img2
,
cv
::
Ptr
<
Map
>
init
=
cv
::
Ptr
<
Map
>
()
)
const
;
CV_WRAP
cv
::
Ptr
<
Map
>
getMap
()
const
;
CV_WRAP
cv
::
Ptr
<
Map
>
getMap
()
const
;
};
};
...
...
modules/reg/include/opencv2/reg/mappergradshift.hpp
View file @
51464723
...
@@ -55,7 +55,7 @@ public:
...
@@ -55,7 +55,7 @@ public:
CV_WRAP
MapperGradShift
();
CV_WRAP
MapperGradShift
();
virtual
~
MapperGradShift
();
virtual
~
MapperGradShift
();
virtual
void
calculate
(
InputArray
img1
,
InputArray
img2
,
cv
::
Ptr
<
Map
>&
res
)
const
;
CV_WRAP
virtual
cv
::
Ptr
<
Map
>
calculate
(
InputArray
img1
,
InputArray
img2
,
cv
::
Ptr
<
Map
>
init
=
cv
::
Ptr
<
Map
>
()
)
const
;
CV_WRAP
cv
::
Ptr
<
Map
>
getMap
()
const
;
CV_WRAP
cv
::
Ptr
<
Map
>
getMap
()
const
;
};
};
...
...
modules/reg/include/opencv2/reg/mappergradsimilar.hpp
View file @
51464723
...
@@ -55,7 +55,7 @@ public:
...
@@ -55,7 +55,7 @@ public:
CV_WRAP
MapperGradSimilar
();
CV_WRAP
MapperGradSimilar
();
~
MapperGradSimilar
();
~
MapperGradSimilar
();
virtual
void
calculate
(
InputArray
img1
,
InputArray
img2
,
cv
::
Ptr
<
Map
>&
res
)
const
;
CV_WRAP
virtual
cv
::
Ptr
<
Map
>
calculate
(
InputArray
img1
,
InputArray
img2
,
cv
::
Ptr
<
Map
>
init
=
cv
::
Ptr
<
Map
>
()
)
const
;
CV_WRAP
cv
::
Ptr
<
Map
>
getMap
()
const
;
CV_WRAP
cv
::
Ptr
<
Map
>
getMap
()
const
;
};
};
...
...
modules/reg/include/opencv2/reg/mapperpyramid.hpp
View file @
51464723
...
@@ -57,9 +57,9 @@ public:
...
@@ -57,9 +57,9 @@ public:
* Constructor
* Constructor
* \param[in] baseMapper Base mapper used for the refinements
* \param[in] baseMapper Base mapper used for the refinements
*/
*/
MapperPyramid
(
const
Mapper
&
baseMapper
);
CV_WRAP
MapperPyramid
(
Ptr
<
Mapper
>
baseMapper
);
void
calculate
(
InputArray
img1
,
InputArray
img2
,
cv
::
Ptr
<
Map
>&
res
)
const
;
CV_WRAP
virtual
cv
::
Ptr
<
Map
>
calculate
(
InputArray
img1
,
InputArray
img2
,
cv
::
Ptr
<
Map
>
init
=
cv
::
Ptr
<
Map
>
()
)
const
;
CV_WRAP
cv
::
Ptr
<
Map
>
getMap
()
const
;
CV_WRAP
cv
::
Ptr
<
Map
>
getMap
()
const
;
...
...
modules/reg/include/opencv2/reg/mapprojec.hpp
View file @
51464723
...
@@ -85,10 +85,14 @@ public:
...
@@ -85,10 +85,14 @@ public:
return
projTr_
;
return
projTr_
;
}
}
CV_WRAP
void
getProjTr
(
OutputArray
projTr
)
const
{
Mat
(
projTr_
).
copyTo
(
projTr
);
}
/*!
/*!
* Normalizes object's homography
* Normalizes object's homography
*/
*/
void
normalize
(
void
)
{
CV_WRAP
void
normalize
(
)
{
double
z
=
1.
/
projTr_
(
2
,
2
);
double
z
=
1.
/
projTr_
(
2
,
2
);
for
(
size_t
v_i
=
0
;
v_i
<
sizeof
(
projTr_
.
val
)
/
sizeof
(
projTr_
.
val
[
0
]);
++
v_i
)
for
(
size_t
v_i
=
0
;
v_i
<
sizeof
(
projTr_
.
val
)
/
sizeof
(
projTr_
.
val
[
0
]);
++
v_i
)
projTr_
.
val
[
v_i
]
*=
z
;
projTr_
.
val
[
v_i
]
*=
z
;
...
...
modules/reg/include/opencv2/reg/mapshift.hpp
View file @
51464723
...
@@ -85,6 +85,10 @@ public:
...
@@ -85,6 +85,10 @@ public:
return
shift_
;
return
shift_
;
}
}
CV_WRAP
void
getShift
(
OutputArray
shift
)
const
{
Mat
(
shift_
).
copyTo
(
shift
);
}
private
:
private
:
cv
::
Vec
<
double
,
2
>
shift_
;
/*< Displacement */
cv
::
Vec
<
double
,
2
>
shift_
;
/*< Displacement */
};
};
...
...
modules/reg/src/mappergradaffine.cpp
View file @
51464723
...
@@ -56,7 +56,7 @@ MapperGradAffine::~MapperGradAffine()
...
@@ -56,7 +56,7 @@ MapperGradAffine::~MapperGradAffine()
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
void
MapperGradAffine
::
calculate
(
InputArray
_img1
,
InputArray
image2
,
cv
::
Ptr
<
Map
>&
res
)
const
cv
::
Ptr
<
Map
>
MapperGradAffine
::
calculate
(
InputArray
_img1
,
InputArray
image2
,
cv
::
Ptr
<
Map
>
init
)
const
{
{
Mat
img1
=
_img1
.
getMat
();
Mat
img1
=
_img1
.
getMat
();
Mat
gradx
,
grady
,
imgDiff
;
Mat
gradx
,
grady
,
imgDiff
;
...
@@ -66,9 +66,9 @@ void MapperGradAffine::calculate(InputArray _img1, InputArray image2, cv::Ptr<Ma
...
@@ -66,9 +66,9 @@ void MapperGradAffine::calculate(InputArray _img1, InputArray image2, cv::Ptr<Ma
CV_DbgAssert
(
img1
.
channels
()
==
image2
.
channels
());
CV_DbgAssert
(
img1
.
channels
()
==
image2
.
channels
());
CV_DbgAssert
(
img1
.
channels
()
==
1
||
img1
.
channels
()
==
3
);
CV_DbgAssert
(
img1
.
channels
()
==
1
||
img1
.
channels
()
==
3
);
if
(
!
res
.
empty
())
{
if
(
!
init
.
empty
())
{
// We have initial values for the registration: we move img2 to that initial reference
// We have initial values for the registration: we move img2 to that initial reference
res
->
inverseWarp
(
image2
,
img2
);
init
->
inverseWarp
(
image2
,
img2
);
}
else
{
}
else
{
img2
=
image2
.
getMat
();
img2
=
image2
.
getMat
();
}
}
...
@@ -145,11 +145,14 @@ void MapperGradAffine::calculate(InputArray _img1, InputArray image2, cv::Ptr<Ma
...
@@ -145,11 +145,14 @@ void MapperGradAffine::calculate(InputArray _img1, InputArray image2, cv::Ptr<Ma
Matx
<
double
,
2
,
2
>
linTr
(
k
(
0
)
+
1.
,
k
(
1
),
k
(
3
),
k
(
4
)
+
1.
);
Matx
<
double
,
2
,
2
>
linTr
(
k
(
0
)
+
1.
,
k
(
1
),
k
(
3
),
k
(
4
)
+
1.
);
Vec
<
double
,
2
>
shift
(
k
(
2
),
k
(
5
));
Vec
<
double
,
2
>
shift
(
k
(
2
),
k
(
5
));
if
(
res
.
empty
())
{
if
(
init
.
empty
())
{
re
s
=
Ptr
<
Map
>
(
new
MapAffine
(
linTr
,
shift
));
re
turn
Ptr
<
Map
>
(
new
MapAffine
(
linTr
,
shift
));
}
else
{
}
else
{
Ptr
<
MapAffine
>
newTr
(
new
MapAffine
(
linTr
,
shift
));
Ptr
<
MapAffine
>
newTr
(
new
MapAffine
(
linTr
,
shift
));
res
->
compose
(
newTr
);
MapAffine
*
initPtr
=
dynamic_cast
<
MapAffine
*>
(
init
.
get
());
Ptr
<
MapAffine
>
oldTr
(
new
MapAffine
(
initPtr
->
getLinTr
(),
initPtr
->
getShift
()));
oldTr
->
compose
(
newTr
);
return
oldTr
;
}
}
}
}
...
...
modules/reg/src/mappergradeuclid.cpp
View file @
51464723
...
@@ -56,8 +56,8 @@ MapperGradEuclid::~MapperGradEuclid()
...
@@ -56,8 +56,8 @@ MapperGradEuclid::~MapperGradEuclid()
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
void
MapperGradEuclid
::
calculate
(
cv
::
Ptr
<
Map
>
MapperGradEuclid
::
calculate
(
InputArray
_img1
,
InputArray
image2
,
cv
::
Ptr
<
Map
>
&
res
)
const
InputArray
_img1
,
InputArray
image2
,
cv
::
Ptr
<
Map
>
init
)
const
{
{
Mat
img1
=
_img1
.
getMat
();
Mat
img1
=
_img1
.
getMat
();
Mat
gradx
,
grady
,
imgDiff
;
Mat
gradx
,
grady
,
imgDiff
;
...
@@ -67,9 +67,9 @@ void MapperGradEuclid::calculate(
...
@@ -67,9 +67,9 @@ void MapperGradEuclid::calculate(
CV_DbgAssert
(
img1
.
channels
()
==
image2
.
channels
());
CV_DbgAssert
(
img1
.
channels
()
==
image2
.
channels
());
CV_DbgAssert
(
img1
.
channels
()
==
1
||
img1
.
channels
()
==
3
);
CV_DbgAssert
(
img1
.
channels
()
==
1
||
img1
.
channels
()
==
3
);
if
(
!
res
.
empty
())
{
if
(
!
init
.
empty
())
{
// We have initial values for the registration: we move img2 to that initial reference
// We have initial values for the registration: we move img2 to that initial reference
res
->
inverseWarp
(
image2
,
img2
);
init
->
inverseWarp
(
image2
,
img2
);
}
else
{
}
else
{
img2
=
image2
.
getMat
();
img2
=
image2
.
getMat
();
}
}
...
@@ -112,11 +112,14 @@ void MapperGradEuclid::calculate(
...
@@ -112,11 +112,14 @@ void MapperGradEuclid::calculate(
Matx
<
double
,
2
,
2
>
linTr
(
cosT
,
-
sinT
,
sinT
,
cosT
);
Matx
<
double
,
2
,
2
>
linTr
(
cosT
,
-
sinT
,
sinT
,
cosT
);
Vec
<
double
,
2
>
shift
(
k
(
0
),
k
(
1
));
Vec
<
double
,
2
>
shift
(
k
(
0
),
k
(
1
));
if
(
res
.
empty
())
{
if
(
init
.
empty
())
{
re
s
=
Ptr
<
Map
>
(
new
MapAffine
(
linTr
,
shift
));
re
turn
Ptr
<
Map
>
(
new
MapAffine
(
linTr
,
shift
));
}
else
{
}
else
{
Ptr
<
MapAffine
>
newTr
(
new
MapAffine
(
linTr
,
shift
));
Ptr
<
MapAffine
>
newTr
(
new
MapAffine
(
linTr
,
shift
));
res
->
compose
(
newTr
);
MapAffine
*
initPtr
=
dynamic_cast
<
MapAffine
*>
(
init
.
get
());
Ptr
<
MapAffine
>
oldTr
(
new
MapAffine
(
initPtr
->
getLinTr
(),
initPtr
->
getShift
()));
oldTr
->
compose
(
newTr
);
return
oldTr
;
}
}
}
}
...
...
modules/reg/src/mappergradproj.cpp
View file @
51464723
...
@@ -56,8 +56,8 @@ MapperGradProj::~MapperGradProj()
...
@@ -56,8 +56,8 @@ MapperGradProj::~MapperGradProj()
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
void
MapperGradProj
::
calculate
(
cv
::
Ptr
<
Map
>
MapperGradProj
::
calculate
(
InputArray
_img1
,
InputArray
image2
,
cv
::
Ptr
<
Map
>
&
res
)
const
InputArray
_img1
,
InputArray
image2
,
cv
::
Ptr
<
Map
>
init
)
const
{
{
Mat
img1
=
_img1
.
getMat
();
Mat
img1
=
_img1
.
getMat
();
Mat
gradx
,
grady
,
imgDiff
;
Mat
gradx
,
grady
,
imgDiff
;
...
@@ -67,9 +67,9 @@ void MapperGradProj::calculate(
...
@@ -67,9 +67,9 @@ void MapperGradProj::calculate(
CV_DbgAssert
(
img1
.
channels
()
==
image2
.
channels
());
CV_DbgAssert
(
img1
.
channels
()
==
image2
.
channels
());
CV_DbgAssert
(
img1
.
channels
()
==
1
||
img1
.
channels
()
==
3
);
CV_DbgAssert
(
img1
.
channels
()
==
1
||
img1
.
channels
()
==
3
);
if
(
!
res
.
empty
())
{
if
(
!
init
.
empty
())
{
// We have initial values for the registration: we move img2 to that initial reference
// We have initial values for the registration: we move img2 to that initial reference
res
->
inverseWarp
(
image2
,
img2
);
init
->
inverseWarp
(
image2
,
img2
);
}
else
{
}
else
{
img2
=
image2
.
getMat
();
img2
=
image2
.
getMat
();
}
}
...
@@ -196,11 +196,14 @@ void MapperGradProj::calculate(
...
@@ -196,11 +196,14 @@ void MapperGradProj::calculate(
Vec
<
double
,
8
>
k
=
A
.
inv
(
DECOMP_CHOLESKY
)
*
b
;
Vec
<
double
,
8
>
k
=
A
.
inv
(
DECOMP_CHOLESKY
)
*
b
;
Matx
<
double
,
3
,
3
>
H
(
k
(
0
)
+
1.
,
k
(
1
),
k
(
2
),
k
(
3
),
k
(
4
)
+
1.
,
k
(
5
),
k
(
6
),
k
(
7
),
1.
);
Matx
<
double
,
3
,
3
>
H
(
k
(
0
)
+
1.
,
k
(
1
),
k
(
2
),
k
(
3
),
k
(
4
)
+
1.
,
k
(
5
),
k
(
6
),
k
(
7
),
1.
);
if
(
res
.
empty
())
{
if
(
init
.
empty
())
{
re
s
=
Ptr
<
Map
>
(
new
MapProjec
(
H
));
re
turn
Ptr
<
Map
>
(
new
MapProjec
(
H
));
}
else
{
}
else
{
Ptr
<
MapProjec
>
newTr
(
new
MapProjec
(
H
));
Ptr
<
MapProjec
>
newTr
(
new
MapProjec
(
H
));
res
->
compose
(
newTr
);
MapProjec
*
initPtr
=
dynamic_cast
<
MapProjec
*>
(
init
.
get
());
Ptr
<
MapProjec
>
oldTr
(
new
MapProjec
(
initPtr
->
getProjTr
()));
oldTr
->
compose
(
newTr
);
return
oldTr
;
}
}
}
}
...
...
modules/reg/src/mappergradshift.cpp
View file @
51464723
...
@@ -56,8 +56,8 @@ MapperGradShift::~MapperGradShift()
...
@@ -56,8 +56,8 @@ MapperGradShift::~MapperGradShift()
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
void
MapperGradShift
::
calculate
(
cv
::
Ptr
<
Map
>
MapperGradShift
::
calculate
(
InputArray
_img1
,
InputArray
image2
,
cv
::
Ptr
<
Map
>
&
res
)
const
InputArray
_img1
,
InputArray
image2
,
cv
::
Ptr
<
Map
>
init
)
const
{
{
Mat
img1
=
_img1
.
getMat
();
Mat
img1
=
_img1
.
getMat
();
Mat
gradx
,
grady
,
imgDiff
;
Mat
gradx
,
grady
,
imgDiff
;
...
@@ -65,9 +65,9 @@ void MapperGradShift::calculate(
...
@@ -65,9 +65,9 @@ void MapperGradShift::calculate(
CV_DbgAssert
(
img1
.
size
()
==
image2
.
size
());
CV_DbgAssert
(
img1
.
size
()
==
image2
.
size
());
if
(
!
res
.
empty
())
{
if
(
!
init
.
empty
())
{
// We have initial values for the registration: we move img2 to that initial reference
// We have initial values for the registration: we move img2 to that initial reference
res
->
inverseWarp
(
image2
,
img2
);
init
->
inverseWarp
(
image2
,
img2
);
}
else
{
}
else
{
img2
=
image2
.
getMat
();
img2
=
image2
.
getMat
();
}
}
...
@@ -93,11 +93,14 @@ void MapperGradShift::calculate(
...
@@ -93,11 +93,14 @@ void MapperGradShift::calculate(
// Calculate shift. We use Cholesky decomposition, as A is symmetric.
// Calculate shift. We use Cholesky decomposition, as A is symmetric.
Vec
<
double
,
2
>
shift
=
A
.
inv
(
DECOMP_CHOLESKY
)
*
b
;
Vec
<
double
,
2
>
shift
=
A
.
inv
(
DECOMP_CHOLESKY
)
*
b
;
if
(
res
.
empty
())
{
if
(
init
.
empty
())
{
re
s
=
Ptr
<
Map
>
(
new
MapShift
(
shift
));
re
turn
Ptr
<
Map
>
(
new
MapShift
(
shift
));
}
else
{
}
else
{
Ptr
<
MapShift
>
newTr
(
new
MapShift
(
shift
));
Ptr
<
MapShift
>
newTr
(
new
MapShift
(
shift
));
res
->
compose
(
newTr
);
MapShift
*
initPtr
=
dynamic_cast
<
MapShift
*>
(
init
.
get
());
Ptr
<
MapShift
>
oldTr
(
new
MapShift
(
initPtr
->
getShift
()));
oldTr
->
compose
(
newTr
);
return
oldTr
;
}
}
}
}
...
...
modules/reg/src/mappergradsimilar.cpp
View file @
51464723
...
@@ -56,8 +56,8 @@ MapperGradSimilar::~MapperGradSimilar()
...
@@ -56,8 +56,8 @@ MapperGradSimilar::~MapperGradSimilar()
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
void
MapperGradSimilar
::
calculate
(
cv
::
Ptr
<
Map
>
MapperGradSimilar
::
calculate
(
InputArray
_img1
,
InputArray
image2
,
cv
::
Ptr
<
Map
>
&
res
)
const
InputArray
_img1
,
InputArray
image2
,
cv
::
Ptr
<
Map
>
init
)
const
{
{
Mat
img1
=
_img1
.
getMat
();
Mat
img1
=
_img1
.
getMat
();
Mat
gradx
,
grady
,
imgDiff
;
Mat
gradx
,
grady
,
imgDiff
;
...
@@ -67,9 +67,9 @@ void MapperGradSimilar::calculate(
...
@@ -67,9 +67,9 @@ void MapperGradSimilar::calculate(
CV_DbgAssert
(
img1
.
channels
()
==
image2
.
channels
());
CV_DbgAssert
(
img1
.
channels
()
==
image2
.
channels
());
CV_DbgAssert
(
img1
.
channels
()
==
1
||
img1
.
channels
()
==
3
);
CV_DbgAssert
(
img1
.
channels
()
==
1
||
img1
.
channels
()
==
3
);
if
(
!
res
.
empty
())
{
if
(
!
init
.
empty
())
{
// We have initial values for the registration: we move img2 to that initial reference
// We have initial values for the registration: we move img2 to that initial reference
res
->
inverseWarp
(
image2
,
img2
);
init
->
inverseWarp
(
image2
,
img2
);
}
else
{
}
else
{
img2
=
image2
.
getMat
();
img2
=
image2
.
getMat
();
}
}
...
@@ -127,11 +127,14 @@ void MapperGradSimilar::calculate(
...
@@ -127,11 +127,14 @@ void MapperGradSimilar::calculate(
Matx
<
double
,
2
,
2
>
linTr
(
k
(
0
)
+
1.
,
k
(
1
),
-
k
(
1
),
k
(
0
)
+
1.
);
Matx
<
double
,
2
,
2
>
linTr
(
k
(
0
)
+
1.
,
k
(
1
),
-
k
(
1
),
k
(
0
)
+
1.
);
Vec
<
double
,
2
>
shift
(
k
(
2
),
k
(
3
));
Vec
<
double
,
2
>
shift
(
k
(
2
),
k
(
3
));
if
(
res
.
empty
())
{
if
(
init
.
empty
())
{
re
s
=
Ptr
<
Map
>
(
new
MapAffine
(
linTr
,
shift
));
re
turn
Ptr
<
Map
>
(
new
MapAffine
(
linTr
,
shift
));
}
else
{
}
else
{
Ptr
<
MapAffine
>
newTr
(
new
MapAffine
(
linTr
,
shift
));
Ptr
<
MapAffine
>
newTr
(
new
MapAffine
(
linTr
,
shift
));
res
->
compose
(
newTr
);
MapAffine
*
initPtr
=
dynamic_cast
<
MapAffine
*>
(
init
.
get
());
Ptr
<
MapAffine
>
oldTr
(
new
MapAffine
(
initPtr
->
getLinTr
(),
initPtr
->
getShift
()));
oldTr
->
compose
(
newTr
);
return
oldTr
;
}
}
}
}
...
...
modules/reg/src/mapperpyramid.cpp
View file @
51464723
...
@@ -48,22 +48,22 @@ namespace reg {
...
@@ -48,22 +48,22 @@ namespace reg {
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
MapperPyramid
::
MapperPyramid
(
const
Mapper
&
baseMapper
)
MapperPyramid
::
MapperPyramid
(
Ptr
<
Mapper
>
baseMapper
)
:
numLev_
(
3
),
numIterPerScale_
(
3
),
baseMapper_
(
baseMapper
)
:
numLev_
(
3
),
numIterPerScale_
(
3
),
baseMapper_
(
*
baseMapper
)
{
{
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
void
MapperPyramid
::
calculate
(
InputArray
_img1
,
InputArray
image2
,
Ptr
<
Map
>&
res
)
const
Ptr
<
Map
>
MapperPyramid
::
calculate
(
InputArray
_img1
,
InputArray
image2
,
Ptr
<
Map
>
init
)
const
{
{
Mat
img1
=
_img1
.
getMat
();
Mat
img1
=
_img1
.
getMat
();
Mat
img2
;
Mat
img2
;
if
(
!
res
.
empty
())
{
if
(
!
init
.
empty
())
{
// We have initial values for the registration: we move img2 to that initial reference
// We have initial values for the registration: we move img2 to that initial reference
res
->
inverseWarp
(
image2
,
img2
);
init
->
inverseWarp
(
image2
,
img2
);
}
else
{
}
else
{
res
=
baseMapper_
.
getMap
();
init
=
baseMapper_
.
getMap
();
img2
=
image2
.
getMat
();
img2
=
image2
.
getMat
();
}
}
...
@@ -87,11 +87,12 @@ void MapperPyramid::calculate(InputArray _img1, InputArray image2, Ptr<Map>& res
...
@@ -87,11 +87,12 @@ void MapperPyramid::calculate(InputArray _img1, InputArray image2, Ptr<Map>& res
ident
->
scale
(
2.
);
ident
->
scale
(
2.
);
}
}
for
(
size_t
it_i
=
0
;
it_i
<
numIterPerScale_
;
++
it_i
)
{
for
(
size_t
it_i
=
0
;
it_i
<
numIterPerScale_
;
++
it_i
)
{
baseMapper_
.
calculate
(
currRef
,
currImg
,
ident
);
ident
=
baseMapper_
.
calculate
(
currRef
,
currImg
,
ident
);
}
}
}
}
res
->
compose
(
ident
);
init
->
compose
(
ident
);
return
init
;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
...
...
modules/reg/test/test_reg.cpp
View file @
51464723
...
@@ -86,10 +86,10 @@ void RegTest::testShift()
...
@@ -86,10 +86,10 @@ void RegTest::testShift()
mapTest
.
warp
(
img1
,
img2
);
mapTest
.
warp
(
img1
,
img2
);
// Register
// Register
MapperGradShift
mapper
;
Ptr
<
Mapper
>
mapper
=
makePtr
<
MapperGradShift
>
()
;
MapperPyramid
mappPyr
(
mapper
);
MapperPyramid
mappPyr
(
mapper
);
Ptr
<
Map
>
mapPtr
;
Ptr
<
Map
>
mapPtr
;
mappPyr
.
calculate
(
img1
,
img2
,
mapPtr
);
map
Ptr
=
map
pPyr
.
calculate
(
img1
,
img2
,
mapPtr
);
// Print result
// Print result
MapShift
*
mapShift
=
dynamic_cast
<
MapShift
*>
(
mapPtr
.
get
());
MapShift
*
mapShift
=
dynamic_cast
<
MapShift
*>
(
mapPtr
.
get
());
...
@@ -119,10 +119,10 @@ void RegTest::testEuclidean()
...
@@ -119,10 +119,10 @@ void RegTest::testEuclidean()
mapTest
.
warp
(
img1
,
img2
);
mapTest
.
warp
(
img1
,
img2
);
// Register
// Register
MapperGradEuclid
mapper
;
Ptr
<
Mapper
>
mapper
=
makePtr
<
MapperGradEuclid
>
()
;
MapperPyramid
mappPyr
(
mapper
);
MapperPyramid
mappPyr
(
mapper
);
Ptr
<
Map
>
mapPtr
;
Ptr
<
Map
>
mapPtr
;
mappPyr
.
calculate
(
img1
,
img2
,
mapPtr
);
map
Ptr
=
map
pPyr
.
calculate
(
img1
,
img2
,
mapPtr
);
// Print result
// Print result
MapAffine
*
mapAff
=
dynamic_cast
<
MapAffine
*>
(
mapPtr
.
get
());
MapAffine
*
mapAff
=
dynamic_cast
<
MapAffine
*>
(
mapPtr
.
get
());
...
@@ -158,10 +158,10 @@ void RegTest::testSimilarity()
...
@@ -158,10 +158,10 @@ void RegTest::testSimilarity()
mapTest
.
warp
(
img1
,
img2
);
mapTest
.
warp
(
img1
,
img2
);
// Register
// Register
MapperGradSimilar
mapper
;
Ptr
<
Mapper
>
mapper
=
makePtr
<
MapperGradSimilar
>
()
;
MapperPyramid
mappPyr
(
mapper
);
MapperPyramid
mappPyr
(
mapper
);
Ptr
<
Map
>
mapPtr
;
Ptr
<
Map
>
mapPtr
;
mappPyr
.
calculate
(
img1
,
img2
,
mapPtr
);
map
Ptr
=
map
pPyr
.
calculate
(
img1
,
img2
,
mapPtr
);
// Print result
// Print result
MapAffine
*
mapAff
=
dynamic_cast
<
MapAffine
*>
(
mapPtr
.
get
());
MapAffine
*
mapAff
=
dynamic_cast
<
MapAffine
*>
(
mapPtr
.
get
());
...
@@ -194,10 +194,10 @@ void RegTest::testAffine()
...
@@ -194,10 +194,10 @@ void RegTest::testAffine()
mapTest
.
warp
(
img1
,
img2
);
mapTest
.
warp
(
img1
,
img2
);
// Register
// Register
MapperGradAffine
mapper
;
Ptr
<
Mapper
>
mapper
=
makePtr
<
MapperGradAffine
>
()
;
MapperPyramid
mappPyr
(
mapper
);
MapperPyramid
mappPyr
(
mapper
);
Ptr
<
Map
>
mapPtr
;
Ptr
<
Map
>
mapPtr
;
mappPyr
.
calculate
(
img1
,
img2
,
mapPtr
);
map
Ptr
=
map
pPyr
.
calculate
(
img1
,
img2
,
mapPtr
);
// Print result
// Print result
MapAffine
*
mapAff
=
dynamic_cast
<
MapAffine
*>
(
mapPtr
.
get
());
MapAffine
*
mapAff
=
dynamic_cast
<
MapAffine
*>
(
mapPtr
.
get
());
...
@@ -230,10 +230,10 @@ void RegTest::testProjective()
...
@@ -230,10 +230,10 @@ void RegTest::testProjective()
mapTest
.
warp
(
img1
,
img2
);
mapTest
.
warp
(
img1
,
img2
);
// Register
// Register
MapperGradProj
mapper
;
Ptr
<
Mapper
>
mapper
=
makePtr
<
MapperGradProj
>
()
;
MapperPyramid
mappPyr
(
mapper
);
MapperPyramid
mappPyr
(
mapper
);
Ptr
<
Map
>
mapPtr
;
Ptr
<
Map
>
mapPtr
;
mappPyr
.
calculate
(
img1
,
img2
,
mapPtr
);
map
Ptr
=
map
pPyr
.
calculate
(
img1
,
img2
,
mapPtr
);
// Print result
// Print result
MapProjec
*
mapProj
=
dynamic_cast
<
MapProjec
*>
(
mapPtr
.
get
());
MapProjec
*
mapProj
=
dynamic_cast
<
MapProjec
*>
(
mapPtr
.
get
());
...
...
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