OpenCV getNumThreads_0
How Many Threads Is OpenCV Actually Using Right Now?
- int
OpenCV getNumThreads_0 returns the number of threads OpenCV is currently using for its parallel operations - cv2.getNumThreads() wrapped as a node. No inputs, one int output. If you've ever watched an OpenCV filter grind through a 4K image and wondered whether it's even using your cores, this is the number that tells you. It's the read-half of the pack's thread-control pair; the write-half is setNumThreads.
What the number means
OpenCV parallelizes its heavy loops (blurs, warps, filters, DFT) across a worker pool. getNumThreads reports the current pool size:
0- the auto mode: OpenCV picks its own thread count based on the machine it sees.- Any positive number - a specific cap someone set via
setNumThreads(orcv2.setNumThreadselsewhere).
The value sticks process-wide, like OpenCV's log level. If any custom node in your ComfyUI session called cv2.setNumThreads(2), that cap affects every OpenCV call after it - including nodes from other packs. So when your OpenCV ops are inexplicably slow, checking this tells you whether someone's already clamped the pool.
When you'd actually use it
Same honest story as the other diagnostic nodes in this pack: this is a debugging instrument, not a workflow citizen. You reach for it when OpenCV-backed nodes feel slow or when a single blur saturates all your cores and starves the sampler. Read it, then decide: cap it lower with setNumThreads if OpenCV is hogging everything (a real complaint when one heavy node sits between generation passes), or raise it if it's clamped and you have cores to spare. Then remove both nodes from the final graph - they're process-global and don't belong in a shared workflow.
One nuance: this number is OpenCV's thread pool, completely independent of PyTorch's thread settings and of the GPU. Tuning it won't touch sampler speed, model loading, or anything torch-side. It's a dedicated knob for the dedicated OpenCV code path only.
Install
Standard for the pack - ComfyUI Manager, search opencv-comfyui (display "OpenCV"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-contrib-python
Restart, done, no models.
No gotchas to speak of: single int output, no images, no literal strings, nothing to break. The only real footgun is forgetting the global-scope behavior - if you set threads in a test workflow and then remove the node, the setting may persist for the rest of the process unless something resets it. 0 (auto) is the value you want to leave things at when you're done experimenting.
Inputs (0)
No inputs
Outputs (1)
| Name | Type | Description |
|---|---|---|
| int | INT | — |