division by zero problem

This commit is contained in:
Şefik Serangil 2020-06-28 11:28:14 +03:00
parent 68a792b290
commit b72b2ef05b

View File

@ -197,7 +197,12 @@ def detectFace(img, target_size=(224, 224), grayscale = False, enforce_detection
#--------------------------------
faces = []
try:
faces = face_detector.detectMultiScale(img, 1.3, 5)
except:
pass
#print("found faces in ",image_path," is ",len(faces))
@ -265,6 +270,8 @@ def detectFace(img, target_size=(224, 224), grayscale = False, enforce_detection
#-----------------------
#apply cosine rule
if b != 0 and c != 0: #this multiplication causes division by zero in cos_a calculation
cos_a = (b*b + c*c - a*a)/(2*b*c)
angle = np.arccos(cos_a) #angle in radian
angle = (angle * 180) / math.pi #radian to degree