def __write_settings(self): """ Zapisz wartości z widgetów """ Configuration.distance_border1(self.border1_adjustment.get_value()) Configuration.distance_border2(self.border2_adjustment.get_value()) Configuration.meters_length( self.meters_length_spin_adjustment.get_value()) Configuration.color_number( self.color_number_spin_adjustment.get_value()) Configuration.horizontal_border( self.horizontal_border_spin_adjustment.get_value()) Configuration.vertical_border( self.vertical_border_spin_adjustment.get_value()) Configuration.pixel_limit(self.pixel_limit_spin_adjustment.get_value()) Configuration.distance_from_border( self.distance_from_border_spin_adjustment.get_value()) Configuration.draw_detection_region( self.draw_detection_region_check.get_active()) Configuration.draw_speed_region( self.draw_speed_region_check.get_active()) Configuration.draw_cars(self.draw_cars_check.get_active()) Configuration.draw_conturs(self.draw_conturs_check.get_active()) Configuration.draw_speed_info(self.draw_speed_info_check.get_active()) Configuration.draw_size_info(self.draw_size_info_check.get_active()) Configuration.draw_color_bar(self.draw_color_bar_check.get_active()) Configuration.save_config()
def __load_settings(self): """ Wczytaj obecną konfigurację znajdującą się config.json do widgetów okna. """ self.border1_adjustment.set_value(Configuration.distance_border1()) self.border2_adjustment.set_value(Configuration.distance_border2()) self.meters_length_spin_adjustment.set_value( Configuration.meters_length()) self.color_number_spin_adjustment.set_value( Configuration.color_number()) self.horizontal_border_spin_adjustment.set_value( Configuration.horizontal_border()) self.vertical_border_spin_adjustment.set_value( Configuration.vertical_border()) self.pixel_limit_spin_adjustment.set_value(Configuration.pixel_limit()) self.distance_from_border_spin_adjustment.set_value( Configuration.distance_from_border()) self.draw_detection_region_check.set_active( Configuration.draw_detection_region()) self.draw_speed_region_check.set_active( Configuration.draw_speed_region()) self.draw_cars_check.set_active(Configuration.draw_cars()) self.draw_conturs_check.set_active(Configuration.draw_conturs()) self.draw_speed_info_check.set_active(Configuration.draw_speed_info()) self.draw_size_info_check.set_active(Configuration.draw_size_info()) self.draw_color_bar_check.set_active(Configuration.draw_color_bar())
def __has_valid_size(region: np.ndarray): """ Sprawdza czy obszar nie jest za mały oraz za duży. :param np.ndarray region: Obraz zwierający region oznaczony niezerową wartością. :return: Prawda/fałsz. :rtype: bool """ max = (480*720/2) min = Configuration.pixel_limit() return (np.count_nonzero(region) >= min) and (np.count_nonzero(region) < max)
def __has_valid_size(region: np.ndarray): """ Sprawdza czy obszar nie jest za mały oraz za duży. :param np.ndarray region: Obraz zwierający region oznaczony niezerową wartością. :return: Prawda/fałsz. :rtype: bool """ max = 480 * 720 / 2 min = Configuration.pixel_limit() return (np.count_nonzero(region) >= min) and (np.count_nonzero(region) < max)
def __write_settings(self): """ Zapisz wartości z widgetów """ Configuration.distance_border1(self.border1_adjustment.get_value()) Configuration.distance_border2(self.border2_adjustment.get_value()) Configuration.meters_length(self.meters_length_spin_adjustment.get_value()) Configuration.color_number(self.color_number_spin_adjustment.get_value()) Configuration.horizontal_border(self.horizontal_border_spin_adjustment.get_value()) Configuration.vertical_border(self.vertical_border_spin_adjustment.get_value()) Configuration.pixel_limit(self.pixel_limit_spin_adjustment.get_value()) Configuration.distance_from_border(self.distance_from_border_spin_adjustment.get_value()) Configuration.draw_detection_region(self.draw_detection_region_check.get_active()) Configuration.draw_speed_region(self.draw_speed_region_check.get_active()) Configuration.draw_cars(self.draw_cars_check.get_active()) Configuration.draw_conturs(self.draw_conturs_check.get_active()) Configuration.draw_speed_info(self.draw_speed_info_check.get_active()) Configuration.draw_size_info(self.draw_size_info_check.get_active()) Configuration.draw_color_bar(self.draw_color_bar_check.get_active()) Configuration.save_config()
def __load_settings(self): """ Wczytaj obecną konfigurację znajdującą się config.json do widgetów okna. """ self.border1_adjustment.set_value(Configuration.distance_border1()) self.border2_adjustment.set_value(Configuration.distance_border2()) self.meters_length_spin_adjustment.set_value(Configuration.meters_length()) self.color_number_spin_adjustment.set_value(Configuration.color_number()) self.horizontal_border_spin_adjustment.set_value(Configuration.horizontal_border()) self.vertical_border_spin_adjustment.set_value(Configuration.vertical_border()) self.pixel_limit_spin_adjustment.set_value(Configuration.pixel_limit()) self.distance_from_border_spin_adjustment.set_value(Configuration.distance_from_border()) self.draw_detection_region_check.set_active(Configuration.draw_detection_region()) self.draw_speed_region_check.set_active(Configuration.draw_speed_region()) self.draw_cars_check.set_active(Configuration.draw_cars()) self.draw_conturs_check.set_active(Configuration.draw_conturs()) self.draw_speed_info_check.set_active(Configuration.draw_speed_info()) self.draw_size_info_check.set_active(Configuration.draw_size_info()) self.draw_color_bar_check.set_active(Configuration.draw_color_bar())