remove cropping

this logic was duplicative. there are native nodes in comfyui for both resizing and cropping.
This commit is contained in:
RyanOnTheInside
2025-05-03 16:47:53 -04:00
parent 3badc92b59
commit a1e3af7c19
2 changed files with 15 additions and 18 deletions
+11 -10
View File
@@ -55,9 +55,7 @@ class FastWebcamCapture:
return {
"required": {
"image": ("WEBCAM", {}),
"width": ("INT", {"default": 640, "min": 0, "max": MAX_RESOLUTION, "step": 1}),
"height": ("INT", {"default": 480, "min": 0, "max": MAX_RESOLUTION, "step": 1}),
"capture_on_queue": ("BOOLEAN", {"default": True}),
"capture_on_queue": ("BOOLEAN", {"default": True, "tooltip": "Whether to capture the frame when the node is queued"}),
}
}
@@ -66,7 +64,13 @@ class FastWebcamCapture:
CATEGORY = "image"
def process_capture(self, image, width, height, capture_on_queue):
def process_capture(self, image, capture_on_queue):
"""
Process a webcam image at native resolution.
This node simply captures the webcam feed at its native resolution.
For resizing or cropping, use standard ComfyUI nodes after this one.
"""
# Check if we got a data URL
if isinstance(image, str) and image.startswith("data:image/"):
# Extract the base64 data after the comma
@@ -75,16 +79,13 @@ class FastWebcamCapture:
# Convert base64 to PIL Image
buffer = BytesIO(base64.b64decode(base64_data))
pil_image = Image.open(buffer).convert("RGB")
# Log the image size we're receiving from the webcam
print(f"Webcam image size: {pil_image.width}x{pil_image.height}")
# Convert PIL to numpy array
image = np.array(pil_image)
# Handle resize if requested
if width > 0 and height > 0:
import cv2
image = cv2.resize(image, (width, height), interpolation=cv2.INTER_AREA)
# Convert to float32 and normalize to 0-1 range
image = image.astype(np.float32) / 255.0
+4 -8
View File
@@ -66,9 +66,6 @@ app.registerExtension({
const r = onNodeCreated ? onNodeCreated.apply(this, arguments) : undefined;
const camera = this.widgets.find((w) => w.name === "image");
const w = this.widgets.find((w) => w.name === "width");
const h = this.widgets.find((w) => w.name === "height");
const canvas = document.createElement("canvas");
camera.serializeValue = async () => {
@@ -82,20 +79,19 @@ app.registerExtension({
}
console.log("Capturing frame from video:", {
paused: webcamVideo.paused,
readyState: webcamVideo.readyState,
videoWidth: webcamVideo.videoWidth,
videoHeight: webcamVideo.videoHeight
});
canvas.width = w.value || webcamVideo.videoWidth || 640;
canvas.height = h.value || webcamVideo.videoHeight || 480;
// Always use native webcam resolution
canvas.width = webcamVideo.videoWidth;
canvas.height = webcamVideo.videoHeight;
const ctx = canvas.getContext("2d");
ctx.drawImage(webcamVideo, 0, 0, canvas.width, canvas.height);
const dataUrl = canvas.toDataURL("image/png");
// console.log("Successfully captured and converted frame to data URL");
console.log("Captured frame at native resolution:", canvas.width, "x", canvas.height);
return dataUrl;
};