ComfyUI/comfy_extras/nodes_webcam.py
easonysliu 197dba5b69 fix: respect capture_on_queue flag in WebcamCapture.IS_CHANGED
When capture_on_queue is True, the node should always re-execute on
each queue operation. Previously IS_CHANGED ignored this flag and always
returned the file hash, causing the node to be skipped if the cached
image hadn't changed on disk - defeating the purpose of the option.
2026-04-09 14:20:27 +08:00

41 lines
1.1 KiB
Python

import nodes
import folder_paths
MAX_RESOLUTION = nodes.MAX_RESOLUTION
class WebcamCapture(nodes.LoadImage):
SEARCH_ALIASES = ["camera input", "live capture", "camera feed", "snapshot"]
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"image": ("WEBCAM", {}),
"width": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION, "step": 1}),
"height": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION, "step": 1}),
"capture_on_queue": ("BOOLEAN", {"default": True}),
}
}
RETURN_TYPES = ("IMAGE",)
FUNCTION = "load_capture"
CATEGORY = "image"
def load_capture(self, image, **kwargs):
return super().load_image(folder_paths.get_annotated_filepath(image))
@classmethod
def IS_CHANGED(cls, image, width, height, capture_on_queue):
if capture_on_queue:
return float("NaN")
return super().IS_CHANGED(image)
NODE_CLASS_MAPPINGS = {
"WebcamCapture": WebcamCapture,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"WebcamCapture": "Webcam Capture",
}