mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge pull request #26903 from asmorkalov:as/openvx_hal
Migrate remaning OpenVX integrations to OpenVX HAL (core) #26903 Tested with OpenVX 1.2 & 1.3 sample implementation. Steps to build and test: ``` git clone git@github.com:KhronosGroup/OpenVX-sample-impl.git cd OpenVX-sample-impl python3 Build.py --os=Linux --conf=Release cd .. mkdir build cmake -DWITH_OPENVX=ON -DOPENVX_ROOT=/mnt/Projects/Projects/OpenVX-sample-impl/install/Linux/x64/Release/ ../opencv make -j8 ``` ### 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
This commit is contained in:
committed by
GitHub
parent
e4b23cf96a
commit
58e557d059
@@ -5,7 +5,6 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencl_kernels_core.hpp"
|
||||
#include "opencv2/core/openvx/ovx_defs.hpp"
|
||||
#include "stat.hpp"
|
||||
|
||||
#ifndef OPENCV_IPP_MEAN
|
||||
@@ -328,70 +327,6 @@ static bool ocl_meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENVX
|
||||
static bool openvx_meanStdDev(Mat& src, OutputArray _mean, OutputArray _sdv, Mat& mask)
|
||||
{
|
||||
size_t total_size = src.total();
|
||||
int rows = src.size[0], cols = rows ? (int)(total_size / rows) : 0;
|
||||
if (src.type() != CV_8UC1|| !mask.empty() ||
|
||||
(src.dims != 2 && !(src.isContinuous() && cols > 0 && (size_t)rows*cols == total_size))
|
||||
)
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
ivx::Context ctx = ovx::getOpenVXContext();
|
||||
#ifndef VX_VERSION_1_1
|
||||
if (ctx.vendorID() == VX_ID_KHRONOS)
|
||||
return false; // Do not use OpenVX meanStdDev estimation for sample 1.0.1 implementation due to lack of accuracy
|
||||
#endif
|
||||
|
||||
ivx::Image
|
||||
ia = ivx::Image::createFromHandle(ctx, VX_DF_IMAGE_U8,
|
||||
ivx::Image::createAddressing(cols, rows, 1, (vx_int32)(src.step[0])), src.ptr());
|
||||
|
||||
vx_float32 mean_temp, stddev_temp;
|
||||
ivx::IVX_CHECK_STATUS(vxuMeanStdDev(ctx, ia, &mean_temp, &stddev_temp));
|
||||
|
||||
if (_mean.needed())
|
||||
{
|
||||
if (!_mean.fixedSize())
|
||||
_mean.create(1, 1, CV_64F, -1, true);
|
||||
Mat mean = _mean.getMat();
|
||||
CV_Assert(mean.type() == CV_64F && mean.isContinuous() &&
|
||||
(mean.cols == 1 || mean.rows == 1) && mean.total() >= 1);
|
||||
double *pmean = mean.ptr<double>();
|
||||
pmean[0] = mean_temp;
|
||||
for (int c = 1; c < (int)mean.total(); c++)
|
||||
pmean[c] = 0;
|
||||
}
|
||||
|
||||
if (_sdv.needed())
|
||||
{
|
||||
if (!_sdv.fixedSize())
|
||||
_sdv.create(1, 1, CV_64F, -1, true);
|
||||
Mat stddev = _sdv.getMat();
|
||||
CV_Assert(stddev.type() == CV_64F && stddev.isContinuous() &&
|
||||
(stddev.cols == 1 || stddev.rows == 1) && stddev.total() >= 1);
|
||||
double *pstddev = stddev.ptr<double>();
|
||||
pstddev[0] = stddev_temp;
|
||||
for (int c = 1; c < (int)stddev.total(); c++)
|
||||
pstddev[c] = 0;
|
||||
}
|
||||
}
|
||||
catch (const ivx::RuntimeError & e)
|
||||
{
|
||||
VX_DbgThrow(e.what());
|
||||
}
|
||||
catch (const ivx::WrapperError & e)
|
||||
{
|
||||
VX_DbgThrow(e.what());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
static bool ipp_meanStdDev(Mat& src, OutputArray _mean, OutputArray _sdv, Mat& mask)
|
||||
{
|
||||
@@ -543,9 +478,6 @@ void meanStdDev(InputArray _src, OutputArray _mean, OutputArray _sdv, InputArray
|
||||
|
||||
CV_Assert(mask.empty() || src.size == mask.size);
|
||||
|
||||
CV_OVX_RUN(!ovx::skipSmallImages<VX_KERNEL_MEAN_STDDEV>(src.cols, src.rows),
|
||||
openvx_meanStdDev(src, _mean, _sdv, mask))
|
||||
|
||||
CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_meanStdDev(src, _mean, _sdv, mask));
|
||||
|
||||
int k, cn = src.channels(), depth = src.depth();
|
||||
|
||||
Reference in New Issue
Block a user