cv2.dnn.setInferenceEngineBackendType
A global switch you probably shouldn't flip
- string
One string in, one string out, and a side effect that reaches outside your graph. This is the setter for OpenCV's DNN backend type - the call that decides whether cv2.dnn keeps using its own implementation or hands work off to Intel's Inference Engine. The output is the string OpenCV returns for the call, which its docs describe as the value that was in effect before you changed it - hence the follow-up: run the sibling getter to see where you've landed.
What's actually happening
OpenCV's DNN module carries a global backend-type parameter. Everything that loads and runs a network afterwards reads it. So the moment this node executes, you have changed how cv2.dnn behaves for the rest of the process - which in ComfyUI means the rest of the session, across every workflow, including any other custom node pack that also calls into cv2.dnn. There's no scoping, no per-node override, and nothing that resets it at the end of a run. If you're on an ONNX pipeline and you flip this to a backend your build doesn't ship, the next CV DNN Forward is the thing that fails, probably with an error that doesn't mention this node at all.
That combination - global state, distant failure, no automatic cleanup - is why this is a node to reach for last, and why it's worth knowing it exists mostly so you can recognise it in someone else's workflow.
The widget, and one schema detail that will bite you
newBackendType is a required string, and its widget comes up blank because the underlying type stubs carry no default value. Unlike the optional parameters on the raw wrappers - where blank means "don't pass this argument, use OpenCV's default" - a blank required string gets passed as an empty string. OpenCV then gets to decide what to do with a backend name it doesn't recognise, and the answer is generally an error, not a graceful fallback.
So: type a real name. Whatever your build's getter reports is by definition a valid round-trip value, which makes the safe experiment trivially easy:
- Run
cv2.dnn.getInferenceEngineBackendTypeand read the string. - Type that same string into this node's widget and run.
- It should come back unchanged, and nothing downstream should break.
If step 3 breaks, you've learned that your build doesn't accept the very value it reported, which is a genuinely useful thing to know before you go hunting for a performance fix in the wrong place.
Is there a reason to use it in anger?
Marginal. The original use case was choosing between OpenCV's own kernels and the Inference Engine backend for the same model on Intel hardware. Modern OpenCV moved away from that split, and the whole get/setInferenceEngine*Type family is legacy surface that some builds no longer expose in Python at all - the pack probes each generated wrapper against your installed cv2 and skips what isn't there, so this node may simply not appear in your menu. That's not a broken install.
If you're chasing ONNX inference speed in ComfyUI, the lever that actually moves the needle isn't a backend string; it's whether you should be running that model through cv2.dnn's CPU path at all. The pack's README says it plainly: ComfyUI usually has a first-class PyTorch path for the same job, and the DNN nodes exist for reaching models it doesn't cover.
Installing comfyui_cv
About 470 auto-generated raw cv2.* wrappers plus curated nodes, in bmad4ever/comfyui_cv - a GPL-3.0 fork of Gerold Meisinger's opencv-comfyui. Manager: search ComfyUI CV. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_cv
Restart afterwards. Python ≥ 3.12 and a recent ComfyUI on the V3 node API; the single dependency is opencv-contrib-python-headless~=5.0.0.93. Install the contrib wheel - the four OpenCV distributions share one site-packages/cv2 and the last one installed wins, so a plain opencv-python quietly removes the contrib nodes. tools/repair_opencv_contrib.py --check diagnoses; --apply repairs.
Common issues
Something else broke later in the session. Suspect this node. It's process-global, and the failure shows up wherever the next cv2.dnn call happens, not here.
Error on an empty field. Blank isn't a default - it's an empty string. Type the name.
The node doesn't exist in your menu. Your OpenCV build doesn't expose the function.
Performance didn't change. It rarely does; this is a legacy backend switch, not a speed dial.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| newBackendType | STRING | - - - |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| string | STRING | — |