Add hard-coded fisheye un-distortion operation for testing / discussion

This commit is contained in:
Alexander Brock
2023-02-04 00:59:04 +01:00
parent 9a245c1acb
commit 9de5cb9915

View File

@@ -1244,6 +1244,25 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I
pLCPMap->correctDistortion(x_d, y_d, w2, h2);
}
// Hard-coded fisheye undistortion for testing purposes.
bool enableFish = true;
// Hard-coded focal length so it matches the image used for testing
double focal_source = maxRadius*1351.0/5206.416;
// A different destination focal length allows the user to shrink the image so more of the original FoV fits into the undistorted image.
// fish_scale = 0.5 means the source image is downscaled by a factor of two in the center.
double fish_scale = 0.5;
double focal_dst = focal_source*fish_scale;
if (enableFish) {
x_d /= focal_dst;
y_d /= focal_dst;
double const r = std::sqrt(x_d*x_d + y_d*y_d);
double const factor = focal_source * std::atan(r)/r;
x_d *= factor;
y_d *= factor;
}
// rotate
const double Dxc = x_d * cost - y_d * sint;
const double Dyc = x_d * sint + y_d * cost;