OpenCV getVersionMajor_0
The single digit that tells you which OpenCV era you're on
- int
getVersionMajor_0 does exactly one thing: it reports the major version of the OpenCV that's actually loaded in your ComfyUI environment, as an INT. No inputs, one output, no images touched. On a standard install that's 4 - the fourth major version has been the current one for over a decade now. If you're debugging "why is this node behaving differently than the docs say," this is a good first stop, because OpenCV's major version gates some of the biggest behavioral changes (the whole API reshaped at the 2→3 and 3→4 boundaries).
How it works
It wraps cv2.getVersionMajor(), one of a family of version-reporting functions. The output comes straight from the compiled cv2 binary, so it's a fact about the installed wheel, not about ComfyUI. Useful things you can learn from it:
- Whether you're on OpenCV 3 (ancient, some functions behave differently) or OpenCV 4 (everything modern expects).
- Combined with
getVersionMinor_0, whether a specific API you rely on - like thegradientSizevariant ofgoodFeaturesToTrack, added in 4.4 - is even available.
The realistic use in a workflow is conditional behavior: if some node in the pack only works cleanly on OpenCV 4.x, this output can drive a branch. In practice, almost nobody does that in ComfyUI - the pack's own requirements.txt pins opencv-contrib-python with no upper bound, so you just get whatever the latest is. The value is diagnostic: it's the cheapest "is my environment sane" check you can run.
Why you'd reach for it over getVersionString_0
You mostly wouldn't. getVersionString_0 gives you the whole version in one string ("4.11.0"), which is easier to read and remember. The per-component nodes exist because the auto-generator wrapped every function, and they have one edge: if you're scripting comparisons or feeding a numeric version into another node's INT input, a clean integer beats parsing a string. That's a thin use case, but it's real.
Install & troubleshooting
The pack installs like any of its siblings:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
or ComfyUI Manager, search "opencv-comfyui", install, restart. Needs opencv-contrib-python (plus numpy/torch that ComfyUI ships). No models, no keys. The only "trouble" you're likely to hit with this node is environmental: if multiple OpenCV packages are fighting, you can get Cannot import name 'guidedFilter' from 'cv2.ximgproc' at startup - uninstall the duplicates. And if the major version this node reports looks old, your pip environment is holding onto a stale wheel; upgrade opencv-contrib-python and rerun. A diagnostic node, through and through - boring, but boring is exactly what you want when it tells you your ground truth.
Inputs (0)
No inputs
Outputs (1)
| Name | Type | Description |
|---|---|---|
| int | INT | — |