Created
January 13, 2023 13:30
-
-
Save sukhitashvili/ea51eaa7a510432782f67e93a7226b83 to your computer and use it in GitHub Desktop.
Revisions
-
sukhitashvili created this gist
Jan 13, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ def resize_coordinates(coords: np.ndarray, old_size: tuple, new_size: tuple): """ :param coords: coordinates as numpy array of shape (N, 2) [x, y] format :param old_size: old size as (width, height) :param new_size: new size as (width, height) :return: resized coordinates as numpy array of shape (N, 2) """ # Calculate the scale factor scale_factor = np.array(new_size) / np.array(old_size) # Scale the coordinates coords = np.round(coords.reshape(-1, 2) * scale_factor).astype(int) return coords