-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.py
52 lines (39 loc) · 1.33 KB
/
Utils.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
import os
import cv2
import hashlib
from datetime import datetime
def listAllFolderName(path):
filenames = os.listdir(path)
foldernames = []
for filename in filenames:
if os.path.isdir(os.path.join(path, filename)):
foldernames.append(filename)
return foldernames
def checkFileExist(fileList, name):
for filename in fileList:
if name == filename:
return True
return False
def loadImagesFromFolder(folderPath):
images = []
for filename in os.listdir(folderPath):
img = cv2.imread(os.path.join(folderPath, filename))
if img is not None:
images.append(img)
return images
def loadAndResizeImagesFromFolder(folderPath, scale):
images = []
for filename in os.listdir(folderPath):
img = cv2.imread(os.path.join(folderPath, filename))
if img is not None:
resizedImg = cv2.resize(img, (0, 0), None, 1 / scale, 1 / scale)
images.append(resizedImg)
return images
def hashPassword(plainPassword):
hashPassword = hashlib.md5(plainPassword.encode())
return hashPassword.hexdigest()
def hashPasswordAndCompare(plainPassword, comparePassword):
hashedPassword = hashPassword(plainPassword)
return hashedPassword == comparePassword
def findCurrentDayOfWeek():
return datetime.today().weekday()