forked from erlendb/Ascend-Techathon-2019
-
Notifications
You must be signed in to change notification settings - Fork 0
/
save_photos.py
40 lines (28 loc) · 1.18 KB
/
save_photos.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
'''
import cv2 as cv
def save_photos(windmill_position, photo_id, img, score):
filename = 'rustimg-'+str(windmill_position.x)+'-'+str(windmill_position.y)+'-'+str(photo_id)+'-'+str(score)+'.jpg'
print(filename)
cv.imwrite(filename, img)
'''
import cv2 as cv
def save_photos(windmill_position, photo_id, img, score, totalScore):
filename = 'rustimg-'+str(int(totalScore))+'---'+str(windmill_position.x)+'-'+str(windmill_position.y)+'---'+str(photo_id)+'---'+str(int(score))+'.jpg'
#print(filename)
x_pos_str = "x_pos: " + str(windmill_position.x)
y_pos_str = "y_pos: " + str(windmill_position.y)
id_str = "id: " + str(photo_id)
score_str = "score: " + str(score)
tot_score_str = "tot score: " + str(totalScore)
stringArray = [x_pos_str, y_pos_str, id_str, score_str, tot_score_str]
font = cv.FONT_HERSHEY_SIMPLEX
blue = (255,0,0)
text_start_x = 10
text_start_y = 40
font_scale = 1
thickness = 2
for string in stringArray:
text_start = (text_start_x, text_start_y)
img = cv.putText(img, string, text_start, font, font_scale, blue, thickness)
text_start_y = text_start_y + 30
cv.imwrite(filename, img)