Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitacc9084

Browse files
committed
Move OpenVX integrations to imgproc to OpenVX HAL
Covered functions:- medianBlur- Sobel- Canny- pyrDown- BoxFilter- equalizeHist- GaussianBlur- remap- threshold
1 parent36a5176 commitacc9084

File tree

12 files changed

+728
-676
lines changed

12 files changed

+728
-676
lines changed

‎3rdparty/openvx/hal/openvx_hal.cpp‎

Lines changed: 670 additions & 0 deletions
Large diffs are not rendered by default.

‎3rdparty/openvx/hal/openvx_hal.hpp‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,29 @@ int ovx_hal_meanStdDev(const uchar* src_data, size_t src_step, int width, int he
5959
intovx_hal_lut(const uchar *src_data,size_t src_step,size_t src_type,const uchar* lut_data,size_t lut_channel_size,size_t lut_channels, uchar *dst_data,size_t dst_step,int width,int height);
6060
intovx_hal_minMaxIdxMaskStep(const uchar* src_data,size_t src_step,int width,int height,int depth,
6161
double* minVal,double* maxVal,int* minIdx,int* maxIdx, uchar* mask,size_t mask_step);
62+
intovx_hal_medianBlur(const uchar* src_data,size_t src_step, uchar* dst_data,size_t dst_step,int width,int height,int depth,int cn,int ksize);
63+
intovx_hal_sobel(const uchar* src_data,size_t src_step, uchar* dst_data,size_t dst_step,int width,int height,int src_depth,int dst_depth,int cn,int margin_left,int margin_top,int margin_right,int margin_bottom,int dx,int dy,int ksize,double scale,double delta,int border_type);
64+
intovx_hal_canny(const uchar* src_data,size_t src_step, uchar* dst_data,size_t dst_step,
65+
int width,int height,int cn,double lowThreshold,double highThreshold,int ksize,bool L2gradient);
66+
intovx_hal_pyrdown(const uchar* src_data,size_t src_step,int src_width,int src_height,
67+
uchar* dst_data,size_t dst_step,int dst_width,int dst_height,int depth,int cn,int border_type);
68+
intovx_hal_boxFilter(const uchar* src_data,size_t src_step, uchar* dst_data,size_t dst_step,
69+
int width,int height,int src_depth,int dst_depth,int cn,
70+
int margin_left,int margin_top,int margin_right,int margin_bottom,
71+
size_t ksize_width,size_t ksize_height,int anchor_x,int anchor_y,bool normalize,int border_type);
72+
intovx_hal_equalize_hist(const uchar* src_data,size_t src_step, uchar* dst_data,size_t dst_step,int width,int height);
73+
intovx_hal_gaussianBlur(const uchar* src_data,size_t src_step, uchar* dst_data,size_t dst_step,int width,int height,
74+
int depth,int cn,size_t margin_left,size_t margin_top,size_t margin_right,size_t margin_bottom,
75+
size_t ksize_width,size_t ksize_height,double sigmaX,double sigmaY,int border_type);
76+
intovx_hal_remap32f(int src_type,const uchar *src_data,size_t src_step,int src_width,int src_height,
77+
uchar *dst_data,size_t dst_step,int dst_width,int dst_height,
78+
float* mapx,size_t mapx_step,float* mapy,size_t mapy_step,
79+
int interpolation,int border_type,constdouble border_value[4]);
80+
intovx_hal_threshold(const uchar* src_data,size_t src_step, uchar* dst_data,size_t dst_step,
81+
int width,int height,int depth,int cn,double thresh,double maxValue,int thresholdType);
6282
intovx_hal_FAST(const uchar* src_data,size_t src_step,int width,int height, uchar* keypoints_data,size_t* keypoints_count,
6383
int threshold,bool nonmax_suppression,int/*cv::FastFeatureDetector::DetectorType*/ dtype);
84+
6485
//==================================================================================================
6586
// functions redefinition
6687
// ...
@@ -153,6 +174,5 @@ int ovx_hal_FAST(const uchar* src_data, size_t src_step, int width, int height,
153174
#definecv_hal_lut ovx_hal_lut
154175
#undef cv_hal_minMaxIdxMaskStep
155176
#definecv_hal_minMaxIdxMaskStep ovx_hal_minMaxIdxMaskStep
156-
#definecv_hal_FAST ovx_hal_FAST
157177

158178
#endif

‎3rdparty/openvx/include/ivx.hpp‎

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,6 +1717,22 @@ static const vx_enum
17171717
#endif
17181718
}
17191719

1720+
/// Convert cv::Mat type to standard image format (fourcc), throws WrapperError if not possible
1721+
static vx_df_imagematTypeToFormat(int matType)
1722+
{
1723+
switch (matType)
1724+
{
1725+
case CV_8UC4:return VX_DF_IMAGE_RGBX;
1726+
case CV_8UC3:return VX_DF_IMAGE_RGB;
1727+
case CV_8UC1:return VX_DF_IMAGE_U8;
1728+
case CV_16UC1:return VX_DF_IMAGE_U16;
1729+
case CV_16SC1:return VX_DF_IMAGE_S16;
1730+
case CV_32SC1:return VX_DF_IMAGE_S32;
1731+
case CV_32FC1:returnVX_DF_IMAGE('F','0','3','2');
1732+
default:throwWrapperError(std::string(__func__)+"(): unsupported cv::Mat type");
1733+
}
1734+
}
1735+
17201736
#ifdef IVX_USE_OPENCV
17211737
/// Convert image format (fourcc) to cv::Mat type, throws WrapperError if not possible
17221738
staticintformatToMatType(vx_df_image format, vx_uint32 planeIdx =0)
@@ -1742,22 +1758,6 @@ static const vx_enum
17421758
}
17431759
}
17441760

1745-
/// Convert cv::Mat type to standard image format (fourcc), throws WrapperError if not possible
1746-
static vx_df_imagematTypeToFormat(int matType)
1747-
{
1748-
switch (matType)
1749-
{
1750-
case CV_8UC4:return VX_DF_IMAGE_RGBX;
1751-
case CV_8UC3:return VX_DF_IMAGE_RGB;
1752-
case CV_8UC1:return VX_DF_IMAGE_U8;
1753-
case CV_16UC1:return VX_DF_IMAGE_U16;
1754-
case CV_16SC1:return VX_DF_IMAGE_S16;
1755-
case CV_32SC1:return VX_DF_IMAGE_S32;
1756-
case CV_32FC1:returnVX_DF_IMAGE('F','0','3','2');
1757-
default:throwWrapperError(std::string(__func__)+"(): unsupported cv::Mat type");
1758-
}
1759-
}
1760-
17611761
/// Initialize cv::Mat shape to fit the specified image plane data
17621762
voidcreateMatForPlane(cv::Mat& m, vx_uint32 planeIdx)
17631763
{
@@ -3177,6 +3177,27 @@ class Remap : public RefWrapper<vx_remap>
31773177
voidgetMapping(vx_uint32 dst_x, vx_uint32 dst_y, vx_float32 &src_x, vx_float32 &src_y)const
31783178
{IVX_CHECK_STATUS(vxGetRemapPoint(ref, dst_x, dst_y, &src_x, &src_y)); }
31793179

3180+
voidsetMappings(vx_float32* map_x,size_t map_x_stride, vx_float32* map_y,size_t map_y_stride)
3181+
{
3182+
for (vx_uint32 y =0; y <dstHeight(); y++)
3183+
{
3184+
const vx_float32* map_x_line = (vx_float32*)((char*)map_x + y*map_x_stride);
3185+
const vx_float32* map_y_line = (vx_float32*)((char*)map_y + y*map_y_stride);
3186+
for (vx_uint32 x =0; x <dstWidth(); x++)
3187+
setMapping(x, y, map_x_line[x], map_y_line[x]);
3188+
}
3189+
}
3190+
3191+
voidsetMappings(vx_float32* map,size_t map_stride)
3192+
{
3193+
for (vx_uint32 y =0; y <dstHeight(); y++)
3194+
{
3195+
const vx_float32* map_line = (vx_float32*)((char*)map + y*map_stride);
3196+
for (vx_uint32 x =0; x <2*dstWidth(); x+=2)
3197+
setMapping(x, y, map_line[x], map_line[x+1]);
3198+
}
3199+
}
3200+
31803201
#ifdef IVX_USE_OPENCV
31813202
voidsetMappings(const cv::Mat& map_x,const cv::Mat& map_y)
31823203
{

‎modules/imgproc/src/box_filter.dispatch.cpp‎

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@
4848
#include"opencv2/core/hal/intrin.hpp"
4949
#include"opencl_kernels_imgproc.hpp"
5050

51-
#include"opencv2/core/openvx/ovx_defs.hpp"
52-
5351
#include"box_filter.simd.hpp"
5452
#include"box_filter.simd_declarations.hpp"// defines CV_CPU_DISPATCH_MODES_ALL=AVX2,...,BASELINE based on CMakeLists.txt content
5553

@@ -315,80 +313,6 @@ Ptr<FilterEngine> createBoxFilter(int srcType, int dstType, Size ksize,
315313
CV_CPU_DISPATCH_MODES_ALL);
316314
}
317315

318-
#ifdef HAVE_OPENVX
319-
namespaceovx {
320-
template<>inlinebool skipSmallImages<VX_KERNEL_BOX_3x3>(int w,int h) {return w*h <640 *480; }
321-
}
322-
staticboolopenvx_boxfilter(InputArray _src, OutputArray _dst,int ddepth,
323-
Size ksize, Point anchor,
324-
bool normalize,int borderType)
325-
{
326-
if (ddepth <0)
327-
ddepth = CV_8UC1;
328-
if (_src.type() != CV_8UC1 || ddepth != CV_8U || !normalize ||
329-
_src.cols() <3 || _src.rows() <3 ||
330-
ksize.width !=3 || ksize.height !=3 ||
331-
(anchor.x >=0 && anchor.x !=1) ||
332-
(anchor.y >=0 && anchor.y !=1) ||
333-
ovx::skipSmallImages<VX_KERNEL_BOX_3x3>(_src.cols(), _src.rows()))
334-
returnfalse;
335-
336-
Mat src = _src.getMat();
337-
338-
if ((borderType & BORDER_ISOLATED) ==0 && src.isSubmatrix())
339-
returnfalse;//Process isolated borders only
340-
vx_enum border;
341-
switch (borderType & ~BORDER_ISOLATED)
342-
{
343-
case BORDER_CONSTANT:
344-
border = VX_BORDER_CONSTANT;
345-
break;
346-
case BORDER_REPLICATE:
347-
border = VX_BORDER_REPLICATE;
348-
break;
349-
default:
350-
returnfalse;
351-
}
352-
353-
_dst.create(src.size(), CV_8UC1);
354-
Mat dst = _dst.getMat();
355-
356-
try
357-
{
358-
ivx::Context ctx =ovx::getOpenVXContext();
359-
360-
Mat a;
361-
if (dst.data != src.data)
362-
a = src;
363-
else
364-
src.copyTo(a);
365-
366-
ivx::Image
367-
ia =ivx::Image::createFromHandle(ctx, VX_DF_IMAGE_U8,
368-
ivx::Image::createAddressing(a.cols, a.rows,1, (vx_int32)(a.step)), a.data),
369-
ib =ivx::Image::createFromHandle(ctx, VX_DF_IMAGE_U8,
370-
ivx::Image::createAddressing(dst.cols, dst.rows,1, (vx_int32)(dst.step)), dst.data);
371-
372-
//ATTENTION: VX_CONTEXT_IMMEDIATE_BORDER attribute change could lead to strange issues in multi-threaded environments
373-
//since OpenVX standard says nothing about thread-safety for now
374-
ivx::border_t prevBorder = ctx.immediateBorder();
375-
ctx.setImmediateBorder(border, (vx_uint8)(0));
376-
ivx::IVX_CHECK_STATUS(vxuBox3x3(ctx, ia, ib));
377-
ctx.setImmediateBorder(prevBorder);
378-
}
379-
catch (const ivx::RuntimeError & e)
380-
{
381-
VX_DbgThrow(e.what());
382-
}
383-
catch (const ivx::WrapperError & e)
384-
{
385-
VX_DbgThrow(e.what());
386-
}
387-
388-
returntrue;
389-
}
390-
#endif
391-
392316
#if0 //defined(HAVE_IPP)
393317
static bool ipp_boxfilter(Mat &src, Mat &dst, Size ksize, Point anchor, bool normalize, int borderType)
394318
{
@@ -475,9 +399,6 @@ void boxFilter(InputArray _src, OutputArray _dst, int ddepth,
475399
ofs.x, ofs.y, wsz.width - src.cols - ofs.x, wsz.height - src.rows - ofs.y, ksize.width, ksize.height,
476400
anchor.x, anchor.y, normalize, borderType&~BORDER_ISOLATED);
477401

478-
CV_OVX_RUN(true,
479-
openvx_boxfilter(src, dst, ddepth, ksize, anchor, normalize, borderType))
480-
481402
//CV_IPP_RUN_FAST(ipp_boxfilter(src, dst, ksize, anchor, normalize, borderType));
482403

483404
borderType = (borderType&~BORDER_ISOLATED);

‎modules/imgproc/src/canny.cpp‎

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@
4545
#include"opencv2/core/hal/intrin.hpp"
4646
#include<deque>
4747

48-
#include"opencv2/core/openvx/ovx_defs.hpp"
49-
5048
namespacecv
5149
{
5250

@@ -761,65 +759,6 @@ class finalPass : public ParallelLoopBody
761759
finalPass&operator=(const finalPass&);// = delete
762760
};
763761

764-
#ifdef HAVE_OPENVX
765-
namespaceovx {
766-
template<>inlinebool skipSmallImages<VX_KERNEL_CANNY_EDGE_DETECTOR>(int w,int h) {return w*h <640 *480; }
767-
}
768-
staticboolopenvx_canny(const Mat& src, Mat& dst,int loVal,int hiVal,intkSize,bool useL2)
769-
{
770-
usingnamespaceivx;
771-
772-
Context context =ovx::getOpenVXContext();
773-
try
774-
{
775-
Image _src =Image::createFromHandle(
776-
context,
777-
Image::matTypeToFormat(src.type()),
778-
Image::createAddressing(src),
779-
src.data );
780-
Image _dst =Image::createFromHandle(
781-
context,
782-
Image::matTypeToFormat(dst.type()),
783-
Image::createAddressing(dst),
784-
dst.data );
785-
Threshold threshold =Threshold::createRange(context, VX_TYPE_UINT8, saturate_cast<uchar>(loVal), saturate_cast<uchar>(hiVal));
786-
787-
#if0
788-
// the code below is disabled because vxuCannyEdgeDetector()
789-
// ignores context attribute VX_CONTEXT_IMMEDIATE_BORDER
790-
791-
// FIXME: may fail in multithread case
792-
border_t prevBorder = context.immediateBorder();
793-
context.setImmediateBorder(VX_BORDER_REPLICATE);
794-
IVX_CHECK_STATUS( vxuCannyEdgeDetector(context, _src, threshold, kSize, (useL2 ? VX_NORM_L2 : VX_NORM_L1), _dst) );
795-
context.setImmediateBorder(prevBorder);
796-
#else
797-
// alternative code without vxuCannyEdgeDetector()
798-
Graph graph =Graph::create(context);
799-
ivx::Node node =ivx::Node(vxCannyEdgeDetectorNode(graph, _src, threshold,kSize, (useL2 ? VX_NORM_L2 : VX_NORM_L1), _dst) );
800-
node.setBorder(VX_BORDER_REPLICATE);
801-
graph.verify();
802-
graph.process();
803-
#endif
804-
805-
#ifdef VX_VERSION_1_1
806-
_src.swapHandle();
807-
_dst.swapHandle();
808-
#endif
809-
}
810-
catch(const WrapperError& e)
811-
{
812-
VX_DbgThrow(e.what());
813-
}
814-
catch(const RuntimeError& e)
815-
{
816-
VX_DbgThrow(e.what());
817-
}
818-
819-
returntrue;
820-
}
821-
#endif// HAVE_OPENVX
822-
823762
voidCanny( InputArray _src, OutputArray _dst,
824763
double low_thresh,double high_thresh,
825764
int aperture_size,bool L2gradient )
@@ -864,21 +803,6 @@ void Canny( InputArray _src, OutputArray _dst,
864803
CALL_HAL(canny, cv_hal_canny, src.data, src.step, dst.data, dst.step, src.cols, src.rows, src.channels(),
865804
low_thresh, high_thresh, aperture_size, L2gradient);
866805

867-
CV_OVX_RUN(
868-
false &&/* disabling due to accuracy issues*/
869-
src.type() == CV_8UC1 &&
870-
!src.isSubmatrix() &&
871-
src.cols >= aperture_size &&
872-
src.rows >= aperture_size &&
873-
!ovx::skipSmallImages<VX_KERNEL_CANNY_EDGE_DETECTOR>(src.cols, src.rows),
874-
openvx_canny(
875-
src,
876-
dst,
877-
cvFloor(low_thresh),
878-
cvFloor(high_thresh),
879-
aperture_size,
880-
L2gradient ) )
881-
882806
CV_IPP_RUN_FAST(ipp_Canny(src,Mat(),Mat(), dst, (float)low_thresh, (float)high_thresh, L2gradient, aperture_size))
883807

884808
if (L2gradient)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp