Merge pull request #5595 from Lawrence37/distortion

Move profiled distortion correction in pipeline
This commit is contained in:
Lawrence37
2020-06-25 10:56:58 -07:00
committed by GitHub
5 changed files with 26 additions and 36 deletions

View File

@@ -491,15 +491,8 @@ bool ImProcFunctions::transCoord (int W, int H, const std::vector<Coord2D> &src,
for (size_t i = 0; i < src.size(); i++) {
double x_d = src[i].x, y_d = src[i].y;
if (pLCPMap && params->lensProf.useDist) {
pLCPMap->correctDistortion(x_d, y_d, 0, 0, ascale);
} else {
x_d *= ascale;
y_d *= ascale;
}
x_d += ascale * (0 - w2); // centering x coord & scale
y_d += ascale * (0 - h2); // centering y coord & scale
y_d = ascale * (y_d - h2); // centering x coord & scale
x_d = ascale * (x_d - w2); // centering x coord & scale
switch (perspectiveType) {
case PerspType::NONE:
@@ -522,6 +515,10 @@ bool ImProcFunctions::transCoord (int W, int H, const std::vector<Coord2D> &src,
break;
}
if (pLCPMap && params->lensProf.useDist) {
pLCPMap->correctDistortion(x_d, y_d, 0, 0);
}
// rotate
double Dx = x_d * cost - y_d * sint;
double Dy = x_d * sint + y_d * cost;
@@ -1219,15 +1216,8 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I
double x_d = x;
double y_d = y;
if (enableLCPDist) {
pLCPMap->correctDistortion(x_d, y_d, cx, cy, ascale); // must be first transform
} else {
x_d *= ascale;
y_d *= ascale;
}
x_d += ascale * centerFactorx; // centering x coord & scale
y_d += ascale * centerFactory; // centering y coord & scale
x_d = ascale * (x_d + centerFactorx); // centering x coord & scale
y_d = ascale * (y_d + centerFactory); // centering y coord & scale
switch (perspectiveType) {
case PerspType::NONE:
@@ -1250,6 +1240,10 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I
break;
}
if (enableLCPDist) {
pLCPMap->correctDistortion(x_d, y_d, w2, h2);
}
// rotate
const double Dxc = x_d * cost - y_d * sint;
const double Dyc = x_d * sint + y_d * cost;