reg: enable wrapping of Map::compose()

pull/988/head
Vladislav Sovrasov 8 years ago
parent 79edb0faf2
commit 97dab3b568
  1. 2
      modules/reg/include/opencv2/reg/map.hpp
  2. 2
      modules/reg/include/opencv2/reg/mapaffine.hpp
  3. 2
      modules/reg/include/opencv2/reg/mapprojec.hpp
  4. 2
      modules/reg/include/opencv2/reg/mapshift.hpp
  5. 4
      modules/reg/src/mapaffine.cpp
  6. 2
      modules/reg/src/mappergradaffine.cpp
  7. 2
      modules/reg/src/mappergradeuclid.cpp
  8. 2
      modules/reg/src/mappergradproj.cpp
  9. 2
      modules/reg/src/mappergradshift.cpp
  10. 2
      modules/reg/src/mappergradsimilar.cpp
  11. 2
      modules/reg/src/mapperpyramid.cpp
  12. 4
      modules/reg/src/mapprojec.cpp
  13. 4
      modules/reg/src/mapshift.cpp
  14. 10
      modules/reg/test/test_reg.cpp

@ -158,7 +158,7 @@ public:
* The order is first the current transformation, then the input argument.
* \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

@ -73,7 +73,7 @@ public:
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);

@ -73,7 +73,7 @@ public:
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);

@ -73,7 +73,7 @@ public:
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);

@ -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'
const MapAffine& mapAff = static_cast<const MapAffine&>(map);
const MapAffine& mapAff = static_cast<const MapAffine&>(*map);
Matx<double, 2, 2> compMat = mapAff.getLinTr()*linTr_;
Vec<double, 2> compShift = mapAff.getLinTr()*shift_ + mapAff.getShift();
linTr_ = compMat;

@ -148,7 +148,7 @@ void MapperGradAffine::calculate(InputArray _img1, InputArray image2, cv::Ptr<Ma
if(res.empty()) {
res = Ptr<Map>(new MapAffine(linTr, shift));
} else {
MapAffine newTr(linTr, shift);
Ptr<MapAffine> newTr(new MapAffine(linTr, shift));
res->compose(newTr);
}
}

@ -115,7 +115,7 @@ void MapperGradEuclid::calculate(
if(res.empty()) {
res = Ptr<Map>(new MapAffine(linTr, shift));
} else {
MapAffine newTr(linTr, shift);
Ptr<MapAffine> newTr(new MapAffine(linTr, shift));
res->compose(newTr);
}
}

@ -199,7 +199,7 @@ void MapperGradProj::calculate(
if(res.empty()) {
res = Ptr<Map>(new MapProjec(H));
} else {
MapProjec newTr(H);
Ptr<MapProjec> newTr(new MapProjec(H));
res->compose(newTr);
}
}

@ -96,7 +96,7 @@ void MapperGradShift::calculate(
if(res.empty()) {
res = Ptr<Map>(new MapShift(shift));
} else {
MapShift newTr(shift);
Ptr<MapShift> newTr(new MapShift(shift));
res->compose(newTr);
}
}

@ -130,7 +130,7 @@ void MapperGradSimilar::calculate(
if(res.empty()) {
res = Ptr<Map>(new MapAffine(linTr, shift));
} else {
MapAffine newTr(linTr, shift);
Ptr<MapAffine> newTr(new MapAffine(linTr, shift));
res->compose(newTr);
}
}

@ -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
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void MapProjec::compose(const Map& map)
void MapProjec::compose(Ptr<Map> map)
{
// 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_;
projTr_ = compProjTr;
}

@ -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'
const MapShift& mapShift = static_cast<const MapShift&>(map);
const MapShift& mapShift = static_cast<const MapShift&>(*map);
shift_ += mapShift.getShift();
}

@ -100,7 +100,7 @@ void RegTest::testShift()
#endif
// Check accuracy
Ptr<Map> mapInv(mapShift->inverseMap());
mapTest.compose(*mapInv.get());
mapTest.compose(mapInv);
double shNorm = norm(mapTest.getShift());
EXPECT_LE(shNorm, 0.1);
}
@ -135,7 +135,7 @@ void RegTest::testEuclidean()
#endif
// Check accuracy
Ptr<Map> mapInv(mapAff->inverseMap());
mapTest.compose(*mapInv.get());
mapTest.compose(mapInv);
double shNorm = norm(mapTest.getShift());
EXPECT_LE(shNorm, 0.1);
double linTrNorm = norm(mapTest.getLinTr());
@ -175,7 +175,7 @@ void RegTest::testSimilarity()
// Check accuracy
Ptr<Map> mapInv(mapAff->inverseMap());
mapTest.compose(*mapInv.get());
mapTest.compose(mapInv);
double shNorm = norm(mapTest.getShift());
EXPECT_LE(shNorm, 0.1);
double linTrNorm = norm(mapTest.getLinTr());
@ -211,7 +211,7 @@ void RegTest::testAffine()
// Check accuracy
Ptr<Map> mapInv(mapAff->inverseMap());
mapTest.compose(*mapInv.get());
mapTest.compose(mapInv);
double shNorm = norm(mapTest.getShift());
EXPECT_LE(shNorm, 0.1);
double linTrNorm = norm(mapTest.getLinTr());
@ -246,7 +246,7 @@ void RegTest::testProjective()
// Check accuracy
Ptr<Map> mapInv(mapProj->inverseMap());
mapTest.compose(*mapInv.get());
mapTest.compose(mapInv);
double projNorm = norm(mapTest.getProjTr());
EXPECT_LE(projNorm, sqrt(3.) + 0.01);
EXPECT_GE(projNorm, sqrt(3.) - 0.01);

Loading…
Cancel
Save