From 5568cff68adc54ab05b0edd688c08ab69836c833 Mon Sep 17 00:00:00 2001 From: Mario Klingemann Date: Fri, 26 Jul 2024 22:15:53 +0200 Subject: [PATCH] Update image_nodes.py Trying to set capture size for cameras that support multiple resolutions. Might be better to use two separate values for that or query the camera's native resolutions, but for now that's what I needed. --- nodes/image_nodes.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nodes/image_nodes.py b/nodes/image_nodes.py index 570922e..32b78a0 100644 --- a/nodes/image_nodes.py +++ b/nodes/image_nodes.py @@ -496,6 +496,11 @@ Can be used for realtime diffusion with autoqueue. self.cap.release() self.current_cam_index = cam_index self.cap = cv2.VideoCapture(cam_index) + try: + self.cap.set(cv2.CAP_PROP_FRAME_WIDTH, width) + self.cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height) + except: + pass if not self.cap.isOpened(): raise Exception("Could not open webcam") @@ -1663,4 +1668,4 @@ class LoadAndResizeImage: if not folder_paths.exists_annotated_filepath(image): return "Invalid image file: {}".format(image) - return True \ No newline at end of file + return True