undistort() and remap() give different results
I was trying to figure out things for my previous question but suddenly found out that undistort() and remap() give different results.
Any ideas why can it be and what result can be considered more "correct"?
remap:
undistort:
post data and runnable code that reproduce this issue.
Sorry for such a late response, for some reason I did not get notification on email about your comment, still figuring out how to set up this properly. Here's the link: source code and a folder with images. At first run it creates maps.yml with data for undistort/remap, on second — loads it from the file and applies to a single image. UPD: Source is in C++
I can only speculate that one of the functions "crops" the picture (by manipulating the camera matrix) such that the picture contains as little black border and as much image content as possible. that was something I saw in the docs a long time ago, so it may not be the case now. either way, remap is a generic operation that relies on something else generating the map. undistort() applies the transformation directly, initUndistortRectifyMap() constructs the hopefully identical maps for a remap() call. it does contain "rectify" in the name, so it probably does more than just undistort.
I looked through your code and compared it to docs. undistort: "The function is simply a combination of initUndistortRectifyMap (with unity R ) and remap (with bilinear interpolation)". your call to initUndistortRectifyMap doesn't pass a unity R (identity matrix) but an empty R. I think that could be the difference. I think "getOptimalNewCameraMatrix" is involved... that could explain the shift/crop you see.