mirror of
https://github.com/boltgolt/howdy.git
synced 2024-09-19 09:51:19 +02:00
check camera opening (fix is_gray(None))
This commit is contained in:
parent
0e4aaa0c47
commit
2e2c1ac196
1 changed files with 10 additions and 17 deletions
|
@ -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])
|
||||
|
|
Loading…
Reference in a new issue