1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

Canny via OpenVX, Node wrapper extended (query/set attribute), some naming fixes

This commit is contained in:
apavlenko
2016-11-25 12:35:55 +03:00
parent beea04cc89
commit 1e2ddc30b1
8 changed files with 389 additions and 59 deletions
+1
View File
@@ -3215,5 +3215,6 @@ template<> struct ParamType<uchar>
#include "opencv2/core/cvstd.inl.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/optim.hpp"
#include "opencv2/core/ovx.hpp"
#endif /*OPENCV_CORE_HPP*/
@@ -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
+28
View File
@@ -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
+72
View File
@@ -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
+8 -3
View File
@@ -262,11 +262,13 @@ struct CoreTLSData
device(0), useOpenCL(-1),
//#endif
useIPP(-1)
{
#ifdef HAVE_TEGRA_OPTIMIZATION
useTegra = -1;
,useTegra(-1)
#endif
}
#ifdef HAVE_OPENVX
,useOpenVX(-1)
#endif
{}
RNG rng;
//#ifdef HAVE_OPENCL
@@ -278,6 +280,9 @@ struct CoreTLSData
#ifdef HAVE_TEGRA_OPTIMIZATION
int useTegra; // 1 - use, 0 - do not use, -1 - auto/not initialized
#endif
#ifdef HAVE_OPENVX
int useOpenVX; // 1 - use, 0 - do not use, -1 - auto/not initialized
#endif
};
TLSData<CoreTLSData>& getCoreTlsData();