mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2026-07-08 20:47:14 +08:00
fix webcam index selection
This commit is contained in:
parent
bc4890f798
commit
6e3af6e7b9
@ -490,11 +490,14 @@ Can be used for realtime diffusion with autoqueue.
|
|||||||
}
|
}
|
||||||
|
|
||||||
def capture(self, x, y, cam_index, width, height, release):
|
def capture(self, x, y, cam_index, width, height, release):
|
||||||
|
# Check if the camera index has changed or the capture object doesn't exist
|
||||||
if not hasattr(self, "cap") or self.cap is None:
|
if not hasattr(self, "cap") or self.cap is None or self.current_cam_index != cam_index:
|
||||||
|
if hasattr(self, "cap") and self.cap is not None:
|
||||||
|
self.cap.release()
|
||||||
|
self.current_cam_index = cam_index
|
||||||
self.cap = cv2.VideoCapture(cam_index)
|
self.cap = cv2.VideoCapture(cam_index)
|
||||||
if not self.cap.isOpened():
|
if not self.cap.isOpened():
|
||||||
raise Exception("Could not open webcam")
|
raise Exception("Could not open webcam")
|
||||||
|
|
||||||
ret, frame = self.cap.read()
|
ret, frame = self.cap.read()
|
||||||
if not ret:
|
if not ret:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user