π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
remove unused draw_rectangle function
edgarribacfaa364b42c4
diff --git a/torchgeometry/utils.py b/torchgeometry/utils.pyindex 1fd522db2..33a8e3c4e 100644--- a/torchgeometry/utils.py+++ b/torchgeometry/utils.py@@ -111,35 +111,3 @@ def create_pinhole(intrinsic, extrinsic, height, width):torch.tensor(extrinsic))pinhole[9:12] = torch.tensor(extrinsic[:, 3])return pinhole.view(1, -1)---def draw_rectangle(image, dst_homo_src):- import cv2- height, width = image.shape[:2]- pts_src = torch.FloatTensor([[- [-1, -1], # top-left- [1, -1], # bottom-left- [1, 1], # bottom-right- [-1, 1], # top-right- ]]).to(dst_homo_src.device)- # transform points- pts_dst = tgm.transform_points(tgm.inverse(dst_homo_src), pts_src)-- def compute_factor(size):- return 1.0 * size / 2-- def convert_coordinates_to_pixel(coordinates, factor):- return factor * (coordinates + 1.0)- # compute convertion factor- x_factor = compute_factor(width - 1)- y_factor = compute_factor(height - 1)- pts_dst = pts_dst.cpu().squeeze().detach().numpy()- pts_dst[..., 0] = convert_coordinates_to_pixel(- pts_dst[..., 0], x_factor)- pts_dst[..., 1] = convert_coordinates_to_pixel(- pts_dst[..., 1], y_factor)- # do the actual drawing- for i in range(4):- pt_i, pt_ii = tuple(pts_dst[i % 4]), tuple(pts_dst[(i + 1) % 4])- image = cv2.line(image, pt_i, pt_ii, (255, 0, 0), 3)- return image