Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 12e2cc9

Browse files
authored
Merge pull request #25491 from savuor:rv/hal_norm_hamming
HAL for Hamming norm added #25491 fixes #25474 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
1 parent 357b9ab commit 12e2cc9

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

modules/core/src/hal_replacement.hpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,36 @@ inline int hal_ni_not8u(const uchar *src_data, size_t src_step, uchar *dst_data,
214214
#define cv_hal_not8u hal_ni_not8u
215215
//! @endcond
216216

217+
/**
218+
Hamming norm of a vector
219+
@param a pointer to vector data
220+
@param n length of a vector
221+
@param cellSize how many bits of the vector will be added and treated as a single bit, can be 1 (standard Hamming distance), 2 or 4
222+
@param result pointer to result output
223+
*/
224+
//! @addtogroup core_hal_interface_hamming Hamming distance
225+
//! @{
226+
inline int hal_ni_normHamming8u(const uchar* a, int n, int cellSize, int* result) { return CV_HAL_ERROR_NOT_IMPLEMENTED; }
227+
//! @}
228+
229+
/**
230+
Hamming distance between two vectors
231+
@param a pointer to first vector data
232+
@param b pointer to second vector data
233+
@param n length of vectors
234+
@param cellSize how many bits of the vectors will be added and treated as a single bit, can be 1 (standard Hamming distance), 2 or 4
235+
@param result pointer to result output
236+
*/
237+
//! @addtogroup core_hal_interface_hamming Hamming distance
238+
//! @{
239+
inline int hal_ni_normHammingDiff8u(const uchar* a, const uchar* b, int n, int cellSize, int* result) { return CV_HAL_ERROR_NOT_IMPLEMENTED; }
240+
//! @}
241+
242+
//! @cond IGNORED
243+
#define cv_hal_normHamming8u hal_ni_normHamming8u
244+
#define cv_hal_normHammingDiff8u hal_ni_normHammingDiff8u
245+
//! @endcond
246+
217247
/**
218248
Compare: _dst[i] = src1[i] op src2[i]_
219249
@param src1_data first source image data

modules/core/src/norm.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ static const uchar popCountTable4[] =
5252

5353
int normHamming(const uchar* a, int n, int cellSize)
5454
{
55+
int output;
56+
CALL_HAL_RET(normHamming8u, cv_hal_normHamming8u, output, a, n, cellSize);
57+
5558
if( cellSize == 1 )
5659
return normHamming(a, n);
5760
const uchar* tab = 0;
@@ -98,6 +101,9 @@ int normHamming(const uchar* a, int n, int cellSize)
98101

99102
int normHamming(const uchar* a, const uchar* b, int n, int cellSize)
100103
{
104+
int output;
105+
CALL_HAL_RET(normHammingDiff8u, cv_hal_normHammingDiff8u, output, a, b, n, cellSize);
106+
101107
if( cellSize == 1 )
102108
return normHamming(a, b, n);
103109
const uchar* tab = 0;

0 commit comments

Comments
 (0)