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

ocl: avoid unnecessary loading/initializing OpenCL subsystem

If there are no OpenCL/UMat methods calls from application.

OpenCL subsystem is initialized:
- haveOpenCL() is called from application
- useOpenCL() is called from application
- access to OpenCL allocator: UMat is created (empty UMat is ignored) or UMat <-> Mat conversions are called

Don't call OpenCL functions if OPENCV_OPENCL_RUNTIME=disabled
(independent from OpenCL linkage type)
This commit is contained in:
Alexander Alekhin
2017-11-24 17:34:02 +03:00
parent 92be112388
commit 0ed3209b00
20 changed files with 114 additions and 64 deletions
+3 -3
View File
@@ -607,7 +607,7 @@ bool HaarEvaluator::read(const FileNode& node, Size _origWinSize)
normrect = Rect(1, 1, origWinSize.width - 2, origWinSize.height - 2);
localSize = lbufSize = Size(0, 0);
if (ocl::haveOpenCL())
if (ocl::isOpenCLActivated())
{
if (ocl::Device::getDefault().isAMD() || ocl::Device::getDefault().isIntel() || ocl::Device::getDefault().isNVidia())
{
@@ -802,7 +802,7 @@ bool LBPEvaluator::read( const FileNode& node, Size _origWinSize )
}
nchannels = 1;
localSize = lbufSize = Size(0, 0);
if (ocl::haveOpenCL())
if (ocl::isOpenCLActivated())
localSize = Size(8, 8);
return true;
@@ -1306,7 +1306,7 @@ void CascadeClassifierImpl::detectMultiScaleNoGrouping( InputArray _image, std::
levelWeights.clear();
#ifdef HAVE_OPENCL
bool use_ocl = tryOpenCL && ocl::useOpenCL() &&
bool use_ocl = tryOpenCL && ocl::isOpenCLActivated() &&
OCL_FORCE_CHECK(_image.isUMat()) &&
featureEvaluator->getLocalSize().area() > 0 &&
(data.minNodesPerTree == data.maxNodesPerTree) &&