| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,9 +16,9 @@ | |||
| 16 | 16 | #include <af/dim4.hpp> | |
| 17 | 17 | ||
| 18 | 18 | #include <array> | |
| 19 | - #include <cfloat> | ||
| 20 | 19 | #include <cmath> | |
| 21 | 20 | #include <cstring> | |
| 21 | + #include <limits> | ||
| 22 | 22 | #include <vector> | |
| 23 | 23 | ||
| 24 | 24 | using af::dim4; | |
@@ -27,6 +27,7 @@ using std::array; | |||
| 27 | 27 | using std::log; | |
| 28 | 28 | using std::max; | |
| 29 | 29 | using std::min; | |
| 30 | + using std::numeric_limits; | ||
| 30 | 31 | using std::pow; | |
| 31 | 32 | using std::round; | |
| 32 | 33 | using std::sqrt; | |
@@ -47,17 +48,17 @@ static const float LMEDSOutlierRatio = 0.4f; | |||
| 47 | 48 | ||
| 48 | 49 | template<typename T> | |
| 49 | 50 | struct EPS { | |
| 50 | - T eps() { return FLT_EPSILON; } | ||
| 51 | + T eps() { return numeric_limits<float>::epsilon(); } | ||
| 51 | 52 | }; | |
| 52 | 53 | ||
| 53 | 54 | template<> | |
| 54 | 55 | struct EPS<float> { | |
| 55 | - static float eps() { return FLT_EPSILON; } | ||
| 56 | + static float eps() { return numeric_limits<float>::epsilon(); } | ||
| 56 | 57 | }; | |
| 57 | 58 | ||
| 58 | 59 | template<> | |
| 59 | 60 | struct EPS<double> { | |
| 60 | - static double eps() { return DBL_EPSILON; } | ||
| 61 | + static double eps() { return numeric_limits<double>::epsilon(); } | ||
| 61 | 62 | }; | |
| 62 | 63 | ||
| 63 | 64 | template<typename T, int M, int N> | |
@@ -138,7 +139,7 @@ unsigned updateIterations(float inlier_ratio, unsigned iter) { | |||
| 138 | 139 | float wn = pow(1 - w, 4.f); | |
| 139 | 140 | ||
| 140 | 141 | float d = 1.f - wn; | |
| 141 | - if (d < FLT_MIN) { return 0; } | ||
| 142 | + if (d < numeric_limits<float>::min()) { return 0; } | ||
| 142 | 143 | ||
| 143 | 144 | d = log(d); | |
| 144 | 145 | ||
@@ -284,7 +285,7 @@ int findBestHomography(Array<T>& bestH, const Array<float>& x_src, | |||
| 284 | 285 | unsigned iter = iterations; | |
| 285 | 286 | unsigned bestIdx = 0; | |
| 286 | 287 | int bestInliers = 0; | |
| 287 | - float minMedian = FLT_MAX; | ||
| 288 | + float minMedian = numeric_limits<float>::max(); | ||
| 288 | 289 | ||
| 289 | 290 | for (unsigned i = 0; i < iter; i++) { | |
| 290 | 291 | const unsigned Hidx = Hdims[0] * i; | |
@@ -344,7 +345,8 @@ int findBestHomography(Array<T>& bestH, const Array<float>& x_src, | |||
| 344 | 345 | median = (median + err[nsamples / 2 - 1]) * 0.5f; | |
| 345 | 346 | } | |
| 346 | 347 | ||
| 347 | - if (median < minMedian && median > FLT_EPSILON) { | ||
| 348 | + if (median < minMedian && | ||
| 349 | + median > numeric_limits<float>::epsilon()) { | ||
| 348 | 350 | minMedian = median; | |
| 349 | 351 | bestIdx = i; | |
| 350 | 352 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,8 +20,8 @@ | |||
| 20 | 20 | #include <resize.hpp> | |
| 21 | 21 | #include <sort_index.hpp> | |
| 22 | 22 | ||
| 23 | - #include <cfloat> | ||
| 24 | 23 | #include <cstring> | |
| 24 | + #include <limits> | ||
| 25 | 25 | #include <vector> | |
| 26 | 26 | ||
| 27 | 27 | using af::dim4; | |
@@ -330,8 +330,9 @@ void interpolateExtrema(float* x_out, float* y_out, unsigned* layer_out, | |||
| 330 | 330 | float det = dxx * dyy - dxy * dxy; | |
| 331 | 331 | ||
| 332 | 332 | // add FLT_EPSILON for double-precision compatibility | |
| 333 | - if (det <= 0 || tr * tr * edge_thr >= | ||
| 334 | - (edge_thr + 1) * (edge_thr + 1) * det + FLT_EPSILON) | ||
| 333 | + if (det <= 0 || | ||
| 334 | + tr * tr * edge_thr >= (edge_thr + 1) * (edge_thr + 1) * det + | ||
| 335 | + std::numeric_limits<float>::epsilon()) | ||
| 335 | 336 | continue; | |
| 336 | 337 | ||
| 337 | 338 | if (*counter < max_feat) { | |
@@ -692,7 +693,7 @@ void computeGLOHDescriptor(float* desc_out, const unsigned desc_len, | |||
| 692 | 693 | (float)(GLOHRadii[1] - GLOHRadii[0]) | |
| 693 | 694 | : min(2 + (r - GLOHRadii[1]) / | |
| 694 | 695 | (float)(GLOHRadii[2] - GLOHRadii[1]), | |
| 695 | - 3.f - FLT_EPSILON)); | ||
| 696 | + 3.f - std::numeric_limits<float>::epsilon())); | ||
| 696 | 697 | ||
| 697 | 698 | if (r <= GLOHRadii[rb - 1] && y > 0 && y < idims[0] - 1 && x > 0 && | |
| 698 | 699 | x < idims[1] - 1) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,7 +14,7 @@ | |||
| 14 | 14 | #include <af/dim4.hpp> | |
| 15 | 15 | #include <algorithm> | |
| 16 | 16 | ||
| 17 | - #include <cfloat> | ||
| 17 | + #include <limits> | ||
| 18 | 18 | ||
| 19 | 19 | using af::dim4; | |
| 20 | 20 | ||
@@ -39,7 +39,8 @@ int homography(Array<T> &bestH, const Array<float> &x_src, | |||
| 39 | 39 | iter = ::std::min( | |
| 40 | 40 | iter, (unsigned)(log(1.f - LMEDSConfidence) / | |
| 41 | 41 | log(1.f - pow(1.f - LMEDSOutlierRatio, 4.f)))); | |
| 42 | - err = createValueArray<float>(af::dim4(nsamples, iter), FLT_MAX); | ||
| 42 | + err = createValueArray<float>(af::dim4(nsamples, iter), | ||
| 43 | + std::numeric_limits<float>::max()); | ||
| 43 | 44 | } | |
| 44 | 45 | ||
| 45 | 46 | af::dim4 rdims(4, iter); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,8 +14,10 @@ | |||
| 14 | 14 | #include <af/dim4.hpp> | |
| 15 | 15 | ||
| 16 | 16 | #include <algorithm> | |
| 17 | + #include <limits> | ||
| 17 | 18 | ||
| 18 | 19 | using af::dim4; | |
| 20 | + using std::numeric_limits; | ||
| 19 | 21 | ||
| 20 | 22 | namespace opencl { | |
| 21 | 23 | ||
@@ -39,7 +41,8 @@ int homography(Array<T> &bestH, const Array<float> &x_src, | |||
| 39 | 41 | ::std::min(iter, static_cast<unsigned>( | |
| 40 | 42 | log(1.f - LMEDSConfidence) / | |
| 41 | 43 | log(1.f - pow(1.f - LMEDSOutlierRatio, 4.f)))); | |
| 42 | - err = createValueArray<float>(af::dim4(nsamples, iter), FLT_MAX); | ||
| 44 | + err = createValueArray<float>(af::dim4(nsamples, iter), | ||
| 45 | + numeric_limits<float>::max()); | ||
| 43 | 46 | } else { | |
| 44 | 47 | // Avoid passing "null" cl_mem object to kernels | |
| 45 | 48 | err = createEmptyArray<float>(af::dim4(1)); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,6 +19,7 @@ | |||
| 19 | 19 | #include <memory.hpp> | |
| 20 | 20 | #include <af/defines.h> | |
| 21 | 21 | ||
| 22 | + #include <limits> | ||
| 22 | 23 | #include <string> | |
| 23 | 24 | #include <vector> | |
| 24 | 25 | ||
@@ -36,8 +37,10 @@ std::array<Kernel, 5> getHomographyKernels(const af_homography_type htype) { | |||
| 36 | 37 | DefineKeyValue(T, dtype_traits<T>::getName()), | |
| 37 | 38 | }; | |
| 38 | 39 | options.emplace_back(getTypeBuildDefinition<T>()); | |
| 39 | - options.emplace_back(DefineKeyValue( | ||
| 40 | - EPS, (std::is_same<T, double>::value ? DBL_EPSILON : FLT_EPSILON))); | ||
| 40 | + options.emplace_back( | ||
| 41 | + DefineKeyValue(EPS, (std::is_same<T, double>::value | ||
| 42 | + ? std::numeric_limits<double>::epsilon() | ||
| 43 | + : std::numeric_limits<float>::epsilon()))); | ||
| 41 | 44 | if (htype == AF_HOMOGRAPHY_RANSAC) { | |
| 42 | 45 | options.emplace_back(DefineKey(RANSAC)); | |
| 43 | 46 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments