mirror of
https://github.com/opencv/opencv.git
synced 2025-06-12 20:42:53 +08:00
fix getUndistortRectangles to ignore corners
This commit is contained in:
parent
344f8c6400
commit
a63ebb3dd1
@ -1527,7 +1527,7 @@ void cv::getUndistortRectangles(InputArray _cameraMatrix, InputArray _distCoeffs
|
|||||||
{
|
{
|
||||||
const int N = 9;
|
const int N = 9;
|
||||||
int x, y, k;
|
int x, y, k;
|
||||||
Mat _pts(1, 4*(N-1), CV_64FC2);
|
Mat _pts(1, 4*(N-2), CV_64FC2);
|
||||||
Point2d* pts = _pts.ptr<Point2d>();
|
Point2d* pts = _pts.ptr<Point2d>();
|
||||||
|
|
||||||
// generate a grid of points across the image to estimate the distortion deformation
|
// generate a grid of points across the image to estimate the distortion deformation
|
||||||
@ -1543,6 +1543,12 @@ void cv::getUndistortRectangles(InputArray _cameraMatrix, InputArray _distCoeffs
|
|||||||
// have no influence on the two deformation rectangles that are calculated below
|
// have no influence on the two deformation rectangles that are calculated below
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if ((x == 0 || x == N - 1) && (y == 0 || y == N - 1))
|
||||||
|
{
|
||||||
|
// skip corners, because undistortPoints is likely to fail and return the same
|
||||||
|
// value
|
||||||
|
continue;
|
||||||
|
}
|
||||||
pts[k++] = Point2d(x * stepX, y * stepY);
|
pts[k++] = Point2d(x * stepX, y * stepY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1561,6 +1567,10 @@ void cv::getUndistortRectangles(InputArray _cameraMatrix, InputArray _distCoeffs
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if ((x == 0 || x == N - 1) && (y == 0 || y == N - 1))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Point2d p = pts[k++];
|
Point2d p = pts[k++];
|
||||||
oX0 = MIN(oX0, p.x);
|
oX0 = MIN(oX0, p.x);
|
||||||
|
Loading…
Reference in New Issue
Block a user