-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
31 lines (26 loc) · 926 Bytes
/
Copy pathutils.py
File metadata and controls
31 lines (26 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import cv2
import numpy as np
# Redimensiona a imagem mantendo a proporção
def ResizeWithAspectRatio(image, width=None, height=None, inter=cv2.INTER_AREA):
dim = None
(h, w) = image.shape[:2]
if width is None and height is None:
return image
if width is None:
r = height / float(h)
dim = (int(w * r), height)
else:
r = width / float(w)
dim = (width, int(h * r))
return cv2.resize(image, dim, interpolation=inter)
# Calcula a distância entre dois pontos (x1, y1) e (x2, y2)
def selectionDistance(tuple):
return np.sqrt((tuple[0][0] - tuple[1][0])**2 + (tuple[0][1] - tuple[1][1])**2)
# Trata o vetor de saída, arredondado os valores para exibir no output
def treatOutputVector(output):
aux_list = []
output = np.squeeze(output)
for out in output:
element = round(float(out), 2)
aux_list.append(element)
return aux_list