Skip to content

Commit 4a4d94f

Browse files
mschoeneckalalek
authored andcommitted
Merge pull request opencv#8694 from mschoeneck:Canny
Parallelize Canny with custom gradient (opencv#8694) * New Canny implementation. Restructuring code in parallelCanny class. Align mag buffer and map. * Fix warnings. * Missing SIMD check added. * Replaced local trailingZeros in contours.cpp. Use alignSize in canny.cpp * Fix warnings in alignSize and allocate just minimum extra columns. * Fix another warning in map.create. * Exchange for loop by do loop to avoid double check at the beginning. Define extra SIMD CANNY_CHECK to avoid unnecessary continue.
1 parent 2e056fb commit 4a4d94f

File tree

3 files changed

+498
-692
lines changed

3 files changed

+498
-692
lines changed

modules/core/include/opencv2/core/hal/intrin.hpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,29 @@ template <> struct V_RegTrait128<double> {
433433
};
434434
#endif
435435

436+
inline unsigned int trailingZeros32(unsigned int value) {
437+
#if defined(_MSC_VER)
438+
#if (_MSC_VER < 1700)
439+
unsigned long index = 0;
440+
_BitScanForward(&index, value);
441+
return (unsigned int)index;
442+
#else
443+
return _tzcnt_u32(value);
444+
#endif
445+
#elif defined(__GNUC__) || defined(__GNUG__)
446+
return __builtin_ctz(value);
447+
#elif defined(__ICC) || defined(__INTEL_COMPILER)
448+
return _bit_scan_forward(value);
449+
#elif defined(__clang__)
450+
return llvm.cttz.i32(value, true);
451+
#else
452+
static const int MultiplyDeBruijnBitPosition[32] = {
453+
0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
454+
31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 };
455+
return MultiplyDeBruijnBitPosition[((uint32_t)((value & -value) * 0x077CB531U)) >> 27];
456+
#endif
457+
}
458+
436459
#ifndef CV_DOXYGEN
437460
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
438461
#endif

0 commit comments

Comments
 (0)