MCPcopy Create free account
hub / github.com/FoundationVision/ByteTrack / get_size_with_aspect_ratio

Function get_size_with_aspect_ratio

tutorials/motr/transforms.py:239–257  ·  view source on GitHub ↗
(image_size, size, max_size=None)

Source from the content-addressed store, hash-verified

237 # size can be min_size (scalar) or (w, h) tuple
238
239 def get_size_with_aspect_ratio(image_size, size, max_size=None):
240 w, h = image_size
241 if max_size is not None:
242 min_original_size = float(min((w, h)))
243 max_original_size = float(max((w, h)))
244 if max_original_size / min_original_size * size > max_size:
245 size = int(round(max_size * min_original_size / max_original_size))
246
247 if (w <= h and w == size) or (h <= w and h == size):
248 return (h, w)
249
250 if w < h:
251 ow = size
252 oh = int(size * h / w)
253 else:
254 oh = size
255 ow = int(size * w / h)
256
257 return (oh, ow)
258
259 def get_size(image_size, size, max_size=None):
260 if isinstance(size, (list, tuple)):

Callers 1

get_sizeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected