From a9ebc61f2a8b4500e22d96fa8577bf3ad192004d Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Wed, 28 Feb 2018 15:22:20 +0300 Subject: [PATCH] dnn(workaround): switch to CPU target if compiled without OpenCL --- modules/dnn/src/dnn.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/dnn/src/dnn.cpp b/modules/dnn/src/dnn.cpp index 194648c6ea..15755f73e9 100644 --- a/modules/dnn/src/dnn.cpp +++ b/modules/dnn/src/dnn.cpp @@ -53,6 +53,7 @@ #include #include +#include namespace cv { namespace dnn { @@ -846,6 +847,13 @@ struct Net::Impl if (!netWasAllocated || this->blobsToKeep != blobsToKeep_) { +#ifndef HAVE_OPENCL + if (preferableBackend == DNN_BACKEND_DEFAULT && preferableTarget == DNN_TARGET_OPENCL) + { + CV_LOG_WARNING(NULL, "DNN: OpenCL target is not available in this OpenCV build, switching to CPU.") + preferableTarget = DNN_TARGET_CPU; + } +#endif clear(); allocateLayers(blobsToKeep_);