Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Help Needed with OpenCV reg: Modifying the map

Hi,

I am working with OpenCV image registration library "reg" under "opencv-contrib". I am using the MapAffine class to estimate affine motion. I need to modify the shift vector element (multiply it by a constant factor). I can get the linear transformation matrix and shift vector using getLinTr() and getShift(). Before doing the warping (using inverseWarp() ) I want to multiply the shift vector by a constant. This is what I have done so far: (Following [this] tutorial(https://github.com/Itseez/opencv_contrib/blob/master/modules/reg/samples/map_test.cpp))

Ptr<Map> mapPtr;
MapperGradAffine mapper;
MapperPyramid mapPyr(mapper);
Ptr<Map> mapPtr;
mapPyr.calculate(image1, image2,  mapPtr);
MapAffine* mapAff = dynamic_cast<MapAffine*>(mapPtr.get());

Then doing the warping:

mapAff->inversewarp(image2, destination);

Now I want to modify the shift vector prior to doing the above step. I have tried to modify the shift part using opencv Mat obejcts:

cv::Mat lin_tr = Mat(mapAff->getLintr); //getting the linear part
cv::Mat shift = Mat(mapAff->getShift()); //getting the translation
cv::Mat* aff_mat;
cv::hconcat(lin_tr, 2 * shift, *aff_mat);

Now the affine matrix is in a Mat object. My question is how can I recast it to MapAffine so that I can use the inversewarp() function. Or is there another way to modify the mapAffine reference directly?

Help Needed with OpenCV reg: Modifying the map

Hi,

I am working with OpenCV image registration library "reg" under "opencv-contrib". I am using the MapAffine class to estimate affine motion. I need to modify the shift vector element (multiply it by a constant factor). I can get the linear transformation matrix and shift vector using getLinTr() and getShift(). Before doing the warping (using inverseWarp() ) I want to multiply the shift vector by a constant. This is what I have done so far: (Following [this] tutorial(https://github.com/Itseez/opencv_contrib/blob/master/modules/reg/samples/map_test.cpp))this tutorial (https://github.com/Itseez/opencv_contrib/blob/master/modules/reg/samples/map_test.cpp)

Ptr<Map> mapPtr;
MapperGradAffine mapper;
MapperPyramid mapPyr(mapper);
Ptr<Map> mapPtr;
mapPyr.calculate(image1, image2,  mapPtr);
MapAffine* mapAff = dynamic_cast<MapAffine*>(mapPtr.get());

Then doing the warping:

mapAff->inversewarp(image2, destination);

Now I want to modify the shift vector prior to doing the above step. I have tried to modify the shift part using opencv Mat obejcts:

cv::Mat lin_tr = Mat(mapAff->getLintr); //getting the linear part
cv::Mat shift = Mat(mapAff->getShift()); //getting the translation
cv::Mat* aff_mat;
cv::hconcat(lin_tr, 2 * shift, *aff_mat);

Now the affine matrix is in a Mat object. My question is how can I recast it to MapAffine so that I can use the inversewarp() function. Or is there another way to modify the mapAffine reference directly?