示例#1
0
def detect_dir(indir, camId):
    import track_seperate_0
    model_types = ['624']
    tracker = track_seperate_0.Tracker(model_types)
    model_type = config['model_type']
    mesh_settings = utils.load_mesh_settings(model_types)
    liner_settings = utils.load_liner_settings(model_types)
    worker = Worker(model_types, mesh_settings, liner_settings, camId)
    start = False
    count = 0
    for name in os.listdir(indir):
        inname = os.path.join(indir, name)
        if not os.path.isfile(inname):
            continue
        print(inname)
        #        if '432.jpg' == name:
        #            start = True
        #        if start == False:
        #            continue
        #         if '2020_06_03_17_27_33.jpg' != name:
        #           continue
        img = cv2.imread(inname)
        frame_dict = {
            'image': img,
        }
        track_ret = tracker.track(frame_dict, model_type)
        for obj in track_ret['objs']:
            print('idx', obj['idx'], '^^^^^^^^^^^^^^^^^^^^^^^^^^^')
            #            if not (obj['row_idx'] == 304 and obj['side'] == 0):
            #                 continue
            # if obj['side'] == 0:
            #     continue
            ret_dict = worker.detect(obj, model_type, name)
            print('defect,result', ret_dict['idx'], ret_dict['defect'])
示例#2
0
 def __init__(self, model_types):
     self.scale = 8
     self.liner_setting = None
     self.mesh_setting = None
     self.model_type = None
     self.liner_settings = utils.load_liner_settings(model_types)
     self.mesh_settings = utils.load_mesh_settings(model_types)
     self.start_row = None
     # 用liner定位
     self.row_idx = 0
     self.mid_xy = None
示例#3
0
    def __init__(self, model_types):
        self.scale = 8
        self.liner_setting = None
        self.mesh_setting = None
        self.model_type = None
        self.liner_settings = utils.load_liner_settings(model_types)
        self.mesh_settings = utils.load_mesh_settings(model_types)
        self.start_row = None
        # 用liner定位
        self.row_idx = 0
        self.mid_xy = None

        self.index_area = [[390, 1650, 615, 1600], [2150, 3410, 615, 1600], [390, 1650, 3835, 4820],
                           [2150, 3410, 3835, 4820]]
示例#4
0
def detect_dir(indir):
    model_types = ['6244']
    model_type = config['model_type']
    mesh_settings = utils.load_mesh_settings(model_types)
    liner_settings = utils.load_liner_settings(model_types)
    worker = Worker(mesh_settings, liner_settings, model_types)
    start = False
    count = 0
    for name in os.listdir(indir):
        inname = os.path.join(indir, name)
        if not os.path.isfile(inname):
            continue
        print(inname)
        #        if '432.jpg' == name:
        #            start = True
        #        if start == False:
        #            continue
        #         if '2020_06_03_17_27_33.jpg' != name:
        #           continue
        img = cv2.imread(inname)
        worker.detect(img, None, None, None)
示例#5
0
                    'idx': idx,
                    'defect': defect
                }
                # for key, val in ret_dict.items():
                #     if key == 'image':
                #         continue

                self.ret_sender.put(send_dict)
                # f = open('test.txt', 'w+')
                # f.write(str(send_dict['trig_count']))
                # f.close
                print('ret_sender_qsize', self.ret_sender.qsize())
            else:
                time.sleep(0.05)


if __name__ == '__main__':
    # f = open('test.txt', 'w+')
    # f.write("hello\n")
    # f.close
    camId = int(sys.argv[1])
    model_types = ['624']
    logger = logging_info.set_logger(
        config['log_dir'],
        os.path.basename(__file__) + '_%d' % camId)
    mesh_settings = utils.load_mesh_settings(model_types)
    liner_settings = utils.load_liner_settings(model_types)
    detector = Detector(camId, model_types, mesh_settings, liner_settings,
                        logger)
    detector.run()