示例#1
0
    def _construct_sequence(self, sequence_info):
        sequence_path = sequence_info["path"]
        nz = sequence_info["nz"]
        ext = sequence_info["ext"]
        start_frame = sequence_info["startFrame"]
        end_frame = sequence_info["endFrame"]

        init_omit = 0
        if "initOmit" in sequence_info:
            init_omit = sequence_info["initOmit"]

        frames = [
            "{base_path}/{sequence_path}/{frame:0{nz}}.{ext}".format(
                base_path=self.base_path,
                sequence_path=sequence_path,
                frame=frame_num,
                nz=nz,
                ext=ext,
            ) for frame_num in range(start_frame + init_omit, end_frame + 1)
        ]

        anno_path = "{}/{}".format(self.base_path, sequence_info["anno_path"])

        try:
            ground_truth_rect = np.loadtxt(str(anno_path), dtype=np.float64)
        except Exception:
            ground_truth_rect = np.loadtxt(str(anno_path),
                                           delimiter=",",
                                           dtype=np.float64)

        return Sequence(sequence_info["name"], frames, "tpl",
                        ground_truth_rect[init_omit:, :])
示例#2
0
    def _construct_sequence(self, sequence_name):
        class_name = sequence_name.split("-")[0]
        anno_path = "{}/{}/{}/groundtruth.txt".format(self.base_path,
                                                      class_name,
                                                      sequence_name)
        try:
            ground_truth_rect = np.loadtxt(str(anno_path), dtype=np.float64)
        except Exception:
            ground_truth_rect = np.loadtxt(str(anno_path),
                                           delimiter=",",
                                           dtype=np.float64)

        frames_path = "{}/{}/{}/img".format(self.base_path, class_name,
                                            sequence_name)
        frame_list = [
            frame for frame in os.listdir(frames_path)
            if frame.endswith(".jpg")
        ]
        frame_list.sort(key=lambda f: int(f[:-4]))
        frames_list = [
            os.path.join(frames_path, frame) for frame in frame_list
        ]

        return Sequence(sequence_name, frames_list, "lasot",
                        ground_truth_rect.reshape(-1, 4))
示例#3
0
    def _construct_sequence(self, sequence_info):
        sequence_path = sequence_info["path"]
        ext = sequence_info["ext"]

        init_omit = 0
        if "initOmit" in sequence_info:
            init_omit = sequence_info["initOmit"]

        frames = sorted(
            glob.glob(
                "{base_path}/{sequence_path}/{fps}/{sequence_path}/*.{ext}".
                format(
                    base_path=self.base_path,
                    sequence_path=sequence_path,
                    fps=self.fps,
                    ext=ext,
                )))

        anno_path = "{base_path}/{sequence_path}/{fps}/{anno_path}".format(
            base_path=self.base_path,
            sequence_path=sequence_path,
            fps=self.fps,
            anno_path=sequence_info["anno_path"],
        )

        try:
            ground_truth_rect = np.loadtxt(str(anno_path), dtype=str)
        except Exception:
            ground_truth_rect = np.loadtxt(str(anno_path),
                                           delimiter=",",
                                           dtype=str)

        ground_truth_rect = ground_truth_rect[:, 1:5].astype(
            float)  # [left, top, right, bottom]
        ground_truth_rect[:,
                          2:] -= ground_truth_rect[:, :
                                                   2]  # [left, top, width, height]

        if not len(frames) == len(ground_truth_rect):
            if abs(len(ground_truth_rect) / len(frames) - 8) < 1:
                ground_truth_rect = ground_truth_rect[0::8, :]
            diff = abs(len(frames) - len(ground_truth_rect))
            if diff > 0 and diff <= 1:
                n = min(len(frames), len(ground_truth_rect))
                ground_truth_rect = ground_truth_rect[:n]
                frames = frames[:n]
        assert len(frames) == len(ground_truth_rect), sequence_info["name"]

        return Sequence(sequence_info["name"], frames, "nfs",
                        ground_truth_rect[init_omit:, :])
示例#4
0
    def _construct_sequence(self, sequence_info):
        sequence_path = sequence_info["path"]
        nz = sequence_info["nz"]
        ext = sequence_info["ext"]
        start_frame = sequence_info["startFrame"]
        end_frame = sequence_info["endFrame"]

        init_omit = 0
        if "initOmit" in sequence_info:
            init_omit = sequence_info["initOmit"]

        if isinstance(ext, list):
            for e in ext:
                first_frame_path = "{base_path}/{sequence_path}/{frame:0{nz}}.{ext}".format(
                    base_path=self.base_path,
                    sequence_path=sequence_path,
                    frame=start_frame + init_omit,
                    nz=nz,
                    ext=e,
                )
                if os.path.isfile(first_frame_path):
                    ext = e
                    break

            if isinstance(ext, list):
                raise Exception("Sequence {} not found".format(sequence_info["name"]))

        frames = [
            "{base_path}/{sequence_path}/{frame:0{nz}}.{ext}".format(
                base_path=self.base_path,
                sequence_path=sequence_path,
                frame=frame_num,
                nz=nz,
                ext=ext,
            )
            for frame_num in range(start_frame + init_omit, end_frame + 1)
        ]

        anno_path = "{}/{}".format(self.base_path, sequence_info["anno_path"])

        try:
            ground_truth_rect = np.loadtxt(str(anno_path), dtype=np.float64)
        except Exception:
            ground_truth_rect = np.loadtxt(
                str(anno_path), delimiter=",", dtype=np.float64
            )

        return Sequence(
            sequence_info["name"], frames, "otb", ground_truth_rect[init_omit:, :]
        )
示例#5
0
    def _construct_sequence(self, set, sequence_name):
        anno_path = "{}/{}/anno/{}.txt".format(self.base_path, set, sequence_name)

        ground_truth_rect = load_text(
            str(anno_path), delimiter=",", dtype=np.float64, backend="numpy"
        )

        frames_path = "{}/{}/frames/{}".format(self.base_path, set, sequence_name)
        frame_list = [
            frame for frame in os.listdir(frames_path) if frame.endswith(".jpg")
        ]
        frame_list.sort(key=lambda f: int(f[:-4]))
        frames_list = [os.path.join(frames_path, frame) for frame in frame_list]

        return Sequence(
            sequence_name, frames_list, "trackingnet", ground_truth_rect.reshape(-1, 4)
        )
示例#6
0
    def _construct_sequence(self, key, task):
        vid, obj = key

        init_image = self.imfile(vid, task.init_time)
        im = cv2.imread(init_image, cv2.IMREAD_COLOR)
        imheight, imwidth, _ = im.shape

        frames_list = [
            self.imfile(vid, t)
            for t in range(task.init_time, task.last_time + 1)
        ]

        ground_truth_rect = np.zeros((len(frames_list), 4))
        init_box = rect_to_opencv(task.init_rect,
                                  imsize_hw=(imheight, imwidth))
        ground_truth_rect[0, :] = init_box

        return Sequence(vid, frames_list, "oxuva", ground_truth_rect)
示例#7
0
    def _construct_sequence(self, sequence_name):
        sequence_path = sequence_name
        nz = 8
        ext = "jpg"
        start_frame = 1

        anno_path = "{}/{}/groundtruth.txt".format(self.base_path, sequence_name)
        try:
            ground_truth_rect = np.loadtxt(str(anno_path), dtype=np.float64)
        except Exception:
            ground_truth_rect = np.loadtxt(
                str(anno_path), delimiter=",", dtype=np.float64
            )

        end_frame = ground_truth_rect.shape[0]

        frames = [
            "{base_path}/{sequence_path}/{frame:0{nz}}.{ext}".format(
                base_path=self.base_path,
                sequence_path=sequence_path,
                frame=frame_num,
                nz=nz,
                ext=ext,
            )
            for frame_num in range(start_frame, end_frame + 1)
        ]

        # Convert gt
        if ground_truth_rect.shape[1] > 4:
            gt_x_all = ground_truth_rect[:, [0, 2, 4, 6]]
            gt_y_all = ground_truth_rect[:, [1, 3, 5, 7]]

            x1 = np.amin(gt_x_all, 1).reshape(-1, 1)
            y1 = np.amin(gt_y_all, 1).reshape(-1, 1)
            x2 = np.amax(gt_x_all, 1).reshape(-1, 1)
            y2 = np.amax(gt_y_all, 1).reshape(-1, 1)

            ground_truth_rect = np.concatenate((x1, y1, x2 - x1, y2 - y1), 1)
        return Sequence(sequence_name, frames, "vot", ground_truth_rect)