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:
|
if re_name:
|
||||||
device_name = re_name.group(1)
|
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:
|
try:
|
||||||
capture = cv2.VideoCapture(device_path)
|
if not is_gray(frame):
|
||||||
capture.grab()
|
raise Exception()
|
||||||
ret, frame = capture.read()
|
|
||||||
except Exception:
|
except Exception:
|
||||||
device_rows.append([device_name, device_path, -9, _("No, camera can't be opened")])
|
device_rows.append([device_name, device_path, -5, _("No, camera can't be opened")])
|
||||||
continue
|
capture.release()
|
||||||
|
|
||||||
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")])
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
device_rows.append([device_name, device_path, 5, _("Yes, compatible infrared camera")])
|
device_rows.append([device_name, device_path, 5, _("Yes, compatible infrared camera")])
|
||||||
|
|
||||||
capture.release()
|
capture.release()
|
||||||
|
|
||||||
device_rows = sorted(device_rows, key=lambda k: -k[2])
|
device_rows = sorted(device_rows, key=lambda k: -k[2])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue