-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathutils.py
More file actions
41 lines (28 loc) · 866 Bytes
/
utils.py
File metadata and controls
41 lines (28 loc) · 866 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
32
33
34
35
36
37
38
39
40
41
import time
from datetime import datetime
import json
import config
import cv2
import numpy as np
# Helper functions
def currentTime() :
return time.time() * 1000
def dateTime() :
return datetime.now().strftime(r"%m/%d/%Y, %H:%M:%S")
def appendJSON(filePath, jsonData) :
with open(filePath, 'r') as file:
data = json.load(file)
# decode and append data
dict_obj = json.loads(jsonData.toJSON())
data.append(dict_obj)
# write to file
with open(filePath, 'w') as file:
json.dump(data, file)
def loadJSON(filepath) :
with open(filepath, 'r') as file:
return json.load(file)
def drawFaces(img_data, faces) :
for (x,y,w,h) in faces:
img_data = cv2.rectangle(img_data, (x, y), (x + w, y + h),
(0, 255, 0), 2)
return img_data