forked from MjdMahasneh/MSLabel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.py
42 lines (32 loc) · 1.15 KB
/
helpers.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
import os
import sys
import cv2
import numpy as np
import glob as glist
import getImageList as glist
def check_dir_setup():
if not os.path.exists('./cache'):
os.makedirs('./cache')
if not os.path.exists('./annotation_files'):
os.makedirs('./annotation_files')
if not os.path.exists('./cache'):
os.makedirs('./cache')
if not os.path.exists('./images/band_1'):
os.makedirs('./images/band_1')
if not os.path.exists('./images/band_2'):
os.makedirs('./images/band_2')
if not os.path.exists('./cache/temp.txt'):
file = open('./cache/temp.txt', 'w')
file.write('')
file.close()
if not os.path.exists('./cache/no_image_available.jpg'):
img = np.zeros((800, 800, 3), np.uint8)
font = cv2.FONT_HERSHEY_SIMPLEX
cv2.putText(img, 'No Image', (10, 500), font, 5, (255, 255, 255), 2, cv2.LINE_AA)
cv2.imwrite('./cache/no_image_available.jpg', img)
else:
pass
if len(glist.get_imlist('images/band_1')) == 0 or len(glist.get_imlist('images/band_2')) == 0:
print('images/band_1 or images/band_2 is empty')
sys.exit()
return()