Nodes/ComfyUI_Camera/Load Image From Local Camera
ComfyUI Node

Load Image From Local Camera

Feed your webcam into ComfyUI, one frame at a time

By xuhongming251·Created 2 years ago·Updated about a year ago· 7
Load Image From Local Camera
    • image

    Your webcam, live, as an IMAGE tensor inside the graph. That's the whole pitch of Load Image From Local Camera, and for once the name is basically accurate.

    This is the input half of the ComfyUI_Camera pack. It grabs the current frame from your webcam and hands it to the rest of your workflow as a normal image tensor. Wire it into anything that takes an image - img2img, a ControlNet depth or pose preprocessor, an IP-Adapter for identity - and every time the graph runs it pulls a fresh frame instead of reading a file off disk. That one difference turns a still-image workflow into a live camera filter.

    It's not the only way to get live video into ComfyUI, but it's close to the simplest: no API key, no cloud service, no external capture app. The whole pipeline runs over local shared memory. The cost of that simplicity shows up in speed and in a few sharp edges below.

    How it works

    The node itself is almost embarrassingly thin - and that's by design. The actual camera work happens in a separate Python process the pack launches for you.

    1. After install, right-click the canvas and pick Start Local Camera. That POSTs to a /start_camera route the pack adds to ComfyUI's server, which spawns two child processes. One (preview_camera.py) opens your default webcam with OpenCV, pops a small resolution dialog, and writes frames into a shared-memory block named camera_to_comfy at roughly 30fps.
    2. This node reads that block, converts the frame from BGRA to RGB, normalizes it to 0–1, wraps it in a torch tensor, and returns it as a one-image batch ([1, H, W, 3]) - exactly the shape a normal Load Image node hands downstream.

    The clever bit is IS_CHANGED. ComfyUI skips nodes whose inputs didn't change. This node has no inputs, so without help it would run once and never again. The pack toggles a counter on every call so ComfyUI always sees it as changed and re-executes it each time you queue. That trick is what makes "live" possible: keep hitting Queue Prompt and every pass picks up the newest frame.

    Inputs and outputs

    There are no inputs at all. Just one output:

    • image (IMAGE) - the current camera frame as a float tensor. VAE Encode it for img2img (keep the denoise low if you want the subject recognizable), run it through a ControlNet preprocessor for structure, or feed it to an IP-Adapter for identity.

    The demo workflow in the repo is simply this node → ImageInvert → Save Image To Local Camera. Run that first; it's a cheap sanity check that the plumbing works before you bolt on a sampler.

    Installing it

    cd ComfyUI/custom_nodes
    git clone https://github.com/xuhongming251/ComfyUI_Camera
    cd ComfyUI_Camera
    pip install -r requirements.txt
    

    Then restart ComfyUI. Dependencies are light - opencv-python, numpy, psutil - and there are no model downloads. ComfyUI Manager users can just search "ComfyUI_Camera". One gotcha: the child process runs with sys.executable, the same Python that's running ComfyUI, so opencv has to be in that environment - not just installed somewhere on your machine.

    Common issues

    • "Shared memory not found, waiting..." on loop. You queued the graph before starting the camera, or the camera process died. Right-click → Start Local Camera first, then queue. The node blocks in that loop until the memory exists.
    • No webcam on the machine. The README suggests OBS's virtual camera, which works fine - it just registers as a normal capture device.
    • Cloud or remote setups won't work. The camera, ComfyUI, and the preview windows all have to share one machine. Shared memory doesn't cross machines, and the README says so outright.
    • Headless Linux. The resolution picker is a tkinter dialog, so it needs a desktop display. The README only claims Windows and Mac.
    • Speed. The preview windows are native desktop windows, not in your browser. And ComfyUI re-runs the whole graph per frame, so don't expect the 10+ fps people get from StreamDiffusion or DaydreamLive. Keep the graph small - low resolution, a few steps, a Turbo or LCM model - and it's plenty for a fun live filter.
    CategoryLocalCamera

    Inputs (0)

    No inputs

    Outputs (1)

    NameTypeDescription
    imageIMAGE