async def btn_reload_model_clicked(self):
     try:
         await DetectorConfig.instance().get_manager().load_model(
             self.__current_cfg)
         helpers.show_message("Finish reloading model")
     except:
         helpers.show_message("Error reloading model")
Example #2
0
 def change_progress_screen(self):
     err_mess = self.progress_screen.validate_show()
     if err_mess is not None:
         helpers.show_message(err_mess)
         return
     self.__video_camera.release()
     self.stop_capture()
     self.ui.centralStackWidget.setCurrentWidget(self.progress_screen)
Example #3
0
 def btn_detect_clicked(self):
     manager = DetectorConfig.instance().get_manager()
     if self.__last_pair is not None and manager.get_model() is not None:
         if len(self.__last_pair) == 0:
             helpers.show_message("No pair detected")
             return
         images = [img.copy() for idx, img in enumerate(self.__last_pair)]
         runnable = WorkerRunnable(self.__detect_error, images, parent=self)
         runnable.work_error.connect(lambda ex: print(ex))
         QThreadPool.globalInstance().start(runnable)
 def btn_add_clicked(self):
     detector_cfg = DetectorConfig.instance()
     manager = detector_cfg.get_manager()
     table = self.ui.tblCameraConfig
     camera_name = self.ui.txtNewCamera.text().strip()
     err_text = detector_cfg.validate_config_name(camera_name)
     if err_text is not None:
         helpers.show_message(err_text)
         return
     new_cfg = detector.default_detector_config()
     new_cfg["name"] = camera_name
     detector_cfg.add_config(new_cfg)
     self.__add_new_row(table, camera_name, "Side camera")
Example #5
0
 def skipable_change_detect_pair_screen(self):
     idx, cfg = self.__detector_cfg.get_current_cfg()
     continue_screen = cfg["is_main"]
     if continue_screen:
         self.ui.centralStackWidget.setCurrentWidget(
             self.test_detect_pair_screen)
     else:
         err_text = self.side_error_detect_screen.validate_show()
         if err_text is not None:
             helpers.show_message(err_text)
             return
         # skip to screen 6 if only side camera is selected
         self.ui.centralStackWidget.setCurrentWidget(
             self.side_error_detect_screen)
 def btn_save_sample_clicked(self):
     if self.__detected_pair is not None:
         left, right = self.__detected_pair
         folder_path = DetectorConfig.instance().get_current_path()
         if folder_path is None:
             helpers.show_message("You must save configuration first")
             return
         cv2.imwrite(os.path.join(folder_path, detector.SAMPLE_LEFT_FILE),
                     left)
         cv2.imwrite(os.path.join(folder_path, detector.SAMPLE_RIGHT_FILE),
                     right)
         DetectorConfig.instance().get_manager().load_sample_images()
         helpers.show_message("Save successfully")
         self.__set_btn_next_enabled()
 def chk_main_camera_state_changed(self):
     is_checked = self.ui.chkMainCamera.isChecked()
     is_main = self.__current_cfg["is_main"]
     if is_main != is_checked and self.__actual_length_edited:
         helpers.show_message("You must save actual length first")
         self.ui.chkMainCamera.setCheckState(
             Qt.CheckState.Checked if not is_checked else Qt.CheckState.
             Unchecked)
         return
     elif is_main == is_checked:
         return
     DetectorConfig.instance().get_manager().set_main_config(
         self.__current_cfg["name"] if is_checked else None)
     self.__change_ui_based_on_is_main()
 def table_action_edit_name_triggered(self):
     table = self.ui.tblCameraConfig
     chosen_row = table.currentRow()
     detector_cfg = DetectorConfig.instance()
     camera_name = table.item(chosen_row, 0).text()
     dialog = DialogEditName(camera_name, parent=self)
     choice = dialog.exec_()
     if choice != QDialog.Accepted:
         return
     new_name = dialog.get_inp_edit_name().strip()
     err_text = detector_cfg.validate_config_name(new_name)
     if err_text is not None:
         helpers.show_message(err_text)
         return
     _, cfg = detector_cfg.get_current_cfg()
     cfg["name"] = new_name
     self.__reload_table()
Example #9
0
 async def action_load_config_triggered(self):
     url = helpers.file_chooser_open_directory(self)
     if url.isEmpty(): return
     file_path = url.toLocalFile()
     self.stop_capture()
     self.__detector_cfg.reset()
     manager = FQCSManager(config_folder=file_path)
     configs = manager.get_configs()
     for cfg in configs:
         if cfg["is_main"] == True:
             self.__detector_cfg.set_current_cfg_name(cfg["name"])
             try:
                 await manager.load_model(cfg)
             except:
                 helpers.show_message("Error loading model")
             break
     self.__detector_cfg.set_manager(manager)
     self.__detector_cfg.set_current_path(file_path)
     self.__detector_cfg.manager_changed.emit()
     self.change_home_screen()
 def btn_login_clicked(self):
     username = self.ui.inpAcc.text().strip()
     password = self.ui.inpPass.text().strip()
     if not username or not password:
         helpers.show_message("Username and password must not be empty!")
     else:
         is_success, resp = self.__identity_service.log_in(
             username, password)
         if is_success and self.__identity_service.is_device_account(resp):
             self.__identity_service.save_token_json(resp)
             self.__identity_service.check_token()
         else:
             if is_success is not None:
                 helpers.show_message("Invalid account or password")
             else:
                 helpers.show_message("Something's wrong")