This node was created to send a webcam/screen to ComfyUI in real time.
This node is recommended for use with LCM/SDXL turbo
75.mp4
(This video is at 4x speed)
Update
2024/11/14 - Add Load Random Text From File node
2024/11/04 - Add Export glb node.
2024/11/02 - Add remove noise node for normal map. Added sobel ratio for more accurate Noraml.
2024/10/25 - Add depth to normal node.
2024/08/11 - Add Direct_screenCap node.
2023/11/24 - AddSave image to path node. Add Render preview, Add export video, Add face detection (After the update, you will need to run CaptrueCam/setup.bat one more time.)
2023/11/29 - Add Region Capture. Made the Webcam app UI smaller.
2023/12/1 - Add Ai render overlay
-
Git clone this repo to the ComfyUI/custom_nodes path.
git clone https://github.com/toyxyz/ComfyUI_toyxyz_test_nodes
-
Run setup.bat in
ComfyUI/custom_nodes/ComfyUI_toyxyz_test_nodes/CaptureCam
Default workflow (Workflow embedded)
Render preview workflow (Workflow embedded)
Direct Webcam capture workflow (without webcam app) (Workflow embedded)
Retrieves the entire text or random lines from a txt file at the entered path.
file_paht : The path to the text file or the path where the files are located
seed : seed for random line
edit_text : Edit tag_(tag) to tag (tag)
get_random_line : Get random line from txt. False for get entire text
get_random_txt_from_path : Randomly use one of all text files located in the entered path instead of one text file.
strength : Adjust the strength of the prompt.
ban_tag : Prompts to exclude.
text : Multi-line text as an alternative to text files
use_index : Gets text from the line corresponding to index instead of a random line.
index : The index of the line.
Export a flat .glb file with a color image, normal map, and alpha mask.
You can specify the roughness, metallic, and save path.
guided_first : Apply guided filter first.
Remove noise from an image. Can be used to clean a normal map.
bilateral_loop: The number of times to apply the bilateralFilter. If 0, it is not used.
d/sigma_color/sigma_space : bilateralFilter parameters
guided_loop: The number of iterations of the guidedFilter. If 0, it is not used.
radius/eps: guidedFilter parameters.
Converts a depth image to a normal map. It works very well with 2D images and DepthAnything v2.
depth_min : Depths lower than this value are replaced with 0.
blue_depth : Adjusts the intensity of the blue channel of the normal map to emphasize depth. The lower this number, the stronger the depth.
sobel_ratio : Makes the Normal map more stereoscopically accurate. Values between 0.1 and 0.3 are recommended.
Captures an image from a specified window or screen.
capture_mode Default : Capture a defined area of the monitor window : Captures the area of the window entered in target_window window_crop : Same as window, but cuts off and captures the area relative to that window.
target_window : Name of the window to capture. You can find its name in the list of windows in the Webcam app.
Load an image from a path.
To use this node with webcam, you must first run run.bat in ComfyUI/custom_nodes/ComfyUI_toyxyz_test_nodes/CaptureCam
.
And in the Webcam app, you'll need to select your webcam and run capture with start.
Captures an image directly from the webcam selected with 'select_webcam'. (Usually 0)
This is unstable compared to the Load Webcam Image node.
If you're using obs, I recommend using the Load Webcam Image node.
This node saves the generated images to a defined path.
If save_sequence is true, it saves the images in order without overwriting them.
Set the delay between image generation.
Resizes the image while maintaining its proportions and painting the margins with the color you specify.
This script captures the selected webcam and saves it as an image file in real-time.
You can specify the resolution, format, and path of the image to be saved.
If you don't enter a path, it will be saved to the default path.
You can combine a sequence of saved images into a video using the Export button. Make sure to set save_sequence in Save Image to Path to true.
To use AI Render, you need a Save Image to Path node.
If you entered a location other than the default path in Save Image to Path, you must select a newly created render image in Select Rendered image.
Run_hide_cmd.vbs : Hide the cmd and run the app.
Webcam : List of camera devices connected to your computer
Width: Sets the width of the image.
Height: Sets the height of the image.
If either the width or height is zero, it will be automatically adjusted to fit the other values entered.
FPS : Set how often the capture occurs. If you enter 0, it is unlimited.
Webcam(Checkbox) : Preview the captured image.
Al Render: Preview the generated image in ComfyUi.
Always on top : Webcam, AI Render is always visible on top. To disable it, you need to close the preview window.
Face detect : Automatically recognize faces and generate masks. It is stored as face_mask.jpg. Use with inpainting.
Keep aspect ratio : Correct the aspect ratio of the image and the capture window.
Capture Path: The path where the captured image will be saved.
Render image: Path to the image generated by ComfyUI. Required to use AI Render.
If you don't enter a path, the default path is used.
Save format: Set the image format to be saved
Overlay alhpa : The alpha value of the overlay image displayed above the region capture window.
Padding: Set how to fill the margins of the image when using Keep aspect ratio.
Export video: Combines the image sequences located in the render image folder into a single video. Enter the desired FPS value.
Clear after export: Deletes the image sequence after the video is exported.
Add region window: Creates a window to specify the region to capture.
The name of the window is the same as entered in Save name. If you enter comma-separated text (e.g., A,B,C), you can use one Region window to capture three images, A, B, and C, alternating between them.
Save name: Set a name for the captured image.
Window list: Select the windows to capture. Other windows will not be captured. If set to Disable, it will be captured as it is displayed on the screen. Window capture is often unstable depending on the program. Be careful when using it.
Reload list: Refresh the list of webcams and windows.
The name of the currently captured and saved image file and the selected Region window are displayed in the Webcam/Ai Render preview window.
If you select 'Region Capture' from the Webcam list, it will capture the region of the window added with 'Add Region window'. If you select 'Window Capture', it will capture the entire window selected in the window list.
https://github.com/toyxyz/ComfyUI_toyxyz_test_nodes/assets/8006000/8723e014-caa5-4e16-8c8c-5c5edac6f141
S: Saves the image displayed in the current AI render to the render folder. Activate (click) the AI render window and then use it.
F : Toggles the Region widow (target window list selected) to full window mode. Select the target Region window and then click Use.
A : Select the Region window currently being captured. Enable the AI render or Webcam preview window, then use it.
C: Change the region window. Select the desired Region window and press the key to switch to that window. When used in the Ai Render or Webcam window, the Region windows are switched in the order they were created.
X: If the Region windows were created separated by commas, pressing the key while Ai Render or Webcam is active will switch the name of the captured image.
Q: Copy the image displayed in AI render to the clipboard. Activate AI render and then use.
M: Mask paint toggle. Allows you to paint the mask directly in the Webcam preview window. Paint with the left mouse and erase with the right. You can change the brush size with the mouse wheel. The mask is saved as the captured image name + '_mask'.
N: Erase all painted masks.
Z: Pause image capture. Use for Webcam or AI Render.
P: Displays the AI Render image as an overlay on the currently selected Region window. This is unstable and should be used with caution. It can only be enabled/disabled when capture is stopped and requires a target window to be set. Does not run even if there is no render image to load.
Load the image file saved with the Save image to path node. Pressing 'Q' while the window is active will copy the preview image to the clipboard.
Detect faces and create masks. Use it for inpainting with the Load Webcam Image node.
The ControlNet preprocessor slows down the process, so I recommend using other tools to prepare the ControlNet image.
If you want ComfyUI to run continuously, use Auto Queue.
For maximum speed, set the VAE to taesd.