-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimageProcessing.py
More file actions
40 lines (28 loc) · 1.06 KB
/
imageProcessing.py
File metadata and controls
40 lines (28 loc) · 1.06 KB
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
""" This file is used to take all of the images outputted from imageCapture.py and detect the brightest pixel """
import cv2
import numpy as np
import os
import sys
import subprocess
imNum = 0
lightList = []
os.makedirs(f'Images/CircImages/{sys.argv[1]}', exist_ok=True)
for image in os.listdir(f'Images/{sys.argv[1]}'):
f = os.path.join(f'Images/{sys.argv[1]}', image)
if os.path.isfile(f):
light = cv2.imread(f'Images/{sys.argv[1]}/{imNum}.jpg')
lightRGB = np.copy(light)
# lightGrey = np.copy(light)
lightGrey = cv2.cvtColor(np.copy(light), cv2.COLOR_RGB2GRAY)
lightBlur = cv2.GaussianBlur(lightGrey, (21, 21), 0)
(minVal, maxVal, minLoc, maxLoc) = cv2.minMaxLoc(lightBlur)
lightCirc = cv2.circle(lightRGB, maxLoc, 21, (0, 0, 255), 4)
cv2.imwrite(f'Images/CircImages/{sys.argv[1]}/{imNum}Alt.jpg', lightCirc)
lightList.append(maxLoc)
imNum += 1
else:
continue
print(lightList)
with open(r'light_coords', 'w') as txt:
for item in lightList:
txt.write(f"{item}\n")