Skip to content

Commit a6ec12f

Browse files
authored
Merge pull request opencv#26163 from asmorkalov:as/HAL_schaar_deriv
HAL interface for Sharr derivatives needed for Lukas-Kanade algorithm opencv#26163 ### 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 - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
1 parent b2e118e commit a6ec12f

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

3rdparty/carotene/hal/tegra_hal.hpp

+16
Original file line numberDiff line numberDiff line change
@@ -1962,4 +1962,20 @@ inline int TEGRA_LKOpticalFlowLevel(const uchar *prev_data, size_t prev_data_ste
19621962
#define cv_hal_LKOpticalFlowLevel TEGRA_LKOpticalFlowLevel
19631963
#endif // __ARM_ARCH=7
19641964

1965+
#if 0 // OpenCV provides fater parallel implementation
1966+
inline int TEGRA_ScharrDeriv(const uchar* src_data, size_t src_step,
1967+
short* dst_data, size_t dst_step,
1968+
int width, int height, int cn)
1969+
{
1970+
if (!CAROTENE_NS::isSupportedConfiguration())
1971+
return CV_HAL_ERROR_NOT_IMPLEMENTED;
1972+
1973+
CAROTENE_NS::ScharrDeriv(CAROTENE_NS::Size2D(width, height), cn, src_data, src_step, dst_data, dst_step);
1974+
return CV_HAL_ERROR_OK;
1975+
}
1976+
1977+
#undef cv_hal_ScharrDeriv
1978+
#define cv_hal_ScharrDeriv TEGRA_ScharrDeriv
1979+
#endif
1980+
19651981
#endif

modules/video/src/hal_replacement.hpp

+21
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,27 @@ inline int hal_ni_LKOpticalFlowLevel(const uchar *prev_data, size_t prev_data_st
6767
#define cv_hal_LKOpticalFlowLevel hal_ni_LKOpticalFlowLevel
6868
//! @endcond
6969

70+
/**
71+
@brief Computes Schaar derivatives with inteleaved layout xyxy...
72+
@param src_data source image data
73+
@param src_step source image step
74+
@param dst_data destination buffer data
75+
@param dst_step destination buffer step
76+
@param width image width
77+
@param height image height
78+
@param cn source image channels
79+
**/
80+
inline int hal_ni_ScharrDeriv(const uchar* src_data, size_t src_step,
81+
short* dst_data, size_t dst_step,
82+
int width, int height, int cn)
83+
{
84+
return CV_HAL_ERROR_NOT_IMPLEMENTED;
85+
}
86+
87+
//! @cond IGNORED
88+
#define cv_hal_ScharrDeriv hal_ni_ScharrDeriv
89+
//! @endcond
90+
7091
//! @}
7192

7293
#if defined(__clang__)

modules/video/src/lkpyramid.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ static void calcScharrDeriv(const cv::Mat& src, cv::Mat& dst)
6363
int rows = src.rows, cols = src.cols, cn = src.channels(), depth = src.depth();
6464
CV_Assert(depth == CV_8U);
6565
dst.create(rows, cols, CV_MAKETYPE(DataType<deriv_type>::depth, cn*2));
66+
67+
CALL_HAL(ScharrDeriv, cv_hal_ScharrDeriv, src.data, src.step, (short*)dst.data, dst.step, cols, rows, cn);
68+
6669
parallel_for_(Range(0, rows), cv::detail::ScharrDerivInvoker(src, dst), cv::getNumThreads());
6770
}
6871

0 commit comments

Comments
 (0)