[英]How to convert c++ get function code to python used in an opencv algorithm
我想将以下 c++ 代码转换为 python。但我似乎找不到第 7 行的等效代码:MapProjec* mapProj = dynamic_cast(mapPtr.get())。
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);
}
到目前为止,我得到的是以下内容;
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)
建议将不胜感激。
这是一个老问题,但如果将来有人需要它,也许你可以尝试:
map_proj = cv2.reg.MapTypeCaster_toProjec(map_ptr)
map_proj.normalize
这是来自: https://answers.opencv.org/question/225512/how-to-port-image-registration-c-code-to-python/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.