コード例 #1
0
 def save_trajectory(self):
     for i, trajectory in enumerate(self.trajectories):
         dir = osp.join(self.traj_dir, '%06d' % trajectory.id)
         mkdirs(dir)
         for j, tracklet in enumerate(trajectory.data):
             fname = osp.join(dir, '%06d.%d.jpg' % (j, tracklet.chan))
             cv2.imwrite(fname, tracklet.im)
コード例 #2
0
 def __init__(self, tid, tracklets, trajectories, exit, model=None):
     super(MTMCT, self).__init__(name=tid)
     self.tid = tid
     self.tracklets = tracklets
     self.trajectories = trajectories
     self.exit = exit
     self.model = model  # ReID model
     self.gplane = np.zeros((2048, 2048, 3), dtype=np.uint8)
     self.counter = 0
     self.gplane_dir = osp.join('tasks', 'gplane')
     mkdirs(self.gplane_dir)
     self.local2global = defaultdict(int)  # `channel-local_id`
     self.undetermined = defaultdict(
         lambda: defaultdict(list))  # `channel`->`local_id`
     self.least = 5  # at least `least` tracklets for matching
     self.atmost = 15  # at most `atmost` tracklets for matching
     self.ncamera = 0
     self.max_dist = 25
     self.traj_dir = osp.join('tasks', 'trajectories')
     mkdirs(self.traj_dir)
コード例 #3
0
ファイル: train.py プロジェクト: dbofseuofhust/JDE
def main():
    # Parse configurations.
    args = parse_args()
    if os.path.isfile(args.config):
        config.merge_from_file(args.config)
    config.merge_from_list(args.opts)

    torch.backends.cudnn.benchmark = True
    mkdirs(config.SYSTEM.TASK_DIR)

    # Build dataset
    dataset = build_dataset(config.DATASET)

    # Build model.
    num_ide = int(dataset.max_id + 1)
    config.MODEL.ARGS.HEAD.ARGS[1]['num_ide'] = num_ide
    model = build_tracker(config.MODEL)

    # Train tracker now.
    train_tracker(model, dataset, config)
コード例 #4
0
 def __init__(self,
              tid,
              images,
              tracklets,
              exit,
              model,
              locator=None,
              insize=(320, 576)):
     super(MTSCT, self).__init__(name=tid)
     self.tid = tid
     self.images = images
     self.tracklets = tracklets
     self.exit = exit
     self.model = model.cuda()  # Tracker model
     self.model.eval()
     self.locator = locator  # ground plane location
     self.insize = insize
     self.score_thresh = 0.5
     self.iou_thresh = 0.4
     self.tracker = trackernew.JDETracker()
     self.save_dir = osp.join('tasks', 'mtsct_{}'.format(self.tid))
     mkdirs(self.save_dir)
コード例 #5
0
    parser.add_argument('--root', '-r', type=str,
        help='dataset data root directory.')
    parser.add_argument('--data', '-d', type=str,
        help='dataset configuration filepath.')
    parser.add_argument('-k', type=int, default=1000,
        help='The maximum number of generated samples.')
    parser.add_argument('--save-path', '-sp', type=str,
        default='./samples',
        help='Samples saving path.')
    return parser.parse_args()

if __name__ == '__main__':
    args = parse_args()
    all_samples = []
    with open(args.data, 'r') as fd1:
        files = fd1.readlines()
        files = [f.strip() for f in files]
        files = list(filter(lambda f: len(f) > 0, files))
        for file in files:
            with open(file, 'r') as fd2:
                samples = fd2.readlines()
                samples = [s.strip() for s in samples]
                samples = list(filter(lambda s: len(s) > 0, samples))
                samples = [osp.join(args.root, s) for s in samples]
            all_samples += samples
    k = min(len(all_samples), args.k)
    selections = random.sample(all_samples, k)
    mkdirs(args.save_path)
    for s in selections:
        print('copy {} to {}'.format(s, args.save_path))
        os.system('cp {} {}'.format(s, args.save_path))
コード例 #6
0
ファイル: cvat2mot.py プロジェクト: Jay-Liu/JDE
    args = parser.parse_args()
    return args


if __name__ == '__main__':
    args = parse_args()
    vc = cv2.VideoCapture(args.video)
    width = int(vc.get(cv2.CAP_PROP_FRAME_WIDTH))
    height = int(vc.get(cv2.CAP_PROP_FRAME_HEIGHT))
    frames = int(vc.get(cv2.CAP_PROP_FRAME_COUNT))
    print('width {}, height {}, frames {}'.format(width, height, frames))

    root, _ = os.path.splitext(args.video)
    cache_path = os.path.join(root, 'frames')
    if not os.path.exists(cache_path):
        mkdirs(cache_path)
        i = 0
        while True:
            retval, im = vc.read()
            if not retval:
                break
            cv2.imwrite(os.path.join(cache_path, '{}.jpg'.format(i)), im)
            i = i + 1
            print('\rextract frame {}/{}'.format(i, frames),
                  end='',
                  flush=True)

    print('')
    mot_path = os.path.join(root, 'mot')
    mkdirs(mot_path)
    im_path = os.path.join(mot_path, 'images')
コード例 #7
0
    return args


if __name__ == '__main__':
    args = parse_args()
    vc = cv2.VideoCapture(args.video)
    width = int(vc.get(cv2.CAP_PROP_FRAME_WIDTH))
    height = int(vc.get(cv2.CAP_PROP_FRAME_HEIGHT))
    frames = int(vc.get(cv2.CAP_PROP_FRAME_COUNT))
    print('width {}, height {}, possible frames {}'.format(
        width, height, frames))

    root, _ = os.path.splitext(args.video)
    cache_path = os.path.join(root, 'frames')
    if not os.path.exists(cache_path):
        mkdirs(cache_path)
        i = 0
        while True:
            retval, im = vc.read()
            if not retval:
                break
            cv2.imwrite(os.path.join(cache_path, '{}.jpg'.format(i)), im)
            i = i + 1
            print('\rextract frame {}/{}'.format(i, frames),
                  end='',
                  flush=True)

    print('')
    reid_path = os.path.join(root, 'reid')
    mkdirs(reid_path)