dnn(workaround): switch to CPU target if compiled without OpenCL

This commit is contained in:
Alexander Alekhin 2018-02-28 15:22:20 +03:00
parent 4a6d582f2e
commit e79be78ef4

View File

@ -53,6 +53,7 @@
#include <opencv2/imgproc.hpp>
#include <opencv2/core/utils/configuration.private.hpp>
#include <opencv2/core/utils/logger.hpp>
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_);