safe crop on IBO

This commit is contained in:
Prohurtz 2023-03-17 16:26:01 -05:00
parent bc1c2d1f68
commit 3525aed134

View File

@ -3,6 +3,7 @@ import time
import os
import cv2
from enums import EyeLR
from utils.img_utils import safe_crop
#higher intensity means more closed/ more white/less pupil
#Hm I need an acronym for this, any ideas?
@ -149,7 +150,8 @@ class IntensityBasedOpeness:
upper_y = min(int_y + 25, frame.shape[0])
lower_y = max(int_y - 25, 0)
frame_crop = frame[lower_y:upper_y, lower_x:upper_x]
# frame_crop = frame[lower_y:upper_y, lower_x:upper_x]
frame_crop = safe_crop(frame, lower_x, lower_y, upper_x, upper_y, 1)
# The same can be done with cv2.integral, but since there is only one area of the rectangle for which we want to know the total value, there is no advantage in terms of computational complexity.
intensity = frame_crop.sum() + 1
# numpy:np.sum(),ndarray.sum()