# Define the function for calculating the Eye Aspect Ratio(EAR)
from scipy.spatial import distance as dist
def eye_aspect_ratio(eye):
	# Vertical eye landmarks
	A = dist.euclidean(eye[1], eye[5])
	B = dist.euclidean(eye[2], eye[4])
	# Horizontal eye landmarks
	C = dist.euclidean(eye[0], eye[3])

	# The EAR Equation
	EAR = (A + B) / (2.0 * C)
	return EAR

def mouth_aspect_ratio(mouth):
	A = dist.euclidean(mouth[13], mouth[19])
	B = dist.euclidean(mouth[14], mouth[18])
	C = dist.euclidean(mouth[15], mouth[17])

	MAR = (A + B + C) / 3.0
	return MAR

def get_max_area_rect(rects):
    if len(rects) == 0: return
    areas = []
    for rect in rects:
        areas.append(rect.area())
    return rects[areas.index(max(areas))]