Skip to content

Commit 31c4c34

Browse files
committed
perf: make resize a no-op if frame has already target size
1 parent 8dfffd7 commit 31c4c34

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/arduino/app_utils/image/adjustments.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,15 @@ def resize(frame: np.ndarray, target_size: Tuple[int, int], maintain_ratio: bool
9393
Args:
9494
frame (np.ndarray): Input frame
9595
target_size (tuple): Target size as (width, height)
96-
maintain_ratio (bool): If True, use letterboxing to maintain aspect ratio
97-
interpolation (int): OpenCV interpolation method
96+
maintain_ratio (bool): If True, use letterboxing to maintain aspect ratio. Default: False.
97+
interpolation (int): OpenCV interpolation method. Default: cv2.INTER_LINEAR.
9898
9999
Returns:
100100
np.ndarray: Resized frame
101101
"""
102+
if frame.shape[1] == target_size[0] and frame.shape[0] == target_size[1]:
103+
return frame
104+
102105
if maintain_ratio:
103106
return letterbox(frame, target_size)
104107
else:

0 commit comments

Comments
 (0)