From 775efd0d4188e73814fc0331b9f225e7440cc335 Mon Sep 17 00:00:00 2001 From: SkalskiP Date: Thu, 1 Feb 2024 10:25:43 +0100 Subject: [PATCH] fix inference and yolo nas speed estimation examples --- examples/speed_estimation/inference_example.py | 3 +++ examples/speed_estimation/yolo_nas_example.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/examples/speed_estimation/inference_example.py b/examples/speed_estimation/inference_example.py index 1043b46b..b0ff84dd 100644 --- a/examples/speed_estimation/inference_example.py +++ b/examples/speed_estimation/inference_example.py @@ -30,6 +30,9 @@ class ViewTransformer: self.m = cv2.getPerspectiveTransform(source, target) def transform_points(self, points: np.ndarray) -> np.ndarray: + if points.size == 0: + return points + reshaped_points = points.reshape(-1, 1, 2).astype(np.float32) transformed_points = cv2.perspectiveTransform(reshaped_points, self.m) return transformed_points.reshape(-1, 2) diff --git a/examples/speed_estimation/yolo_nas_example.py b/examples/speed_estimation/yolo_nas_example.py index 5847d759..77f1fd0f 100644 --- a/examples/speed_estimation/yolo_nas_example.py +++ b/examples/speed_estimation/yolo_nas_example.py @@ -30,6 +30,9 @@ class ViewTransformer: self.m = cv2.getPerspectiveTransform(source, target) def transform_points(self, points: np.ndarray) -> np.ndarray: + if points.size == 0: + return points + reshaped_points = points.reshape(-1, 1, 2).astype(np.float32) transformed_points = cv2.perspectiveTransform(reshaped_points, self.m) return transformed_points.reshape(-1, 2)