From 2e2c1ac1969e65c6ca992bb43e7233c2733d8d38 Mon Sep 17 00:00:00 2001 From: EmixamPP Date: Sat, 30 Oct 2021 13:58:36 +0200 Subject: [PATCH] check camera opening (fix is_gray(None)) --- howdy-gtk/src/onboarding.py | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/howdy-gtk/src/onboarding.py b/howdy-gtk/src/onboarding.py index 124a663..301ea09 100644 --- a/howdy-gtk/src/onboarding.py +++ b/howdy-gtk/src/onboarding.py @@ -148,28 +148,21 @@ class OnboardingWindow(gtk.Window): if re_name: device_name = re_name.group(1) + capture = cv2.VideoCapture(device_path) + is_open, frame = capture.read() + if not is_open: + device_rows.append([device_name, device_path, -9, _("No, not an infrared camera")]) + continue + try: - capture = cv2.VideoCapture(device_path) - capture.grab() - ret, frame = capture.read() + if not is_gray(frame): + raise Exception() except Exception: - device_rows.append([device_name, device_path, -9, _("No, camera can't be opened")]) - continue - - if not is_gray(frame): - device_rows.append([device_name, device_path, -5, _("No, not an infrared camera")]) - continue - - time.sleep(.2) - - ret, frame = capture.read() - - if not is_gray(frame): - device_rows.append([device_name, device_path, -5, _("No, not an infrared camera")]) + device_rows.append([device_name, device_path, -5, _("No, camera can't be opened")]) + capture.release() continue device_rows.append([device_name, device_path, 5, _("Yes, compatible infrared camera")]) - capture.release() device_rows = sorted(device_rows, key=lambda k: -k[2])