Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 99d51a2

Browse files
committed
Merge branch 'as/undistortion_grid_port_5.x' into 5.x-merge-4.x
2 parents b2b63fd + 07edd5e commit 99d51a2

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

modules/3d/include/opencv2/3d.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2384,7 +2384,7 @@ to compute the optimal new camera matrix.
23842384
*/
23852385
CV_EXPORTS void getUndistortRectangles(InputArray cameraMatrix, InputArray distCoeffs,
23862386
InputArray R, InputArray newCameraMatrix, Size imgSize,
2387-
Rect_<float>& inner, Rect_<float>& outer );
2387+
Rect_<double>& inner, Rect_<double>& outer );
23882388

23892389
/** @brief Returns the new camera intrinsic matrix based on the free scaling parameter.
23902390

modules/3d/src/calibration_base.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,27 +1363,27 @@ void cv::projectPoints( InputArray _opoints,
13631363

13641364
void cv::getUndistortRectangles(InputArray _cameraMatrix, InputArray _distCoeffs,
13651365
InputArray R, InputArray newCameraMatrix, Size imgSize,
1366-
Rect_<float>& inner, Rect_<float>& outer )
1366+
Rect_<double>& inner, Rect_<double>& outer )
13671367
{
13681368
const int N = 9;
13691369
int x, y, k;
1370-
Mat _pts(1, N*N, CV_32FC2);
1371-
Point2f* pts = _pts.ptr<Point2f>();
1370+
Mat _pts(1, N*N, CV_64FC2);
1371+
Point2d* pts = _pts.ptr<Point2d>();
13721372

13731373
for( y = k = 0; y < N; y++ )
13741374
for( x = 0; x < N; x++ )
1375-
pts[k++] = Point2f((float)x*imgSize.width/(N-1), (float)y*imgSize.height/(N-1));
1375+
pts[k++] = Point2d((double)x*(imgSize.width-1)/(N-1), (double)y*(imgSize.height-1)/(N-1));
13761376

13771377
undistortPoints(_pts, _pts, _cameraMatrix, _distCoeffs, R, newCameraMatrix);
13781378

1379-
float iX0=-FLT_MAX, iX1=FLT_MAX, iY0=-FLT_MAX, iY1=FLT_MAX;
1380-
float oX0=FLT_MAX, oX1=-FLT_MAX, oY0=FLT_MAX, oY1=-FLT_MAX;
1379+
double iX0=-FLT_MAX, iX1=FLT_MAX, iY0=-FLT_MAX, iY1=FLT_MAX;
1380+
double oX0=FLT_MAX, oX1=-FLT_MAX, oY0=FLT_MAX, oY1=-FLT_MAX;
13811381
// find the inscribed rectangle.
13821382
// the code will likely not work with extreme rotation matrices (R) (>45%)
13831383
for( y = k = 0; y < N; y++ )
13841384
for( x = 0; x < N; x++ )
13851385
{
1386-
Point2f p = pts[k++];
1386+
Point2d p = pts[k++];
13871387
oX0 = MIN(oX0, p.x);
13881388
oX1 = MAX(oX1, p.x);
13891389
oY0 = MIN(oY0, p.y);
@@ -1398,15 +1398,15 @@ void cv::getUndistortRectangles(InputArray _cameraMatrix, InputArray _distCoeffs
13981398
if( y == N-1 )
13991399
iY1 = MIN(iY1, p.y);
14001400
}
1401-
inner = Rect_<float>(iX0, iY0, iX1-iX0, iY1-iY0);
1402-
outer = Rect_<float>(oX0, oY0, oX1-oX0, oY1-oY0);
1401+
inner = Rect_<double>(iX0, iY0, iX1-iX0, iY1-iY0);
1402+
outer = Rect_<double>(oX0, oY0, oX1-oX0, oY1-oY0);
14031403
}
14041404

14051405
cv::Mat cv::getOptimalNewCameraMatrix( InputArray _cameraMatrix, InputArray _distCoeffs,
14061406
Size imgSize, double alpha, Size newImgSize,
14071407
Rect* validPixROI, bool centerPrincipalPoint )
14081408
{
1409-
Rect_<float> inner, outer;
1409+
Rect_<double> inner, outer;
14101410
newImgSize = newImgSize.width*newImgSize.height != 0 ? newImgSize : imgSize;
14111411

14121412
Mat cameraMatrix = _cameraMatrix.getMat(), M;
@@ -1436,10 +1436,10 @@ cv::Mat cv::getOptimalNewCameraMatrix( InputArray _cameraMatrix, InputArray _dis
14361436

14371437
if( validPixROI )
14381438
{
1439-
inner = cv::Rect_<float>((float)((inner.x - cx0)*s + cx),
1440-
(float)((inner.y - cy0)*s + cy),
1441-
(float)(inner.width*s),
1442-
(float)(inner.height*s));
1439+
inner = cv::Rect_<double>((double)((inner.x - cx0)*s + cx),
1440+
(double)((inner.y - cy0)*s + cy),
1441+
(double)(inner.width*s),
1442+
(double)(inner.height*s));
14431443
Rect r(cvCeil(inner.x), cvCeil(inner.y), cvFloor(inner.width), cvFloor(inner.height));
14441444
r &= Rect(0, 0, newImgSize.width, newImgSize.height);
14451445
*validPixROI = r;

modules/stereo/src/stereo_geom.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ void stereoRectify( InputArray _cameraMatrix1, InputArray _distCoeffs1,
236236

237237
alpha = MIN(alpha, 1.);
238238

239-
cv::Rect_<float> inner1, inner2, outer1, outer2;
239+
cv::Rect_<double> inner1, inner2, outer1, outer2;
240240
getUndistortRectangles(cameraMatrix1, distCoeffs1, _R1, _P1, imageSize, inner1, outer1);
241241
getUndistortRectangles(cameraMatrix2, distCoeffs2, _R2, _P2, imageSize, inner2, outer2);
242242

0 commit comments

Comments
 (0)