Add DNN engine selection (EngineType) and sync Backend/Target enums - #1925
Merged
Merged
Conversation
OpenCV 5 lets readNet* pick an inference engine via an `int engine` parameter (EngineType: Classic/New/Auto/Ort). Expose it through the native bridge and the managed Net / CvDnn read APIs, defaulting to Auto. Also re-sync the Backend and Target enums with OpenCV 5: add Backend WEBNN/TIMVX/CANN (Halide removed but its value 1 kept as a gap so the remaining values stay correct) and Target NPU/CPU_FP16. Refs #1924. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Jun 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First item from #1924 (OpenCV 5 API coverage): expose DNN inference engine selection and re-sync the
Backend/Targetenums with OpenCV 5.Engine selection
EngineTypeenum (Classic=1/New=2/Auto=3/Ort=4), matchingcv::dnn::EngineType.EngineType engine = EngineType.Autoparameter to the read APIs onNetandCvDnn:ReadNet,ReadNetFromONNX,ReadNetFromTensorflow,ReadNetFromTFLite(string / byte[] /ReadOnlySpan<byte>/Streamoverloads).dnn.h) and P/Invoke signatures threaded through theint engineargument. The string-path ONNX/TFLite calls are wrapped incv::String(...)to disambiguate from the(const char*, size_t, int)buffer overloads.Backend / Target enum sync
Backend: addedWEBNN/TIMVX/CANN.HALIDEwas removed in OpenCV 5; its value1is kept as a gap (marked[Obsolete]) so the remaining members keep their OpenCV-matching numeric values.Target: addedNPU/CPU_FP16.Test
EngineSelectionTest: verifies the enum numeric values match OpenCV 5 and thatReadNetFromTensorflowloads the committed MNIST model withClassicandAutoengines.OpenCvSharpExternlocally; fulldnnsuite green (45 passed, 4 network-dependent skips).Refs #1924.
🤖 Generated with Claude Code