Commit 97dab3b5 authored by Vladislav Sovrasov's avatar Vladislav Sovrasov

reg: enable wrapping of Map::compose()

parent 79edb0fa
...@@ -158,7 +158,7 @@ public: ...@@ -158,7 +158,7 @@ public:
* The order is first the current transformation, then the input argument. * The order is first the current transformation, then the input argument.
* \param[in] map Transformation to compose with. * \param[in] map Transformation to compose with.
*/ */
virtual void compose(const Map& map) = 0; CV_WRAP virtual void compose(cv::Ptr<Map> map) = 0;
/*! /*!
* Scales the map by a given factor as if the coordinates system is expanded/compressed * Scales the map by a given factor as if the coordinates system is expanded/compressed
......
...@@ -73,7 +73,7 @@ public: ...@@ -73,7 +73,7 @@ public:
CV_WRAP cv::Ptr<Map> inverseMap() const; CV_WRAP cv::Ptr<Map> inverseMap() const;
void compose(const Map& map); CV_WRAP void compose(cv::Ptr<Map> map);
CV_WRAP void scale(double factor); CV_WRAP void scale(double factor);
......
...@@ -73,7 +73,7 @@ public: ...@@ -73,7 +73,7 @@ public:
CV_WRAP cv::Ptr<Map> inverseMap() const; CV_WRAP cv::Ptr<Map> inverseMap() const;
void compose(const Map& map); CV_WRAP void compose(cv::Ptr<Map> map);
CV_WRAP void scale(double factor); CV_WRAP void scale(double factor);
......
...@@ -73,7 +73,7 @@ public: ...@@ -73,7 +73,7 @@ public:
CV_WRAP cv::Ptr<Map> inverseMap() const; CV_WRAP cv::Ptr<Map> inverseMap() const;
void compose(const Map& map); CV_WRAP void compose(cv::Ptr<Map> map);
CV_WRAP void scale(double factor); CV_WRAP void scale(double factor);
......
...@@ -94,10 +94,10 @@ Ptr<Map> MapAffine::inverseMap(void) const ...@@ -94,10 +94,10 @@ Ptr<Map> MapAffine::inverseMap(void) const
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
void MapAffine::compose(const Map& map) void MapAffine::compose(cv::Ptr<Map> map)
{ {
// Composition of affine transformations T and T' is (T o T') = A'Ax + A'b + b' // Composition of affine transformations T and T' is (T o T') = A'Ax + A'b + b'
const MapAffine& mapAff = static_cast<const MapAffine&>(map); const MapAffine& mapAff = static_cast<const MapAffine&>(*map);
Matx<double, 2, 2> compMat = mapAff.getLinTr()*linTr_; Matx<double, 2, 2> compMat = mapAff.getLinTr()*linTr_;
Vec<double, 2> compShift = mapAff.getLinTr()*shift_ + mapAff.getShift(); Vec<double, 2> compShift = mapAff.getLinTr()*shift_ + mapAff.getShift();
linTr_ = compMat; linTr_ = compMat;
......
...@@ -148,7 +148,7 @@ void MapperGradAffine::calculate(InputArray _img1, InputArray image2, cv::Ptr<Ma ...@@ -148,7 +148,7 @@ void MapperGradAffine::calculate(InputArray _img1, InputArray image2, cv::Ptr<Ma
if(res.empty()) { if(res.empty()) {
res = Ptr<Map>(new MapAffine(linTr, shift)); res = Ptr<Map>(new MapAffine(linTr, shift));
} else { } else {
MapAffine newTr(linTr, shift); Ptr<MapAffine> newTr(new MapAffine(linTr, shift));
res->compose(newTr); res->compose(newTr);
} }
} }
......
...@@ -115,7 +115,7 @@ void MapperGradEuclid::calculate( ...@@ -115,7 +115,7 @@ void MapperGradEuclid::calculate(
if(res.empty()) { if(res.empty()) {
res = Ptr<Map>(new MapAffine(linTr, shift)); res = Ptr<Map>(new MapAffine(linTr, shift));
} else { } else {
MapAffine newTr(linTr, shift); Ptr<MapAffine> newTr(new MapAffine(linTr, shift));
res->compose(newTr); res->compose(newTr);
} }
} }
......
...@@ -199,7 +199,7 @@ void MapperGradProj::calculate( ...@@ -199,7 +199,7 @@ void MapperGradProj::calculate(
if(res.empty()) { if(res.empty()) {
res = Ptr<Map>(new MapProjec(H)); res = Ptr<Map>(new MapProjec(H));
} else { } else {
MapProjec newTr(H); Ptr<MapProjec> newTr(new MapProjec(H));
res->compose(newTr); res->compose(newTr);
} }
} }
......
...@@ -96,7 +96,7 @@ void MapperGradShift::calculate( ...@@ -96,7 +96,7 @@ void MapperGradShift::calculate(
if(res.empty()) { if(res.empty()) {
res = Ptr<Map>(new MapShift(shift)); res = Ptr<Map>(new MapShift(shift));
} else { } else {
MapShift newTr(shift); Ptr<MapShift> newTr(new MapShift(shift));
res->compose(newTr); res->compose(newTr);
} }
} }
......
...@@ -130,7 +130,7 @@ void MapperGradSimilar::calculate( ...@@ -130,7 +130,7 @@ void MapperGradSimilar::calculate(
if(res.empty()) { if(res.empty()) {
res = Ptr<Map>(new MapAffine(linTr, shift)); res = Ptr<Map>(new MapAffine(linTr, shift));
} else { } else {
MapAffine newTr(linTr, shift); Ptr<MapAffine> newTr(new MapAffine(linTr, shift));
res->compose(newTr); res->compose(newTr);
} }
} }
......
...@@ -91,7 +91,7 @@ void MapperPyramid::calculate(InputArray _img1, InputArray image2, Ptr<Map>& res ...@@ -91,7 +91,7 @@ void MapperPyramid::calculate(InputArray _img1, InputArray image2, Ptr<Map>& res
} }
} }
res->compose(*ident.get()); res->compose(ident);
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
......
...@@ -96,10 +96,10 @@ Ptr<Map> MapProjec::inverseMap(void) const ...@@ -96,10 +96,10 @@ Ptr<Map> MapProjec::inverseMap(void) const
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
void MapProjec::compose(const Map& map) void MapProjec::compose(Ptr<Map> map)
{ {
// Composition of homographies H and H' is (H o H') = H'*H // Composition of homographies H and H' is (H o H') = H'*H
const MapProjec& mapProj = static_cast<const MapProjec&>(map); const MapProjec& mapProj = static_cast<const MapProjec&>(*map);
Matx<double, 3, 3> compProjTr = mapProj.getProjTr()*projTr_; Matx<double, 3, 3> compProjTr = mapProj.getProjTr()*projTr_;
projTr_ = compProjTr; projTr_ = compProjTr;
} }
......
...@@ -92,10 +92,10 @@ Ptr<Map> MapShift::inverseMap(void) const ...@@ -92,10 +92,10 @@ Ptr<Map> MapShift::inverseMap(void) const
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
void MapShift::compose(const Map& map) void MapShift::compose(cv::Ptr<Map> map)
{ {
// Composition of transformations T and T' is (T o T') = b + b' // Composition of transformations T and T' is (T o T') = b + b'
const MapShift& mapShift = static_cast<const MapShift&>(map); const MapShift& mapShift = static_cast<const MapShift&>(*map);
shift_ += mapShift.getShift(); shift_ += mapShift.getShift();
} }
......
...@@ -100,7 +100,7 @@ void RegTest::testShift() ...@@ -100,7 +100,7 @@ void RegTest::testShift()
#endif #endif
// Check accuracy // Check accuracy
Ptr<Map> mapInv(mapShift->inverseMap()); Ptr<Map> mapInv(mapShift->inverseMap());
mapTest.compose(*mapInv.get()); mapTest.compose(mapInv);
double shNorm = norm(mapTest.getShift()); double shNorm = norm(mapTest.getShift());
EXPECT_LE(shNorm, 0.1); EXPECT_LE(shNorm, 0.1);
} }
...@@ -135,7 +135,7 @@ void RegTest::testEuclidean() ...@@ -135,7 +135,7 @@ void RegTest::testEuclidean()
#endif #endif
// Check accuracy // Check accuracy
Ptr<Map> mapInv(mapAff->inverseMap()); Ptr<Map> mapInv(mapAff->inverseMap());
mapTest.compose(*mapInv.get()); mapTest.compose(mapInv);
double shNorm = norm(mapTest.getShift()); double shNorm = norm(mapTest.getShift());
EXPECT_LE(shNorm, 0.1); EXPECT_LE(shNorm, 0.1);
double linTrNorm = norm(mapTest.getLinTr()); double linTrNorm = norm(mapTest.getLinTr());
...@@ -175,7 +175,7 @@ void RegTest::testSimilarity() ...@@ -175,7 +175,7 @@ void RegTest::testSimilarity()
// Check accuracy // Check accuracy
Ptr<Map> mapInv(mapAff->inverseMap()); Ptr<Map> mapInv(mapAff->inverseMap());
mapTest.compose(*mapInv.get()); mapTest.compose(mapInv);
double shNorm = norm(mapTest.getShift()); double shNorm = norm(mapTest.getShift());
EXPECT_LE(shNorm, 0.1); EXPECT_LE(shNorm, 0.1);
double linTrNorm = norm(mapTest.getLinTr()); double linTrNorm = norm(mapTest.getLinTr());
...@@ -211,7 +211,7 @@ void RegTest::testAffine() ...@@ -211,7 +211,7 @@ void RegTest::testAffine()
// Check accuracy // Check accuracy
Ptr<Map> mapInv(mapAff->inverseMap()); Ptr<Map> mapInv(mapAff->inverseMap());
mapTest.compose(*mapInv.get()); mapTest.compose(mapInv);
double shNorm = norm(mapTest.getShift()); double shNorm = norm(mapTest.getShift());
EXPECT_LE(shNorm, 0.1); EXPECT_LE(shNorm, 0.1);
double linTrNorm = norm(mapTest.getLinTr()); double linTrNorm = norm(mapTest.getLinTr());
...@@ -246,7 +246,7 @@ void RegTest::testProjective() ...@@ -246,7 +246,7 @@ void RegTest::testProjective()
// Check accuracy // Check accuracy
Ptr<Map> mapInv(mapProj->inverseMap()); Ptr<Map> mapInv(mapProj->inverseMap());
mapTest.compose(*mapInv.get()); mapTest.compose(mapInv);
double projNorm = norm(mapTest.getProjTr()); double projNorm = norm(mapTest.getProjTr());
EXPECT_LE(projNorm, sqrt(3.) + 0.01); EXPECT_LE(projNorm, sqrt(3.) + 0.01);
EXPECT_GE(projNorm, sqrt(3.) - 0.01); EXPECT_GE(projNorm, sqrt(3.) - 0.01);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment