mirror of https://github.com/opencv/opencv.git
parent
beea04cc89
commit
1e2ddc30b1
8 changed files with 387 additions and 57 deletions
@ -0,0 +1,33 @@ |
||||
// 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.
|
||||
|
||||
// Copyright (C) 2016, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
|
||||
// OpenVX related definitions and declarations
|
||||
|
||||
#pragma once |
||||
#ifndef OPENCV_OVX_DEFS_HPP |
||||
#define OPENCV_OVX_DEFS_HPP |
||||
|
||||
#include "cvconfig.h" |
||||
|
||||
// utility macro for running OpenVX-based implementations
|
||||
#ifdef HAVE_OPENVX |
||||
|
||||
#define IVX_HIDE_INFO_WARNINGS |
||||
#define IVX_USE_OPENCV |
||||
#include "ivx.hpp" |
||||
|
||||
#define CV_OVX_RUN(condition, func, ...) \ |
||||
if (cv::useOpenVX() && (condition) && func) \
|
||||
{ \
|
||||
return __VA_ARGS__; \
|
||||
} |
||||
|
||||
#else |
||||
#define CV_OVX_RUN(condition, func, ...) |
||||
#endif // HAVE_OPENVX
|
||||
|
||||
#endif // OPENCV_OVX_DEFS_HPP
|
@ -0,0 +1,28 @@ |
||||
// 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.
|
||||
|
||||
// Copyright (C) 2016, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
|
||||
// OpenVX related definitions and declarations
|
||||
|
||||
#pragma once |
||||
#ifndef OPENCV_OVX_HPP |
||||
#define OPENCV_OVX_HPP |
||||
|
||||
#include "cvdef.h" |
||||
|
||||
namespace cv |
||||
{ |
||||
/// Check if use of OpenVX is possible
|
||||
CV_EXPORTS_W bool haveOpenVX(); |
||||
|
||||
/// Check if use of OpenVX is enabled
|
||||
CV_EXPORTS_W bool useOpenVX(); |
||||
|
||||
/// Enable/disable use of OpenVX
|
||||
CV_EXPORTS_W void setUseOpenVX(bool flag); |
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_OVX_HPP
|
@ -0,0 +1,72 @@ |
||||
// 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.
|
||||
|
||||
// Copyright (C) 2016, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
|
||||
// OpenVX related functions
|
||||
|
||||
#include "precomp.hpp" |
||||
#include "opencv2/core/ovx.hpp" |
||||
#include "opencv2/core/openvx/ovx_defs.hpp" |
||||
|
||||
namespace cv |
||||
{ |
||||
|
||||
bool haveOpenVX() |
||||
{ |
||||
#ifdef HAVE_OPENVX |
||||
static int g_haveOpenVX = -1; |
||||
if(g_haveOpenVX < 0) |
||||
{ |
||||
try |
||||
{ |
||||
ivx::Context context = ivx::Context::create(); |
||||
vx_uint16 vComp = ivx::compiledWithVersion(); |
||||
vx_uint16 vCurr = context.version(); |
||||
g_haveOpenVX = |
||||
VX_VERSION_MAJOR(vComp) == VX_VERSION_MAJOR(vCurr) && |
||||
VX_VERSION_MINOR(vComp) == VX_VERSION_MINOR(vCurr) |
||||
? 1 : 0; |
||||
} |
||||
catch(const ivx::WrapperError&) |
||||
{ g_haveOpenVX = 0; } |
||||
catch(const ivx::RuntimeError&) |
||||
{ g_haveOpenVX = 0; } |
||||
} |
||||
return g_haveOpenVX == 1; |
||||
#else |
||||
return false; |
||||
#endif |
||||
} |
||||
|
||||
bool useOpenVX() |
||||
{ |
||||
#ifdef HAVE_OPENVX |
||||
CoreTLSData* data = getCoreTlsData().get(); |
||||
if( data->useOpenVX < 0 ) |
||||
{ |
||||
// enabled (if available) by default
|
||||
data->useOpenVX = haveOpenVX() ? 1 : 0; |
||||
} |
||||
return data->useOpenVX > 0; |
||||
#else |
||||
return false; |
||||
#endif |
||||
} |
||||
|
||||
void setUseOpenVX(bool flag) |
||||
{ |
||||
#ifdef HAVE_OPENVX |
||||
if( haveOpenVX() ) |
||||
{ |
||||
CoreTLSData* data = getCoreTlsData().get(); |
||||
data->useOpenVX = flag ? 1 : 0; |
||||
} |
||||
#else |
||||
CV_Assert(!flag && "OpenVX support isn't enabled at compile time"); |
||||
#endif |
||||
} |
||||
|
||||
} // namespace cv
|
Loading…
Reference in new issue