Move OpenVX integrations to imgproc to OpenVX HAL

Covered functions:
- medianBlur
- Sobel
- Canny
- pyrDown
- BoxFilter
- equalizeHist
- GaussianBlur
- remap
- threshold
This commit is contained in:
Alexander Smorkalov
2025-02-12 09:54:45 +03:00
committed by Alexander Smorkalov
parent 36a5176a5f
commit acc9084044
12 changed files with 728 additions and 676 deletions

View File

@@ -45,8 +45,6 @@
#include "opencv2/core/hal/intrin.hpp"
#include <deque>
#include "opencv2/core/openvx/ovx_defs.hpp"
namespace cv
{
@@ -761,65 +759,6 @@ private:
finalPass& operator=(const finalPass&); // = delete
};
#ifdef HAVE_OPENVX
namespace ovx {
template <> inline bool skipSmallImages<VX_KERNEL_CANNY_EDGE_DETECTOR>(int w, int h) { return w*h < 640 * 480; }
}
static bool openvx_canny(const Mat& src, Mat& dst, int loVal, int hiVal, int kSize, bool useL2)
{
using namespace ivx;
Context context = ovx::getOpenVXContext();
try
{
Image _src = Image::createFromHandle(
context,
Image::matTypeToFormat(src.type()),
Image::createAddressing(src),
src.data );
Image _dst = Image::createFromHandle(
context,
Image::matTypeToFormat(dst.type()),
Image::createAddressing(dst),
dst.data );
Threshold threshold = Threshold::createRange(context, VX_TYPE_UINT8, saturate_cast<uchar>(loVal), saturate_cast<uchar>(hiVal));
#if 0
// the code below is disabled because vxuCannyEdgeDetector()
// ignores context attribute VX_CONTEXT_IMMEDIATE_BORDER
// FIXME: may fail in multithread case
border_t prevBorder = context.immediateBorder();
context.setImmediateBorder(VX_BORDER_REPLICATE);
IVX_CHECK_STATUS( vxuCannyEdgeDetector(context, _src, threshold, kSize, (useL2 ? VX_NORM_L2 : VX_NORM_L1), _dst) );
context.setImmediateBorder(prevBorder);
#else
// alternative code without vxuCannyEdgeDetector()
Graph graph = Graph::create(context);
ivx::Node node = ivx::Node(vxCannyEdgeDetectorNode(graph, _src, threshold, kSize, (useL2 ? VX_NORM_L2 : VX_NORM_L1), _dst) );
node.setBorder(VX_BORDER_REPLICATE);
graph.verify();
graph.process();
#endif
#ifdef VX_VERSION_1_1
_src.swapHandle();
_dst.swapHandle();
#endif
}
catch(const WrapperError& e)
{
VX_DbgThrow(e.what());
}
catch(const RuntimeError& e)
{
VX_DbgThrow(e.what());
}
return true;
}
#endif // HAVE_OPENVX
void Canny( InputArray _src, OutputArray _dst,
double low_thresh, double high_thresh,
int aperture_size, bool L2gradient )
@@ -864,21 +803,6 @@ void Canny( InputArray _src, OutputArray _dst,
CALL_HAL(canny, cv_hal_canny, src.data, src.step, dst.data, dst.step, src.cols, src.rows, src.channels(),
low_thresh, high_thresh, aperture_size, L2gradient);
CV_OVX_RUN(
false && /* disabling due to accuracy issues */
src.type() == CV_8UC1 &&
!src.isSubmatrix() &&
src.cols >= aperture_size &&
src.rows >= aperture_size &&
!ovx::skipSmallImages<VX_KERNEL_CANNY_EDGE_DETECTOR>(src.cols, src.rows),
openvx_canny(
src,
dst,
cvFloor(low_thresh),
cvFloor(high_thresh),
aperture_size,
L2gradient ) )
CV_IPP_RUN_FAST(ipp_Canny(src, Mat(), Mat(), dst, (float)low_thresh, (float)high_thresh, L2gradient, aperture_size))
if (L2gradient)