Skip to content

Commit 922ac1a

Browse files
authored
Merge pull request opencv#9303 from alalek:akaze_update
2 parents c95a973 + 2a8322d commit 922ac1a

File tree

14 files changed

+326
-299
lines changed

14 files changed

+326
-299
lines changed

modules/core/include/opencv2/core/utility.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,23 @@ static inline size_t alignSize(size_t sz, int n)
444444
return (sz + n-1) & -n;
445445
}
446446

447+
/** @brief Integer division with result round up.
448+
449+
Use this function instead of `ceil((float)a / b)` expressions.
450+
451+
@sa alignSize
452+
*/
453+
static inline int divUp(int a, unsigned int b)
454+
{
455+
CV_DbgAssert(a >= 0);
456+
return (a + b - 1) / b;
457+
}
458+
/** @overload */
459+
static inline size_t divUp(size_t a, unsigned int b)
460+
{
461+
return (a + b - 1) / b;
462+
}
463+
447464
/** @brief Enables or disables the optimized code.
448465
449466
The function can be used to dynamically turn on and off optimized code (code that uses SSE2, AVX,

modules/core/src/matrix.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3406,11 +3406,6 @@ static TransposeInplaceFunc transposeInplaceTab[] =
34063406

34073407
#ifdef HAVE_OPENCL
34083408

3409-
static inline int divUp(int a, int b)
3410-
{
3411-
return (a + b - 1) / b;
3412-
}
3413-
34143409
static bool ocl_transpose( InputArray _src, OutputArray _dst )
34153410
{
34163411
const ocl::Device & dev = ocl::Device::getDefault();

modules/features2d/src/akaze.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ namespace cv
113113
if (descriptor_size == 0)
114114
{
115115
int t = (6 + 36 + 120) * descriptor_channels;
116-
return (int)ceil(t / 8.);
116+
return divUp(t, 8);
117117
}
118118
else
119119
{
120120
// We use the random bit selection length binary descriptor
121-
return (int)ceil(descriptor_size / 8.);
121+
return divUp(descriptor_size, 8);
122122
}
123123

124124
default:

0 commit comments

Comments
 (0)