mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 19:20:28 +08:00
Merge pull request #14411 from ostarling:3.4_fix_for_14242
* Fix for Homogenous precision #14242: - moved scale computation to an inline function - use std::numeric_limits<float>::epsilon() instead of != 0.0 * Fix for Homogenous precision #14242: - fixed warnings for type conversion * Fix for Homogenous precision #14242: - use float epsilon() for truncation of doubles
This commit is contained in:
parent
84847cf4c3
commit
643d9df42d
@ -909,6 +909,14 @@ void cv::computeCorrespondEpilines( InputArray _points, int whichImage,
|
||||
}
|
||||
}
|
||||
|
||||
static inline double scaleFor(double x){
|
||||
return (std::fabs(x) > std::numeric_limits<float>::epsilon()) ? 1./x : 1.;
|
||||
}
|
||||
static inline float scaleFor(float x){
|
||||
return (std::fabs(x) > std::numeric_limits<float>::epsilon()) ? 1.f/x : 1.f;
|
||||
}
|
||||
|
||||
|
||||
void cv::convertPointsFromHomogeneous( InputArray _src, OutputArray _dst )
|
||||
{
|
||||
CV_INSTRUMENT_REGION();
|
||||
@ -967,7 +975,7 @@ void cv::convertPointsFromHomogeneous( InputArray _src, OutputArray _dst )
|
||||
Point2f* dptr = dst.ptr<Point2f>();
|
||||
for( i = 0; i < npoints; i++ )
|
||||
{
|
||||
float scale = sptr[i].z != 0.f ? 1.f/sptr[i].z : 1.f;
|
||||
float scale = scaleFor(sptr[i].z);
|
||||
dptr[i] = Point2f(sptr[i].x*scale, sptr[i].y*scale);
|
||||
}
|
||||
}
|
||||
@ -977,7 +985,7 @@ void cv::convertPointsFromHomogeneous( InputArray _src, OutputArray _dst )
|
||||
Point3f* dptr = dst.ptr<Point3f>();
|
||||
for( i = 0; i < npoints; i++ )
|
||||
{
|
||||
float scale = sptr[i][3] != 0.f ? 1.f/sptr[i][3] : 1.f;
|
||||
float scale = scaleFor(sptr[i][3]);
|
||||
dptr[i] = Point3f(sptr[i][0]*scale, sptr[i][1]*scale, sptr[i][2]*scale);
|
||||
}
|
||||
}
|
||||
@ -990,7 +998,7 @@ void cv::convertPointsFromHomogeneous( InputArray _src, OutputArray _dst )
|
||||
Point2d* dptr = dst.ptr<Point2d>();
|
||||
for( i = 0; i < npoints; i++ )
|
||||
{
|
||||
double scale = sptr[i].z != 0. ? 1./sptr[i].z : 1.;
|
||||
double scale = scaleFor(sptr[i].z);
|
||||
dptr[i] = Point2d(sptr[i].x*scale, sptr[i].y*scale);
|
||||
}
|
||||
}
|
||||
@ -1000,7 +1008,7 @@ void cv::convertPointsFromHomogeneous( InputArray _src, OutputArray _dst )
|
||||
Point3d* dptr = dst.ptr<Point3d>();
|
||||
for( i = 0; i < npoints; i++ )
|
||||
{
|
||||
double scale = sptr[i][3] != 0.f ? 1./sptr[i][3] : 1.;
|
||||
double scale = scaleFor(sptr[i][3]);
|
||||
dptr[i] = Point3d(sptr[i][0]*scale, sptr[i][1]*scale, sptr[i][2]*scale);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user