If i understand right, you have different distortions on each camera, and you want to undistort one of them and apply the other camera's distortion. For the undistortion part here's what I've done in the past.
Using OF, on setup you can create the distortion/undistortion maps, using cv::initUndistortRectifyMap
, that will give you two maps in the form of cv::Mat
objects. This function receives the camera matrix and distortion coefficients from the calibration.
Then you can apply the mapping using cv::remap
. Which will store the result in its second parameter.
After undistorting you'd want to apply the inverse mapping, for applying the other camera's distortion. It seems the warpPerspective function you mentioned would work well for that, but a mapping could probably be computed from the .yml
files you got. It's just a matter of applying the opposite mapping.
Use ofxCV's wrapping to switch from ofImage to Mat whenever it's necessary to make sure you don't make unnecessary copies.