diff --git a/modules/core/src/hal_replacement.hpp b/modules/core/src/hal_replacement.hpp index f78608dbad..67f3ac7141 100644 --- a/modules/core/src/hal_replacement.hpp +++ b/modules/core/src/hal_replacement.hpp @@ -899,6 +899,27 @@ inline int hal_ni_meanStdDev(const uchar* src_data, size_t src_step, int width, #define cv_hal_meanStdDev hal_ni_meanStdDev //! @endcond +/** + * @brief calculates dot product of two vectors (represented as 2d images) + * + * @param a_data Pointer to 1st 2nd image data + * @param a_step Stride of 1st 2nd image + * @param b_data Pointer to 1st 2nd image data + * @param b_step Stride of 1st 2nd image + * @param width Width of both images + * @param height Height of both images + * @param type Data type of both images, for example CV_8U or CV_32F + * @param dot_val Pointer to resulting dot product value + * @return int + */ +inline int hal_ni_dotProduct(const uchar* a_data, size_t a_step, const uchar* b_data, size_t b_step, int width, int height, + int type, double *dot_val) +{ return CV_HAL_ERROR_NOT_IMPLEMENTED; } + +//! @cond IGNORED +#define cv_hal_dotProduct hal_ni_dotProduct +//! @endcond + /** @brief hal_flip @param src_type source and destination image type diff --git a/modules/core/src/matmul.dispatch.cpp b/modules/core/src/matmul.dispatch.cpp index 81953265d7..35b7ad54c4 100644 --- a/modules/core/src/matmul.dispatch.cpp +++ b/modules/core/src/matmul.dispatch.cpp @@ -995,9 +995,18 @@ double Mat::dot(InputArray _mat) const CV_INSTRUMENT_REGION(); Mat mat = _mat.getMat(); + CV_Assert_N( mat.type() == type(), mat.size == size); + int cn = channels(); + if (this->dims <= 2) + { + double product = 0; + CALL_HAL_RET(dotProduct, cv_hal_dotProduct, product, this->data, this->step, mat.data, mat.step, + this->cols * cn, this->rows, this->depth()); + } + DotProdFunc func = getDotProdFunc(depth()); - CV_Assert_N( mat.type() == type(), mat.size == size, func != 0 ); + CV_Assert(func != 0 ); if( isContinuous() && mat.isContinuous() ) {