From d3541cf3c005430236ae58a779b99238df25072e Mon Sep 17 00:00:00 2001 From: EmixamPP Date: Thu, 30 Jun 2022 15:35:27 +0200 Subject: [PATCH 1/2] display linux-enable-ir-emitter help --- howdy-gtk/src/onboarding.glade | 381 ++++++++++++++++++++------------- howdy-gtk/src/onboarding.py | 58 ++++- 2 files changed, 282 insertions(+), 157 deletions(-) diff --git a/howdy-gtk/src/onboarding.glade b/howdy-gtk/src/onboarding.glade index cd4dbe2..27f814d 100644 --- a/howdy-gtk/src/onboarding.glade +++ b/howdy-gtk/src/onboarding.glade @@ -1,56 +1,56 @@ - + True - False - 4 + False + 4 gtk-cancel True - False - 5 + False + 5 gtk-apply True - False - 4 + False + 4 gtk-go-forward True - False - 5 + False + 5 gtk-media-play - 500 - 400 - False + 500 + 400 + False Welcome to Howdy - center + center logo.png - menu + menu center True - False - immediate + False + immediate vertical - - False - True + + False + True vertical True - False - 20 + False + 20 Setup is done! @@ -65,11 +65,11 @@ True - False - 10 - 10 - 10 - 20 + False + 10 + 10 + 10 + 20 We're done! Howdy is now active on this computer. Try doing anything you would normally have to type your password for to authenticate, like running a command with sudo. You can open the Howdy Configurator later on to change more advanced settings or add additional models. Press Finish below to close this window and open the Howdy Configurator. @@ -90,15 +90,15 @@ You can open the Howdy Configurator later on to change more advanced settings or - - False - True + + False + True vertical True - False - 20 + False + 20 Setting a certainty policy @@ -113,11 +113,11 @@ You can open the Howdy Configurator later on to change more advanced settings or True - False - 10 - 10 - 10 - 40 + False + 10 + 10 + 10 + 40 Because of changes in angles, distance, and other factors a face match is never exactly the same as the stored face model. On this page you can set how strict Howdy should be. center True @@ -131,31 +131,31 @@ You can open the Howdy Configurator later on to change more advanced settings or True - False - 60 - 60 + False + 60 + 60 vertical True - True - False - 10 + True + False + 10 0 - 0.50999999046325684 + 0.5099999904632568 True - True + True radiobalanced True - False - 5 + False + 5 vertical True - False + False start Fast @@ -171,7 +171,7 @@ You can open the Howdy Configurator later on to change more advanced settings or True - False + False start Allows more fuzzy matches, but speeds up the scanning process greatly. @@ -195,22 +195,22 @@ but speeds up the scanning process greatly. True - True - False - 10 + True + False + 10 0 True - True + True True - False - 5 + False + 5 vertical True - False + False start Balanced @@ -226,7 +226,7 @@ but speeds up the scanning process greatly. True - False + False start Still relatively quick detection, but might not log you in when further away. @@ -250,22 +250,22 @@ but might not log you in when further away. True - True - False + True + False 0 True - True + True radiobalanced True - False - 5 + False + 5 vertical True - False + False start Secure @@ -281,7 +281,7 @@ but might not log you in when further away. True - False + False start The slightly safer option, but will take much longer to authenticate you @@ -317,15 +317,15 @@ but will take much longer to authenticate you - - False - True + + False + True vertical True - False - 20 + False + 20 Adding a face model @@ -340,11 +340,11 @@ but will take much longer to authenticate you True - False - 10 - 10 - 10 - 20 + False + 10 + 10 + 10 + 20 To authenticate you Howdy needs to save a model of your face to recognise you. Press the Scan button below to start the facial scan. center True @@ -358,7 +358,7 @@ but will take much longer to authenticate you True - False + False @@ -366,16 +366,16 @@ but will take much longer to authenticate you Start face scan True - True - True - True - True - 50 - 50 + True + True + True + True + 50 + 50 iconscan none - right - True + right + True @@ -401,16 +401,101 @@ but will take much longer to authenticate you 2 + + + False + True + vertical + + + True + False + 20 + Configuring webcam + + + + + + False + True + 0 + + + + + True + False + 10 + 20 + Is the infrared emitter flashing ? + center + True + False + + + False + True + 1 + + + + + True + False + spread + + + yes + True + True + True + + + + True + True + 0 + + + + + no + True + True + True + + + + True + True + 1 + + + + + False + True + 2 + + + + + False + True + 3 + + - False - True + False + True vertical True - False - 20 + False + 20 Configuring webcam @@ -425,11 +510,11 @@ but will take much longer to authenticate you True - False - 10 - 10 - 10 - 20 + False + 10 + 10 + 10 + 20 Howdy will search your system automatically for any available cameras, so make sure your webcam is connected. After detection a list of usable webcams will be shown. Pick the one you want to use and click Next. center True @@ -443,16 +528,16 @@ but will take much longer to authenticate you True - False - 0.89000000000000001 - 10 - 10 + False + 0.89 + 10 + 10 vertical True - False - 15 + False + 15 Testing your webcams, please wait... @@ -478,20 +563,20 @@ but will take much longer to authenticate you False True - 3 + 4 - False - True - 10 + False + True + 10 vertical True - False - 20 + False + 20 Downloading data files @@ -506,11 +591,11 @@ but will take much longer to authenticate you True - False - 10 - 10 - 10 - 20 + False + 10 + 10 + 10 + 20 Howdy needs three pre trained facial recognition datasets to be able to recognise you, which will be downloaded now. You can see the download progress below. center True @@ -524,14 +609,14 @@ but will take much longer to authenticate you True - False + False True - False - 10 - 10 - 10 + False + 10 + 10 + 10 Starting download... center @@ -551,19 +636,19 @@ but will take much longer to authenticate you True True - 4 + 5 True - False + False vertical - False - 20 - 10 + False + 20 + 10 7 13 logo_about.png @@ -577,8 +662,8 @@ but will take much longer to authenticate you True - False - 5 + False + 5 Welcome to Howdy! @@ -592,14 +677,14 @@ but will take much longer to authenticate you - 100 + 100 True - False + False center center - 20 - 20 - 10 + 20 + 20 + 10 This wizard will walk you through the setup process and automatically configure Howdy for you. Press next to continue. center True @@ -614,23 +699,23 @@ but will take much longer to authenticate you False True - 5 + 6 True - False - 10 + False + 10 Cancel True - True - True - 10 + True + True + 10 iconcancel - True + True @@ -646,40 +731,40 @@ but will take much longer to authenticate you Next True - True - True - True - True - 10 + True + True + True + True + 10 iconforward none - right - True + right + True False True - end + end 2 Finish setup - True - True - True - 10 + True + True + True + 10 iconfinish none - True + True False True - end + end 3 @@ -687,8 +772,8 @@ but will take much longer to authenticate you False True - end - 8 + end + 9 diff --git a/howdy-gtk/src/onboarding.py b/howdy-gtk/src/onboarding.py index 4ed3406..792ad81 100644 --- a/howdy-gtk/src/onboarding.py +++ b/howdy-gtk/src/onboarding.py @@ -1,5 +1,6 @@ import sys import os +import glob import re import time import subprocess @@ -34,7 +35,8 @@ class OnboardingWindow(gtk.Window): self.builder.get_object("slide2"), self.builder.get_object("slide3"), self.builder.get_object("slide4"), - self.builder.get_object("slide5") + self.builder.get_object("slide5"), + self.builder.get_object("slide6") ] self.window.show_all() @@ -62,6 +64,8 @@ class OnboardingWindow(gtk.Window): self.execute_slide4() elif self.window.current_slide == 5: self.execute_slide5() + elif self.window.current_slide == 6: + self.execute_slide6() def execute_slide1(self): self.downloadoutputlabel = self.builder.get_object("downloadoutputlabel") @@ -124,19 +128,18 @@ class OnboardingWindow(gtk.Window): except Exception: self.show_error(_("Error while importing OpenCV2"), _("Try reinstalling cv2")) - device_ids = os.listdir("/dev/v4l/by-path") + device_ids = glob.glob("/dev/video*") device_rows = [] if not device_ids: self.show_error(_("No webcams found on system"), _("Please configure your camera yourself if you are sure a compatible camera is connected")) # Loop though all devices - for dev in device_ids: + for device_path in device_ids: time.sleep(.5) # The full path to the device is the default name - device_path = "/dev/v4l/by-path/" + dev - device_name = dev + device_name = device_path[:] # Get the udevadm details to try to get a better name udevadm = subprocess.check_output(["udevadm info -r --query=all -n " + device_path], shell=True).decode("utf-8") @@ -184,10 +187,11 @@ class OnboardingWindow(gtk.Window): self.devicelistbox.add(self.treeview) # Create a datamodel - self.listmodel = gtk.ListStore(str, str, str) + self.listmodel = gtk.ListStore(str, str, str, bool) for device in device_rows: - self.listmodel.append([device[0], device[3], device[1]]) + is_gray = device[2] == 5 + self.listmodel.append([device[0], device[3], device[1], is_gray]) self.treeview.set_model(self.listmodel) self.treeview.set_cursor(0) @@ -197,6 +201,42 @@ class OnboardingWindow(gtk.Window): self.enable_next() def execute_slide3(self): + try: + import cv2 + except Exception: + self.show_error(_("Error while importing OpenCV2"), _("Try reinstalling cv2")) + + selection = self.treeview.get_selection() + (listmodel, rowlist) = selection.get_selected_rows() + + if len(rowlist) != 1: + self.show_error(_("Error selecting camera")) + + device_path = listmodel.get_value(listmodel.get_iter(rowlist[0]), 2) + is_gray = listmodel.get_value(listmodel.get_iter(rowlist[0]), 3) + + if is_gray: + # test if linux-enable-ir-emitter help should be displayed, + # the user must click on the yes/no button which calls the method slide3_button_yes|no + self.capture = cv2.VideoCapture(device_path) + if not self.capture.isOpened(): + self.show_error(_("The selected camera cannot be opened"), _("Try to select another one")) + self.capture.read() + else: + # skip, the selected camera is not infrared + self.go_next_slide() + + def slide3_button_yes(self, button): + self.capture.release() + self.go_next_slide() + + def slide3_button_no(self, button): + self.capture.release() + self.builder.get_object("leiestatus").set_markup(_("Please visit\nhttps://github.com/EmixamPP/linux-enable-ir-emitter\nto enable your ir emitter")) + self.builder.get_object("leieyesbutton").hide() + self.builder.get_object("leienobutton").hide() + + def execute_slide4(self): selection = self.treeview.get_selection() (listmodel, rowlist) = selection.get_selected_rows() @@ -235,10 +275,10 @@ class OnboardingWindow(gtk.Window): gobject.timeout_add(10, self.go_next_slide) - def execute_slide4(self): + def execute_slide5(self): self.enable_next() - def execute_slide5(self): + def execute_slide6(self): radio_buttons = self.builder.get_object("radiobalanced").get_group() radio_selected = False radio_certanty = 5.0 From c1214ad9196766cf8e9db0acdec810ebf0f8cb52 Mon Sep 17 00:00:00 2001 From: EmixamPP Date: Thu, 30 Jun 2022 16:55:29 +0200 Subject: [PATCH 2/2] undo device path change --- howdy-gtk/src/onboarding.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/howdy-gtk/src/onboarding.py b/howdy-gtk/src/onboarding.py index 792ad81..0dde535 100644 --- a/howdy-gtk/src/onboarding.py +++ b/howdy-gtk/src/onboarding.py @@ -1,6 +1,5 @@ import sys import os -import glob import re import time import subprocess @@ -128,18 +127,19 @@ class OnboardingWindow(gtk.Window): except Exception: self.show_error(_("Error while importing OpenCV2"), _("Try reinstalling cv2")) - device_ids = glob.glob("/dev/video*") + device_ids = os.listdir("/dev/v4l/by-path") device_rows = [] if not device_ids: self.show_error(_("No webcams found on system"), _("Please configure your camera yourself if you are sure a compatible camera is connected")) # Loop though all devices - for device_path in device_ids: + for dev in device_ids: time.sleep(.5) # The full path to the device is the default name - device_name = device_path[:] + device_path = "/dev/v4l/by-path/" + dev + device_name = dev # Get the udevadm details to try to get a better name udevadm = subprocess.check_output(["udevadm info -r --query=all -n " + device_path], shell=True).decode("utf-8")