mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
OpenVX calls updated to use single common OpenVX context per thread
This commit is contained in:
committed by
Alexander Alekhin
parent
ec7f74f7b4
commit
9a4b5a4545
@@ -20,6 +20,12 @@
|
||||
#define IVX_USE_OPENCV
|
||||
#include "ivx.hpp"
|
||||
|
||||
namespace cv{
|
||||
namespace ovx{
|
||||
// Get common thread local OpenVX context
|
||||
CV_EXPORTS_W ivx::Context& getOpenVXContext();
|
||||
}}
|
||||
|
||||
#define CV_OVX_RUN(condition, func, ...) \
|
||||
if (cv::useOpenVX() && (condition) && func) \
|
||||
{ \
|
||||
|
||||
@@ -4673,7 +4673,7 @@ static bool _openvx_cvt(const T* src, size_t sstep,
|
||||
|
||||
try
|
||||
{
|
||||
Context context = Context::create();
|
||||
Context context = ovx::getOpenVXContext();
|
||||
|
||||
// Other conversions are marked as "experimental"
|
||||
if(context.vendorID() == VX_ID_KHRONOS &&
|
||||
@@ -5406,7 +5406,7 @@ static bool openvx_LUT(Mat src, Mat dst, Mat _lut)
|
||||
|
||||
try
|
||||
{
|
||||
ivx::Context ctx = ivx::Context::create();
|
||||
ivx::Context ctx = ovx::getOpenVXContext();
|
||||
|
||||
ivx::Image
|
||||
ia = ivx::Image::createFromHandle(ctx, VX_DF_IMAGE_U8,
|
||||
|
||||
@@ -14,6 +14,38 @@
|
||||
namespace cv
|
||||
{
|
||||
|
||||
namespace ovx
|
||||
{
|
||||
#ifdef HAVE_OPENVX
|
||||
|
||||
// Simple TLSData<ivx::Context> doesn't work, because default constructor doesn't create any OpenVX context.
|
||||
struct OpenVXTLSData
|
||||
{
|
||||
OpenVXTLSData() : ctx(ivx::Context::create()) {}
|
||||
ivx::Context ctx;
|
||||
};
|
||||
|
||||
static TLSData<OpenVXTLSData>& getOpenVXTLSData()
|
||||
{
|
||||
CV_SINGLETON_LAZY_INIT_REF(TLSData<OpenVXTLSData>, new TLSData<OpenVXTLSData>())
|
||||
}
|
||||
|
||||
struct OpenVXCleanupFunctor
|
||||
{
|
||||
~OpenVXCleanupFunctor() { getOpenVXTLSData().cleanup(); }
|
||||
};
|
||||
static OpenVXCleanupFunctor g_openvx_cleanup_functor;
|
||||
|
||||
ivx::Context& getOpenVXContext()
|
||||
{
|
||||
return getOpenVXTLSData().get()->ctx;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
bool haveOpenVX()
|
||||
{
|
||||
#ifdef HAVE_OPENVX
|
||||
@@ -22,7 +54,7 @@ bool haveOpenVX()
|
||||
{
|
||||
try
|
||||
{
|
||||
ivx::Context context = ivx::Context::create();
|
||||
ivx::Context context = ovx::getOpenVXContext();
|
||||
vx_uint16 vComp = ivx::compiledWithVersion();
|
||||
vx_uint16 vCurr = context.version();
|
||||
g_haveOpenVX =
|
||||
|
||||
@@ -1665,7 +1665,7 @@ namespace cv
|
||||
|
||||
try
|
||||
{
|
||||
ivx::Context ctx = ivx::Context::create();
|
||||
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
|
||||
@@ -2312,7 +2312,7 @@ static bool openvx_minMaxIdx(Mat &src, double* minVal, double* maxVal, int* minI
|
||||
|
||||
try
|
||||
{
|
||||
ivx::Context ctx = ivx::Context::create();
|
||||
ivx::Context ctx = ovx::getOpenVXContext();
|
||||
ivx::Image
|
||||
ia = ivx::Image::createFromHandle(ctx, stype == CV_8UC1 ? VX_DF_IMAGE_U8 : VX_DF_IMAGE_S16,
|
||||
ivx::Image::createAddressing(cols, rows, stype == CV_8UC1 ? 1 : 2, (vx_int32)(src.step[0])), src.ptr());
|
||||
|
||||
Reference in New Issue
Block a user