def __init__(self, config: configparser.ConfigParser): self.__logger = logger_factory.get_logger() self.__filter_tuner = AutomaticFilterTuner(self) self.__tracker = Tracker(config) self.__target_provider = TargetProvider(self) self.__communication_manager = CommunicationManager(config) self.__presentation_manager = PresentationManager(config, self.__filter_tuner.clickAndDrag_Rectangle, self.__target_provider.target_selector) self.__state = AppState()
def __init__(self, config: configparser.ConfigParser): self.__logger = get_logger() self.__config = config self.__sample_count = self.__config.getint('communication', 'sample_count') self.__trunk_sample_count = 0 self.__hood_sample_count = 0 self.__samples: List[Sample] = [] self.__target_coordinates = None self.__kinematic_model = KinematicModel(config) self.__controller_notifier = ControllerNotifier(config)
def __init__(self, config: configparser.ConfigParser): self.__logger = logger_factory.get_logger() self.__config = config self.__poll_interval = config.getfloat('communication', 'poll_interval_in_ms') / 1000 self.__queue = queue.Queue() self.exc_info = None self.__worker_thread = AsyncEventLoopThread() self.__worker_thread.start() if config.getboolean('communication', 'enabled'): self.__worker_thread.run_coroutine(self.serial_client_loop()) else: self.__worker_thread.run_coroutine(self.dummy_loop())
def main(config: configparser.ConfigParser): logger = logger_factory.get_logger() try: logger.info('Initializing image processor.') refresh_delay = config.getint('frame', 'refresh_delay') with VideoStream(config) as video_stream: with AppStateManager(config) as app_state_manager: logger.info('Successfully initialized image processor.') while True: camera_feed_matrix = video_stream.read() if camera_feed_matrix and len(camera_feed_matrix) > 0: app_state_manager.get_state_action( camera_feed_matrix)() waitKey(refresh_delay) except Exception as e: logger.error( f'Unhandled exception occurred. Shutting down! Reason:{e}')
# 取项目根目录 ROOT_PATH = os.path.abspath(os.path.dirname(__file__)).split('yolo')[0] ROOT_PATH = ROOT_PATH + "yolo" sys.path.append(ROOT_PATH) import utils.conf as conf import utils.logger_factory as logf import utils.alphabet as alphabet import data.dataset_cells as ds_cells import models.yolo_v4_tiny as yolo from math import ceil log = logf.get_logger('train_v4') # 初始化数据集 # 训练集 count_train = conf.DATASET_CELLS.get_count_train() batch_size = conf.DATASET_CELLS.get_batch_size() epochs = conf.DATASET_CELLS.get_epochs() db_train = ds_cells.tensor_db( img_dir=conf.DATASET_CELLS.get_in_train(), label_path=conf.DATASET_CELLS.get_label_train(), is_label_mutiple=conf.DATASET_CELLS.get_label_train_mutiple(), count=count_train, batch_size=batch_size, epochs=epochs, shuffle_buffer_rate=conf.DATASET_CELLS.get_shuffle_buffer_rate(), x_preprocess=lambda x: ((x - 255.) - 0.5) / 2,
@author: luoyi Created on 2020年12月29日 ''' import json import os import numpy as np import PIL import tensorflow as tf import collections import data.part as part import utils.conf as conf import utils.alphabet as alphabet import utils.logger_factory as logf log = logf.get_logger('data_original') # 标签文件迭代器 def label_file_iterator(label_file_path=conf.DATASET.get_label_train(), count=conf.DATASET.get_count_train()): '''标签文件迭代器(注:该函数的标签坐标是原坐标,要压缩的话自行处理) json格式 { fileName:'${fileName}', vcode='${vcode}', annos:[ {key:'值', x:x, y:y, w:w, h:h}, {key:'值', x:x, y:y, w:w, h:h}... ] }
@author: luoyi Created on 2021年2月24日 ''' import sys import os # 取项目根目录 ROOT_PATH = os.path.abspath(os.path.dirname(__file__)).split('yolo')[0] ROOT_PATH = ROOT_PATH + "yolo" sys.path.append(ROOT_PATH) import utils.conf as conf import utils.logger_factory as logf import data.dataset_cells as ds_cells import data.dataset as ds log = logf.get_logger('data_cells') log.info('create cells dataset...') # cells数据生成器 cell_creator = ds_cells.CellCreator( standard_scale=[conf.IMAGE_HEIGHT, conf.IMAGE_WEIGHT], scales_set=conf.DATASET_CELLS.get_scales_set(), anchors_set=conf.DATASET_CELLS.get_anchors_set()) log.info('init cell_creator standard_scale:' + str([conf.IMAGE_HEIGHT, conf.IMAGE_WEIGHT]) + 'scales_set:' + str(conf.DATASET_CELLS.get_scales_set())) # 训练数据集 train_db_iter = ds.data_iterator( img_dir=conf.DATASET.get_in_train(), label_path=conf.DATASET.get_label_train(),
''' import numpy as np import itertools import json import os import tensorflow as tf import collections as collections import utils.conf as conf import utils.alphabet as alphabet import utils.logger_factory as logf import data.dataset as ds import data.part as part log = logf.get_logger('proposal_creator') # 建议框生成器 class ProposalsCreator(): def __init__(self, threshold_nms_prob=conf.RPN.get_nms_threshold_positives(), threshold_nms_iou=conf.RPN.get_nms_threshold_iou(), proposal_iou=0.7, proposal_every_image=32, rpn_model=None): ''' @param threshold_nms_prob: 非极大值抑制的前景概率(低于此概率的将被判负样本) @param threshold_nms_iou: 非极大值抑制时IoU比例(超过此比例的anchor会被判重叠而过滤掉) @param proposal_iou: 判定为有效建议框的anchor与label的IoU比例 @param proposal_every_image: 每张图片有效建议框数量