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

Merge pull request #26334 from gursimarsingh:dnn_engine_change

Modify DNN Samples to use ENGINE_CLASSIC for Non-Default Back-end or Target #26334

PR resolves #26325 regarding fall-back to ENGINE_CLASSIC if non-default back-end or target is passed by user.
### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Gursimar Singh
2024-11-08 11:28:35 +05:30
committed by GitHub
parent 1ae304bb83
commit 979428d590
9 changed files with 39 additions and 19 deletions
+5 -1
View File
@@ -83,7 +83,11 @@ int main(int argc, char** argv) {
resize(imgL, imgLResized, Size(256, 256), 0, 0, INTER_CUBIC);
// Prepare the model
dnn::Net net = dnn::readNetFromONNX(onnxModelPath);
EngineType engine = ENGINE_AUTO;
if (backendId != 0 || targetId != 0){
engine = ENGINE_CLASSIC;
}
dnn::Net net = dnn::readNetFromONNX(onnxModelPath, engine);
net.setPreferableBackend(backendId);
net.setPreferableTarget(targetId);
//! [Read and initialize network]