Exemple #1
0
 def apply_to_keypoint(self, keypoint, **params):
     # print('keypoint, ', params)
     height = params["rows"]
     width = params["cols"]
     scale_x = params['width'] / width
     scale_y = params['height'] / height
     return F.keypoint_scale(keypoint, scale_x, scale_y)
    def apply_to_keypoint(self, keypoint, **params):
        height = params["rows"]
        width = params["cols"]
        new_height, new_width = self._compute_new_hw(height, width)

        scale_x = new_width / width
        scale_y = new_height / height
        return F.keypoint_scale(keypoint, scale_x, scale_y)
    def apply_to_keypoint(self, keypoint, **params):
        height = params["rows"]
        width = params["cols"]

        scale = self.max_size / max([height, width])
        if scale > 1.0:
            return keypoint
        return F.keypoint_scale(keypoint, scale, scale)
Exemple #4
0
    def apply_to_keypoint(self, keypoint, **params):
        """
        Keypoints are not normalized and need their xy rescaled.
        """

        new_height, new_width = _compute_new_shape(self.length, params["rows"],
                                                   params["cols"])
        scale_x = new_width / params["cols"]
        scale_y = new_height / params["rows"]
        return F.keypoint_scale(keypoint, scale_x, scale_y)
    def apply_to_keypoint(self, keypoint, **params):
        if self.output_size == -1:
            return keypoint
        height = params["rows"]
        width = params["cols"]
        ratio = width / height
        new_height = int(np.sqrt(self.output_size / ratio))
        new_width = int(self.output_size / new_height)

        scale_x = new_width / width
        scale_y = new_height / height
        return F.keypoint_scale(keypoint, scale_x, scale_y)
Exemple #6
0
    def apply_to_keypoint(self, keypoint, angle=0, **params):
        height = params["rows"]
        width = params["cols"]
        new_height, new_width = get_rotated_size(height, width, angle)

        keypoint = keypoint_rotate_no_crop(keypoint, angle, height, width)

        crop_height, crop_width = rotatedRectWithMaxArea(height, width, angle)

        keypoint = F.keypoint_center_crop(keypoint, crop_height, crop_width,
                                          new_height, new_width)

        resized_height, resized_width = get_resized_max_ratio(
            height, width, crop_height, crop_width)

        scale_x = resized_width / crop_width
        scale_y = resized_height / crop_height
        keypoint = F.keypoint_scale(keypoint, scale_x, scale_y)
        return F.keypoint_center_crop(keypoint, height, width, resized_height,
                                      resized_width)
Exemple #7
0
def test_keypoint_scale(keypoint, expected, scale):
    actual = F.keypoint_scale(keypoint, scale, scale)
    np.testing.assert_allclose(actual, expected, atol=1e-7)
Exemple #8
0
 def apply_to_keypoint(self, keypoint, **params):
     height = params["rows"]
     width = params["cols"]
     scale_x = self.width / width
     scale_y = self.height / height
     return F.keypoint_scale(keypoint, scale_x, scale_y)
Exemple #9
0
 def apply_to_keypoint(self, keypoint, new_height=0, new_width=0, **params):
     scale_x = new_width / params["cols"]
     scale_y = new_height / params["rows"]
     return F.keypoint_scale(keypoint, scale_x, scale_y)
Exemple #10
0
 def apply_to_keypoint(self, keypoint, **params):
     im_sz = np.array([params["cols"], params["rows"]])
     scale = min(self.target_wh / im_sz)
     return F.keypoint_scale(keypoint, scale, scale)
Exemple #11
0
 def apply_to_keypoint(self, keypoint, **params):
     return F.keypoint_scale(keypoint, params["x_scale"], params["y_scale"])
Exemple #12
0
 def apply_to_keypoint(self, keypoint, crop_height=0, crop_width=0, h_start=0, w_start=0, rows=0, cols=0, **params):
     keypoint = F.keypoint_random_crop(keypoint, crop_height, crop_width, h_start, w_start, rows, cols)
     scale_x = self.width / crop_height
     scale_y = self.height / crop_height
     keypoint = F.keypoint_scale(keypoint, scale_x, scale_y)
     return keypoint
 def apply_to_keypoint(self, keypoint, scale_x=0, scale_y=0, **params):
     return F.keypoint_scale(keypoint, scale_x, scale_y)