-
Notifications
You must be signed in to change notification settings - Fork 8
/
image_transforms.py
63 lines (49 loc) · 2.03 KB
/
image_transforms.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import cv2
import imutils
from imutils import perspective
#from imutils.video import count_frames
import numpy as np
from matplotlib import pyplot as plt
import glob
#WIDTH, HEIGHT = 100, 100
class utils(object):
def getSpotsCoordiantesFromImage(img, num_space) :
#coordinate_lists has this format[ [(x1,y1), (x2,y2), (x3,y3), (x4,y4)], [], [] ]
coordinate_lists = []
spots_index_list = []
for i in range(num_space):
plt.imshow(img, cmap = 'gray', interpolation = 'bicubic')
plt.xticks([]), plt.yticks([])
#we need 4 points to get rectangle
print("Please click 4 points for parking lot in clock direction", i)
coordinate = plt.ginput(4)
print("clicked points coordinate are ", coordinate)
coordinate_lists.append(coordinate)
spots_index_list.append(i)
plt.close()
#saveSpotsCoordinates(coordinate_lists)
#saveSpotsIndex(spots_index_list)
return coordinate_lists
''' rotaciona imagens '''
def getRotateRect(img, cooridnate_lists, WIDTH = 100, HEIGHT = 100):
#warped image list is the list with warper images
warped_img_lists = []
i = 0
#every time we process one coordinates
for coordinate in cooridnate_lists :
warped = perspective.four_point_transform(img, coordinate)
warped_resize = cv2.resize(warped, (WIDTH, HEIGHT), interpolation=cv2.INTER_CUBIC)
# plt.imshow(warped, cmap = 'gray', interpolation = 'bicubic')
# plt.xticks([]), plt.yticks([])
# plt.show()
cv2.imshow("resize %d"%i, warped_resize)
warped_img_lists.append(warped_resize)
i+=1
return warped_img_lists
def load_images_from_path(path):
lista_imagens = []
img_list = []
for files in glob.glob(folderPath + "/*.jpg"):
img = cv2.imread(files)
img_list.append(img)
return img_list