-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
24 lines (20 loc) · 911 Bytes
/
test.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
import sys
from PIL import Image
import os
import cv2
import imageUtils
import videoUtils
files = os.listdir('test')
files = set(files).difference(set(['.gitkeep', '.DS_Store', 'test/processed']))
bold = len(sys.argv) > 1 and bool(sys.argv[1])
for fileName in files:
print('Processing', fileName)
if fileName.lower().find('jpg') != -1 or fileName.lower().find('jpeg') != -1 or fileName.lower().find('png') != -1:
originalImage = cv2.imread(f'test/{fileName}')
newImage, hasSeenTheLightInImage = imageUtils.processImage(originalImage, bold)
if hasSeenTheLightInImage:
cv2.imwrite(f'test/processed/{fileName}', newImage)
else:
print(f'No highlights detected for {fileName}')
elif fileName.lower().find('gif') != -1 or fileName.lower().find('mp4') != -1:
videoUtils.processVideo(f'test/{fileName}', fileName, 'test/processed', False)