OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Fri, 25 Sep 2020 05:21:10 -0500Determine new coordinates of pixel after calibration + remaphttp://answers.opencv.org/question/235646/determine-new-coordinates-of-pixel-after-calibration-remap/I'm trying to calibrate camera and I need to be able to determine where to moves each pixel of the original image.
As far as I understand initUndistortRectifyMap creates horizontal and vertical maps (map1 and map2) for remap as a result of some mathematical functions but I honestly did not quite get [all the math behind it](https://docs.opencv.org/master/d9/d0c/group__calib3d.html#ga7dfb72c9cf9780a347fbe3d1c47e5d5a).
I think I get the idea of how x'' and y'' are calculated (also can you check if I get it right on this screenshot from Maple?) but I can't understand what's going on with s and x''' & y'''.
![Calculations up to x'' and y''](/upfiles/1601028896576920.png)
Here's code. As far as I understand in my case R is identity matrix and all distortion coefficients apart from k1,k2,p1,p2,k3 are zeroes.
auto result = calibrateCamera(objectPoints, // the 3D points
imagePoints, // the image points
imageSize, // image size
cameraMatrix, // output camera matrix
distCoeffs, // output distortion matrix
rvecs, tvecs, // Rs, Ts
flag); // set options
// . . .
cv::initUndistortRectifyMap(
cameraMatrix, // computed camera matrix
distCoeffs, // computed distortion matrix
cv::Mat(), // optional rectification (none)
cv::Mat(), // camera matrix to generate undistorted
cv::Size(640, 480), // size of undistorted
CV_32FC1, // type of output map
map1, map2); // the x and y mapping functionsFri, 25 Sep 2020 05:21:10 -0500http://answers.opencv.org/question/235646/determine-new-coordinates-of-pixel-after-calibration-remap/