Update intensity_eye_open.py

This commit is contained in:
Prohurtz 2023-02-12 18:55:06 -08:00
parent 0d300a43d5
commit 3f2742717c

View File

@ -28,10 +28,6 @@ class EyeId(IntEnum):
#TODO There is a bug where eyeID is not correct which causes dual eye to fail when frame of
# one eye is smaller than tracked cord of other eye. seems to be stuck on LEFT
lct = time.time() lct = time.time()
data = None data = None
@ -89,7 +85,6 @@ def newdata(frameshape):
def check_and_load(frameshape, now_data, fname): def check_and_load(frameshape, now_data, fname):
# In the future, both eyes may be processed at the same time. Therefore, data should be passed as arguments.
req_newdata = False req_newdata = False
# Not very clever, but increase the width by 1px to save the maximum value. # Not very clever, but increase the width by 1px to save the maximum value.
frameshape = (frameshape[0], frameshape[1]+1) frameshape = (frameshape[0], frameshape[1]+1)
@ -112,6 +107,7 @@ def check_and_load(frameshape, now_data, fname):
req_newdata = True req_newdata = True
if req_newdata: if req_newdata:
now_data = newdata(frameshape) now_data = newdata(frameshape)
# data2csv(now_data, "a.csv") # data2csv(now_data, "a.csv")
# csv2data(frameshape,"a.csv") # csv2data(frameshape,"a.csv")
return now_data return now_data
@ -120,8 +116,7 @@ def check_and_load(frameshape, now_data, fname):
def intense(x, y, frame, eye_id): def intense(x, y, frame, eye_id):
global lct, data global lct, data
e = False e = False
print(eye_id) if eye_id in [EyeId.RIGHT]: #TODO run only once
if eye_id in [EyeId.RIGHT]:
fname = "IBO_RIGHT.png" fname = "IBO_RIGHT.png"
eye = "RIGHT" eye = "RIGHT"
if eye_id in [EyeId.LEFT]: if eye_id in [EyeId.LEFT]:
@ -146,7 +141,7 @@ def intense(x, y, frame, eye_id):
# numpy:np.sum(),ndarray.sum() # numpy:np.sum(),ndarray.sum()
# opencv:cv2.sumElems() # opencv:cv2.sumElems()
# I don't know which is faster. # I don't know which is faster.
print(frame.shape[1], frame.shape[0], int_x, int_y, eye) #print(frame.shape[1], frame.shape[0], int_x, int_y, eye)
changed = False changed = False
newval_flg = False newval_flg = False
if int_y >= frame.shape[0]: if int_y >= frame.shape[0]:
@ -209,7 +204,7 @@ def intense(x, y, frame, eye_id):
# print(intensity, maxp, minp, x, y) # print(intensity, maxp, minp, x, y)
# print(f"EYEOPEN: {eyeopen}") # print(f"EYEOPEN: {eyeopen}")
# print(int(x), int(y), eyeopen, maxp, minp) # print(int(x), int(y), eyeopen, maxp, minp)
print(data[0, -1])
if changed and ((time.time() - lct) > 4): # save every 4 seconds if something changed to save disk usage if changed and ((time.time() - lct) > 4): # save every 4 seconds if something changed to save disk usage
cv2.imwrite(fname, u32_u16_1ch3ch(data)) cv2.imwrite(fname, u32_u16_1ch3ch(data))
lct = time.time() lct = time.time()