コード例 #1
0
#3.
closed_eyes_time = []  #The time eyes were being offed.
TIMER_FLAG = False  #Flag to activate 'start_closing' variable, which measures the eyes closing time.
ALARM_FLAG = False  #Flag to check if alarm has ever been triggered.

#4.
ALARM_COUNT = 0  #Number of times the total alarm rang.
RUNNING_TIME = 0  #Variable to prevent alarm going off continuously.

#5.
PREV_TERM = 0  #Variable to measure the time eyes were being opened until the alarm rang.

#6. make trained data
np.random.seed(9)
power, nomal, short = mtd.start(
    25
)  #actually this three values aren't used now. (if you use this, you can do the plotting)
#The array the actual test data is placed.
test_data = []
#The array the actual labeld data of test data is placed.
result_data = []
#For calculate fps
prev_time = 0


def eye_aspect_ratio(eye):
    A = dist.euclidean(eye[1], eye[5])
    B = dist.euclidean(eye[2], eye[4])
    C = dist.euclidean(eye[0], eye[3])
    ear = (A + B) / (2.0 * C)
    return ear
コード例 #2
0
# 4.When the alarm rings, count the number of times it is ringing, and prevent the alarm from ringing continuously.

ALARM_COUNT = 0  # Number of times the total alarm rang.
RUNNING_TIME = 0  # Variable to prevent alarm going off continuously.

# 5.We should count the time eyes are being opened for data labeling.

# Variable to measure the time eyes were being opened until the alarm rang.
PREV_TERM = 0

# 6.Variables for trained data generation and calculation fps.make trained data

np.random.seed(9)
# actually these three values aren't used now. (if you use this, you can do the plotting)
power, nomal, short = mtd.start(25)
# The array the actual test data is placed.
test_data = []
# The array the actual labeld data of test data is placed.
result_data = []
# For calculate fps
prev_time = 0

# 7.Detect face & eyes.

print("loading facial landmark predictor...")
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat")

(lStart, lEnd) = face_utils.FACIAL_LANDMARKS_IDXS["left_eye"]
(rStart, rEnd) = face_utils.FACIAL_LANDMARKS_IDXS["right_eye"]