Пример #1
0
    def from_old(cls, json_data):
        """Parse a dictionary representation from the PoseTrack17 format."""
        posetrack_filename = json_data["image"][0]["name"]
        assert len(json_data["image"]) == 1, "Invalid format!"
        old_seq_fp = path.basename(path.dirname(posetrack_filename))
        fp_wo_ending = path.basename(posetrack_filename).split(".")[0]
        if "_" in fp_wo_ending:
            fp_wo_ending = fp_wo_ending.split("_")[0]
        old_frame_id = int(fp_wo_ending)
        try:
            frame_id = posetrack18_fname2id(old_seq_fp, old_frame_id)
        except:  # pylint: disable=bare-except
            print(
                "I stumbled over a strange sequence. Maybe you can have a look?"
            )
            import pdb

            pdb.set_trace()  # pylint: disable=no-member
        image = Image(posetrack_filename, frame_id)
        for person_info in json_data["annorect"]:
            image.people.append(Person.from_old(person_info))
        if "ignore_regions" in list(json_data.keys()):
            ignore_regions_x = []
            ignore_regions_y = []
            for ignore_region in json_data["ignore_regions"]:
                x_values = []
                y_values = []
                for point in ignore_region["point"]:
                    x_values.append(point["x"][0])
                    y_values.append(point["y"][0])
                ignore_regions_x.append(x_values)
                ignore_regions_y.append(y_values)
            image.ignore_regions = (ignore_regions_x, ignore_regions_y)
        return image
Пример #2
0
 def from_new(cls, track_data, image_id):
     """Parse a dictionary representation from the PoseTrack18 format."""
     image_info = [
         image_info for image_info in track_data["images"]
         if image_info["id"] == image_id
     ][0]
     posetrack_filename = image_info["file_name"]
     # license, coco_url, height, width, date_capture, flickr_url, id are lost.
     old_seq_fp = path.basename(path.dirname(posetrack_filename))
     old_frame_id = int(path.basename(posetrack_filename).split(".")[0])
     frame_id = posetrack18_fname2id(old_seq_fp, old_frame_id)
     image = Image(posetrack_filename, frame_id)
     if ("ignore_regions_x" in list(image_info.keys())
             and "ignore_regions_y" in list(image_info.keys())):
         image.ignore_regions = (
             image_info["ignore_regions_x"],
             image_info["ignore_regions_y"],
         )
     return image