mirror of https://github.com/opencv/opencv.git
Merge pull request #26143 from asmorkalov:as/HAL_opticalFlowLK
Added HAL interface for Lukas-Kanade optical flow #26143 ### 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 CMakepull/25569/head
parent
ee685017c3
commit
881440c6c6
5 changed files with 173 additions and 53 deletions
@ -0,0 +1,101 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
|
||||||
|
#ifndef OPENCV_VIDEO_HAL_REPLACEMENT_HPP |
||||||
|
#define OPENCV_VIDEO_HAL_REPLACEMENT_HPP |
||||||
|
|
||||||
|
#include "opencv2/core/hal/interface.h" |
||||||
|
|
||||||
|
#if defined(__clang__) // clang or MSVC clang
|
||||||
|
#pragma clang diagnostic push |
||||||
|
#pragma clang diagnostic ignored "-Wunused-parameter" |
||||||
|
#elif defined(_MSC_VER) |
||||||
|
#pragma warning(push) |
||||||
|
#pragma warning(disable : 4100) |
||||||
|
#elif defined(__GNUC__) |
||||||
|
#pragma GCC diagnostic push |
||||||
|
#pragma GCC diagnostic ignored "-Wunused-parameter" |
||||||
|
#endif |
||||||
|
|
||||||
|
//! @addtogroup video_hal_interface
|
||||||
|
//! @note Define your functions to override default implementations:
|
||||||
|
//! @code
|
||||||
|
//! #undef cv_hal_LK_optical_flow_level
|
||||||
|
//! #define cv_hal_LK_optical_flow_level my_hal_LK_optical_flow_level
|
||||||
|
//! @endcode
|
||||||
|
//! @{
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Lucas-Kanade optical flow for single pyramid layer. See calcOpticalFlowPyrLK |
||||||
|
@param prev_data previous frame image data |
||||||
|
@param prev_data_step previous frame image data step |
||||||
|
@param prev_deriv_data previous frame Schaar derivatives |
||||||
|
@param prev_deriv_step previous frame Schaar derivatives step |
||||||
|
@param next_data next frame image data |
||||||
|
@param next_step next frame image step |
||||||
|
@param width input images width |
||||||
|
@param height input images height |
||||||
|
@param cn source image channels |
||||||
|
@param prev_points 2d points coordinates (x,y) on the previous frame |
||||||
|
@param next_points points coordinates (x,y) on the next frame |
||||||
|
@param point_count - amount of input points |
||||||
|
@param status optical flow status for each point. Optional output, expected if not nullptr is provided |
||||||
|
@param err optical flow estimation error for each point. Optional output, expected if not nullptr is provided |
||||||
|
@param win_width optical flow window width |
||||||
|
@param win_height optical flow window heigh |
||||||
|
@param termination_count maximum algorithm iterations. 0 means unlimited |
||||||
|
@param termination_epsilon maximal allowed algorithm error |
||||||
|
@param get_min_eigen_vals return minimal egen values as point errors in err buffer |
||||||
|
@param min_eigen_vals_threshold eigen values threshold |
||||||
|
**/ |
||||||
|
inline int hal_ni_LKOpticalFlowLevel(const uchar *prev_data, size_t prev_data_step, |
||||||
|
const short* prev_deriv_data, size_t prev_deriv_step, |
||||||
|
const uchar* next_data, size_t next_step, |
||||||
|
int width, int height, int cn, |
||||||
|
const float *prev_points, float *next_points, size_t point_count, |
||||||
|
uchar *status, float *err, |
||||||
|
const int win_width, const int win_height, |
||||||
|
int termination_count, double termination_epsilon, |
||||||
|
bool get_min_eigen_vals, |
||||||
|
float min_eigen_vals_threshold) |
||||||
|
{ |
||||||
|
return CV_HAL_ERROR_NOT_IMPLEMENTED; |
||||||
|
} |
||||||
|
|
||||||
|
//! @cond IGNORED
|
||||||
|
#define cv_hal_LKOpticalFlowLevel hal_ni_LKOpticalFlowLevel |
||||||
|
//! @endcond
|
||||||
|
|
||||||
|
//! @}
|
||||||
|
|
||||||
|
#if defined(__clang__) |
||||||
|
#pragma clang diagnostic pop |
||||||
|
#elif defined(_MSC_VER) |
||||||
|
#pragma warning(pop) |
||||||
|
#elif defined(__GNUC__) |
||||||
|
#pragma GCC diagnostic pop |
||||||
|
#endif |
||||||
|
|
||||||
|
#include "custom_hal.hpp" |
||||||
|
|
||||||
|
//! @cond IGNORED
|
||||||
|
#define CALL_HAL_RET(name, fun, retval, ...) \ |
||||||
|
int res = __CV_EXPAND(fun(__VA_ARGS__, &retval)); \
|
||||||
|
if (res == CV_HAL_ERROR_OK) \
|
||||||
|
return retval; \
|
||||||
|
else if (res != CV_HAL_ERROR_NOT_IMPLEMENTED) \
|
||||||
|
CV_Error_(cv::Error::StsInternal, \
|
||||||
|
("HAL implementation " CVAUX_STR(name) " ==> " CVAUX_STR(fun) " returned %d (0x%08x)", res, res)); |
||||||
|
|
||||||
|
|
||||||
|
#define CALL_HAL(name, fun, ...) \ |
||||||
|
int res = __CV_EXPAND(fun(__VA_ARGS__)); \
|
||||||
|
if (res == CV_HAL_ERROR_OK) \
|
||||||
|
return; \
|
||||||
|
else if (res != CV_HAL_ERROR_NOT_IMPLEMENTED) \
|
||||||
|
CV_Error_(cv::Error::StsInternal, \
|
||||||
|
("HAL implementation " CVAUX_STR(name) " ==> " CVAUX_STR(fun) " returned %d (0x%08x)", res, res)); |
||||||
|
//! @endcond
|
||||||
|
|
||||||
|
#endif |
Loading…
Reference in new issue