@@ -1363,27 +1363,27 @@ void cv::projectPoints( InputArray _opoints,
1363
1363
1364
1364
void cv::getUndistortRectangles (InputArray _cameraMatrix, InputArray _distCoeffs,
1365
1365
InputArray R, InputArray newCameraMatrix, Size imgSize,
1366
- Rect_<float >& inner, Rect_<float >& outer )
1366
+ Rect_<double >& inner, Rect_<double >& outer )
1367
1367
{
1368
1368
const int N = 9 ;
1369
1369
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 >();
1372
1372
1373
1373
for ( y = k = 0 ; y < N; y++ )
1374
1374
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 ));
1376
1376
1377
1377
undistortPoints (_pts, _pts, _cameraMatrix, _distCoeffs, R, newCameraMatrix);
1378
1378
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;
1381
1381
// find the inscribed rectangle.
1382
1382
// the code will likely not work with extreme rotation matrices (R) (>45%)
1383
1383
for ( y = k = 0 ; y < N; y++ )
1384
1384
for ( x = 0 ; x < N; x++ )
1385
1385
{
1386
- Point2f p = pts[k++];
1386
+ Point2d p = pts[k++];
1387
1387
oX0 = MIN (oX0, p.x );
1388
1388
oX1 = MAX (oX1, p.x );
1389
1389
oY0 = MIN (oY0, p.y );
@@ -1398,15 +1398,15 @@ void cv::getUndistortRectangles(InputArray _cameraMatrix, InputArray _distCoeffs
1398
1398
if ( y == N-1 )
1399
1399
iY1 = MIN (iY1, p.y );
1400
1400
}
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);
1403
1403
}
1404
1404
1405
1405
cv::Mat cv::getOptimalNewCameraMatrix ( InputArray _cameraMatrix, InputArray _distCoeffs,
1406
1406
Size imgSize, double alpha, Size newImgSize,
1407
1407
Rect* validPixROI, bool centerPrincipalPoint )
1408
1408
{
1409
- Rect_<float > inner, outer;
1409
+ Rect_<double > inner, outer;
1410
1410
newImgSize = newImgSize.width *newImgSize.height != 0 ? newImgSize : imgSize;
1411
1411
1412
1412
Mat cameraMatrix = _cameraMatrix.getMat (), M;
@@ -1436,10 +1436,10 @@ cv::Mat cv::getOptimalNewCameraMatrix( InputArray _cameraMatrix, InputArray _dis
1436
1436
1437
1437
if ( validPixROI )
1438
1438
{
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));
1443
1443
Rect r (cvCeil (inner.x ), cvCeil (inner.y ), cvFloor (inner.width ), cvFloor (inner.height ));
1444
1444
r &= Rect (0 , 0 , newImgSize.width , newImgSize.height );
1445
1445
*validPixROI = r;
0 commit comments