FaceRec icon indicating copy to clipboard operation
FaceRec copied to clipboard

divide by 0 in align_custom.py

Open BabuTango opened this issue 5 years ago • 2 comments

this is the points(landmarks): [108 124 108 106 119 19 22 32 41 44]

this line, abs(points[1] - points[2]) / abs(points[0] - points[2]) > 2: throws RuntimeWarning: divide by zero encountered in long_scalars, because [0] and [2] are same, subtracting them results in 0.

BabuTango avatar Jul 01 '19 08:07 BabuTango

i have same problem with you how can i fix it?

hsm4703 avatar Jul 12 '19 14:07 hsm4703

just go to AlignCustom def getPos(self, points): and add the following try:

            if abs(points[0] - points[2]) / abs(points[1] - points[2]) > 2:
                return "Right"
            elif abs(points[1] - points[2]) / abs(points[0] - points[2]) > 2:
                return "Left"
            return "Center"
        except expression as identifier:
            return "Center"

eitamring avatar May 05 '20 08:05 eitamring