OpenCV checkRange_0
Catch out-of-bounds arrays before they wreck your pipeline
- a
- bool
- literal
checkRange is OpenCV's array sanity check: it looks at every element of an nparray and reports whether all of them fall between a minimum and maximum value. It returns a boolean (plus a literal holding the offending point). It's a debug/diagnostic node - the kind of thing you drop into a pipeline once when values are misbehaving, not a tool you keep in every workflow.
Here's the concrete case where you want it. This pack is full of operations that assume images are in a certain range - 0..255 for uint8 BGR, 0..1 for floats - and when one node feeds another something outside that range, you get silent garbage or an obscure crash two nodes downstream. checkRange lets you prove where the values went wrong: put it on a wire, set minVal/maxVal to what you expect, and get a clean True/False instead of guessing. If the output is False, you've just located the broken link in the chain - and the literal output carries the position of the first offending element per OpenCV's type definition.
Inputs. a (NPARRAY, the array to inspect), quiet (BOOLEAN), minVal and maxVal (FLOAT). The quiet flag is the interesting one: with quiet on, checkRange returns a result instead of throwing - which is what you want inside a ComfyUI graph, where a crash is far less informative than a boolean you can wire into logic. With quiet off, out-of-range values make OpenCV raise instead. Keep quiet on, honestly. The output is bool (whether everything is in range) plus literal, a string holding the position where the range was violated.
The honest take. This is a plumbing/debug node in the purest sense - it touches no pixels, it just reports. If you're diagnosing a broken workflow, it's genuinely handy; if your workflow is healthy, you'll never touch it. That's not a knock - the pack auto-generated every top-level cv2 function, and half the value of that is having the diagnostic ones available in-graph instead of reaching for a Python script every time something misbehaves.
Install. Standard pack story: ComfyUI Manager → search "OpenCV", or:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-python-contrib
Restart after. No model downloads. Keep the pack's conventions in mind - NPARRAY in, batch size 1, bridge from IMAGE with Image2Nparray. And checkRange_1 is the identical twin of this node (the pack's overload-duplication pattern), so pick either. Expect dragons, as the author says - though honestly this dragon mostly just tells you the truth.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| a | NPARRAY | — | |
| quiet | BOOLEAN | — | |
| minVal | FLOAT | — | |
| maxVal | FLOAT | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| bool | BOOLEAN | — |
| literal | STRING | — |