OpenCV图像转IMAGE
CVIMAGE to IMAGE
- 图像输入
- 图像输出
Every FlowCV article ends the same way: "then run it through FCV_CVToIMAGE." This is that node - the bridge between FlowCV's world and everything else in ComfyUI, and honestly the reason the whole pack is usable at all. Every processing node in FlowCV (thresholds, filters, Canny, morphology) speaks CVIMAGE: a raw OpenCV numpy array in BGR order. ComfyUI's native IMAGE is a float tensor in RGB, normalized 0–1, with a batch dimension. Those two are not interchangeable, and this node is the translator.
If you've loaded a FlowCV workflow and seen red skies and blue faces, or an "IMAGE required" error that won't accept the wire, this is the missing piece. One node in, the pack's output finally talks to the rest of your graph.
What it actually does
The process() method (the pack auto-registers these with a uniform process entrypoint) does the full conversion:
- Handles every input shape: 2D grayscale
(H, W), single-channel(H, W, 1), 3-channel BGR(H, W, 3), or 4-channel BGRA(H, W, 4). Each is converted to RGB - thecv2.COLOR_BGR2RGBswap is the step that fixes the red/blue inversion you'd otherwise see. - Normalizes dtype: if you feed floats in 0–1 range it scales to 0–255; anything else is cast to
uint8. - Divides by 255 to land in the 0–1 float range ComfyUI expects, converts to a torch tensor, and adds the batch dimension, producing the standard
(1, H, W, 3)IMAGE.
So the one input - 图像输入 (image input, type CVIMAGE) - goes in as BGR numpy and comes out as a proper ComfyUI IMAGE that any standard node (preview, VAE encode, image-to-image pipelines) will accept.
When you need it
Basically whenever you're done processing. FlowCV's own visualization nodes (FCV_ShowImage and friends) can display a CVIMAGE inline, but the moment you want to see the result in a standard preview, feed it to a ControlNet, use it as a mask, or pass it into a sampler pipeline, you go through FCV_CVToIMAGE. It's also the correct starting point when you want to take ComfyUI's IMAGE, do OpenCV work on it, and bring the result back.
Installing
It ships with FlowCV, so install the pack once. ComfyUI Manager, search "FlowCV"; or:
cd ComfyUI/custom_nodes
git clone https://github.com/Koren-cy/FlowCV
Restart ComfyUI. Dependencies: opencv-python, numpy, pyserial - no model downloads. Note the README: the project has migrated to ComfyUI_For_Academic, so this repo is archived but functional.
Gotchas
The node raises an exception (which the pack swallows into a console message, returning nothing useful) if you feed it a non-array or an unsupported channel count - check your input is actually a CVIMAGE. And note it doesn't add a mask or alpha handling beyond discarding it in the BGRA→RGB path, so 4-channel masks come through as plain RGB. That's usually what you want, but worth knowing.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| 图像输入 | CVIMAGE | OpenCV格式的图像(ndarray) |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| 图像输出 | IMAGE | ComfyUI IMAGE格式的图片 |