Added CMake configuration OPENCV_DNN_BACKEND_DEFAULT#24218
Added CMake configuration OPENCV_DNN_BACKEND_DEFAULT#24218asmorkalov merged 1 commit intoopencv:4.xfrom
Conversation
|
What if default backend is set to cuda in the compiling stage, but target is not set or set to non-cuda targets? |
|
Then you are into the same situation as defining the respective backend by an environment variable. Currently, the parameters only support defining the backend but not the target (see |
|
I just want to say that the backend-target combinations are confusing to most of the first-time users already, and yet some users may be even confused why they cannot run on cuda with |
|
Yes, understood, we agree with that. All we wanted to say is that it's similarly confusing to set a backend alone (either by a configuration parameter or by code) might not be sufficient to actually enable CUDA, OpenVINO or whatever backend you selected. This could be resolved by extending the current logic such that model and backend are set simlutaneously (i.e. unify |
Until some recent changes were made, OpenCV selected the default DNN backend either as
DNN_BACKEND_INFERENCE_ENGINE, if available, orDNN_BACKEND_OPENCV, otherwise. Recently, this was removed because OpenCV supports multiple plugins/backends, as discussed in #24085.This patch has two aims: First, fix the documentation since there is no extended default backend logic anymore. Next, it introduces a CMake variable
OPENCV_DNN_BACKEND_DEFAULTthat can be used to define a user-specific default backend. If this is not set, it defaults toDNN_BACKEND_OPENCV. Still, compiling with OpenVINO/Inference Engine support allows to default to it by adding the CMake argument-D "OPENCV_DNN_BACKEND_DEFAULT=DNN_BACKEND_INFERENCE_ENGINE". Selecting a different default backend is similarly possible, only defineOPENCV_DNN_BACKEND_DEFAULTaccordingly (e.g. for CUDA). In any case, defining a configuration parameter (e.g. as an environment variable) overrules the compiled-in default such that no existing logic is changed.Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.