The python code below should register an image. The code is based on the example code map_test.cpp found here and also seen below. However I cannot seem to find the equivalent for casting map_ptr (which is a reg_Map object) to a map projection. The cpp code uses a .get() function. Performing this step is relevant as the normalize function is a class member of cv2.reg_MapProjec. In the code below, when I try to cast mat_ptr to map_proj, I get the error TypeError: Expected Ptr cv::UMat for argument '%s'. Does any know how to solve this issue?
Thanks in advance
def calc_homography_pixel(img1, img2):
mapper = cv2.reg_MapperGradProj()
mapp_pyr = cv2.reg_MapperPyramid(mapper)
map_ptr = mapp_pyr.calculate(img1, img2)
map_proj = cv2.reg_MapProjec(map_ptr) # the issue is how to the map from the pyramid cal.
map_proj = map_proj.normalize()
dest = map_proj.inverseWarp(img2)
The c++ code
static void calcHomographyPixel(const Mat& img1, const Mat& img2)
{
static const char* diffpixel = "Difference pixel registered";
Ptr<MapperGradProj> mapper = makePtr<MapperGradProj>();
MapperPyramid mappPyr(mapper);
Ptr<Map> mapPtr = mappPyr.calculate(img1, img2);
MapProjec* mapProj = dynamic_cast<MapProjec*>(mapPtr.get());
mapProj->normalize();
cout << "--- Pixel-based method\n" << Mat(mapProj->getProjTr()) << endl;
Mat dest;
mapProj->inverseWarp(img2, dest);
showDifference(img1, dest, diffpixel);
}