mirror of
https://github.com/EyeTrackVR/EyeTrackVR.git
synced 2025-11-04 14:39:42 +08:00
fix blink algo crash, do not resize small frames
This commit is contained in:
parent
58a86f158f
commit
8f2709253c
@ -17,27 +17,27 @@ def BLINK(self):
|
|||||||
else:
|
else:
|
||||||
self.filterlist.pop(0)
|
self.filterlist.pop(0)
|
||||||
self.filterlist.append(intensity)
|
self.filterlist.append(intensity)
|
||||||
|
if intensity >= np.percentile(self.filterlist, 99) or intensity <= np.percentile(self.filterlist, 1) and len(self.max_ints) >= 1: # filter abnormally high values
|
||||||
|
try: # I don't want this here but I cant get python to stop crying when it's not
|
||||||
|
intensity = min(self.max_ints)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
if intensity >= np.percentile(self.filterlist, 99) or intensity <= np.percentile(self.filterlist, 1): # filter abnormally high values
|
self.frames = self.frames + 1
|
||||||
# print('filter, assume blink')
|
if intensity > self.max_int:
|
||||||
intensity = min(self.max_ints)
|
self.max_int = intensity
|
||||||
|
if self.frames > 300: #TODO: test this number more (make it a setting??)
|
||||||
|
self.max_ints.append(self.max_int)
|
||||||
|
if intensity < self.min_int:
|
||||||
|
self.min_int = intensity
|
||||||
|
|
||||||
|
if len(self.max_ints) > 1:
|
||||||
# self.frames = self.frames + 1
|
if intensity > min(self.max_ints):
|
||||||
# if intensity > self.max_int:
|
blinkvalue = 0.0
|
||||||
# self.max_int = intensity
|
else:
|
||||||
#@ if self.frames > 300: #TODO: test this number more (make it a setting??)
|
blinkvalue = 0.7
|
||||||
# self.max_ints.append(self.max_int)
|
try:
|
||||||
# if intensity < self.min_int:
|
return blinkvalue
|
||||||
# self.min_int = intensity
|
except:
|
||||||
|
return 0.7
|
||||||
# if len(self.max_ints) > 1:
|
|
||||||
# if intensity > min(self.max_ints):
|
|
||||||
# blinkvalue = 0.0
|
|
||||||
# else:
|
|
||||||
# blinkvalue = 0.7
|
|
||||||
#try:
|
|
||||||
# return blinkvalue
|
|
||||||
# except:
|
|
||||||
# return 0.7
|
|
||||||
# print(self.blinkvalue, self.max_int, self.min_int, self.frames, intensity)
|
# print(self.blinkvalue, self.max_int, self.min_int, self.frames, intensity)
|
||||||
@ -139,10 +139,10 @@ class Camera:
|
|||||||
try:
|
try:
|
||||||
ret, image = self.cv2_camera.read()
|
ret, image = self.cv2_camera.read()
|
||||||
height, width = image.shape[:2] # Calculate the aspect ratio
|
height, width = image.shape[:2] # Calculate the aspect ratio
|
||||||
aspect_ratio = float(width) / float(height) # Determine the new height based on the desired maximum width
|
if int(width) > 680:
|
||||||
new_height = int(680 / aspect_ratio)
|
aspect_ratio = float(width) / float(height) # Determine the new height based on the desired maximum width
|
||||||
image = cv2.resize(image, (680, new_height))
|
new_height = int(680 / aspect_ratio)
|
||||||
# image = cv2.resize(image, (480, 480))
|
image = cv2.resize(image, (680, new_height))
|
||||||
if not ret:
|
if not ret:
|
||||||
self.cv2_camera.set(cv2.CAP_PROP_POS_FRAMES, 0)
|
self.cv2_camera.set(cv2.CAP_PROP_POS_FRAMES, 0)
|
||||||
raise RuntimeError("Problem while getting frame")
|
raise RuntimeError("Problem while getting frame")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user