Merge pull request #733 from roboflow/fix/speed-estimation-issue-when-detections-empty

`fix/speed-estimation-issue-when-detections-empty`
This commit is contained in:
Piotr Skalski 2024-01-18 11:30:04 +01:00 committed by GitHub
commit 536e0d86a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 4 deletions

View File

@ -1,6 +1,6 @@
supervision==0.18.0rc1
tqdm
tqdm==4.66.1
requests
ultralytics
super-gradients
inference
ultralytics==8.0.237
super-gradients==3.5.0
inference==0.9.8

View File

@ -29,6 +29,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)