Added CMake configuration OPENCV_DNN_BACKEND_DEFAULT

pull/24218/head
Björn Böken 2 years ago
parent c53b3c5f84
commit 639836ebf0
  1. 4
      CMakeLists.txt
  2. 3
      modules/dnn/CMakeLists.txt
  3. 7
      modules/dnn/include/opencv2/dnn/dnn.hpp
  4. 2
      modules/dnn/src/dnn_params.cpp

@ -1672,6 +1672,10 @@ else()
endif() endif()
endif() endif()
if(BUILD_opencv_dnn)
status(" Default DNN backend:" ${OPENCV_DNN_BACKEND_DEFAULT})
endif()
if(WITH_EIGEN OR HAVE_EIGEN) if(WITH_EIGEN OR HAVE_EIGEN)
status(" Eigen:" HAVE_EIGEN THEN "YES (ver ${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION})" ELSE NO) status(" Eigen:" HAVE_EIGEN THEN "YES (ver ${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION})" ELSE NO)
endif() endif()

@ -227,6 +227,9 @@ if(TARGET ocv.3rdparty.openvino AND OPENCV_DNN_OPENVINO)
endif() endif()
endif() endif()
set(OPENCV_DNN_BACKEND_DEFAULT "DNN_BACKEND_OPENCV" CACHE STRING "Default backend used by the DNN module")
ocv_append_source_file_compile_definitions("${CMAKE_CURRENT_LIST_DIR}/src/dnn_params.cpp" "OPENCV_DNN_BACKEND_DEFAULT=${OPENCV_DNN_BACKEND_DEFAULT}")
ocv_install_used_external_targets(${libs} ${dnn_runtime_libs}) ocv_install_used_external_targets(${libs} ${dnn_runtime_libs})

@ -69,9 +69,7 @@ CV__DNN_INLINE_NS_BEGIN
*/ */
enum Backend enum Backend
{ {
//! DNN_BACKEND_DEFAULT equals to DNN_BACKEND_INFERENCE_ENGINE if //! DNN_BACKEND_DEFAULT equals to OPENCV_DNN_BACKEND_DEFAULT, which can be defined using CMake or a configuration parameter
//! OpenCV is built with Intel OpenVINO or
//! DNN_BACKEND_OPENCV otherwise.
DNN_BACKEND_DEFAULT = 0, DNN_BACKEND_DEFAULT = 0,
DNN_BACKEND_HALIDE, DNN_BACKEND_HALIDE,
DNN_BACKEND_INFERENCE_ENGINE, //!< Intel OpenVINO computational backend DNN_BACKEND_INFERENCE_ENGINE, //!< Intel OpenVINO computational backend
@ -688,9 +686,6 @@ CV__DNN_INLINE_NS_BEGIN
* @brief Ask network to use specific computation backend where it supported. * @brief Ask network to use specific computation backend where it supported.
* @param[in] backendId backend identifier. * @param[in] backendId backend identifier.
* @see Backend * @see Backend
*
* If OpenCV is compiled with Intel's Inference Engine library, DNN_BACKEND_DEFAULT
* means DNN_BACKEND_INFERENCE_ENGINE. Otherwise it equals to DNN_BACKEND_OPENCV.
*/ */
CV_WRAP void setPreferableBackend(int backendId); CV_WRAP void setPreferableBackend(int backendId);

@ -36,7 +36,7 @@ bool getParam_DNN_OPENCL_ALLOW_ALL_DEVICES()
int getParam_DNN_BACKEND_DEFAULT() int getParam_DNN_BACKEND_DEFAULT()
{ {
static int PARAM_DNN_BACKEND_DEFAULT = (int)utils::getConfigurationParameterSizeT("OPENCV_DNN_BACKEND_DEFAULT", static int PARAM_DNN_BACKEND_DEFAULT = (int)utils::getConfigurationParameterSizeT("OPENCV_DNN_BACKEND_DEFAULT",
(size_t)DNN_BACKEND_OPENCV (size_t)OPENCV_DNN_BACKEND_DEFAULT
); );
return PARAM_DNN_BACKEND_DEFAULT; return PARAM_DNN_BACKEND_DEFAULT;
} }

Loading…
Cancel
Save