Example #1
0
 def __init__(self, p0, p1, center):
     self.p0 = p0
     self.p1 = p1
     self.center = center
     self.radius = self.center.distance(self.p0)
     line1 = Line(self.center, self.p1)
     line2 = Line(self.center, self.p0)
     self.central_angle = line1.angle_between(line2)
Example #2
0
def calculateFaceTilt(leftEye, rightEye):
    zeroLine = Line(Point(1, 0), Point(0, 0))
    eyeMiddlePoint = Point((leftEye + rightEye) / 2)
    eyeLine = Line(leftEye, rightEye)
    angle = mpmath.degrees(eyeLine.angle_between(zeroLine))
    if (leftEye.y > rightEye.y):
        return int(angle) - 180
    else:
        return 180 - int(angle)
Example #3
0
    def _calculate_angle(line: Line) -> float:
        angle = line.angle_between(Line((0, 0), (1, 0))).evalf()
        if line.p2.x <= line.p1.x:
            if line.p2.y <= line.p1.y:
                angle = math.pi - angle + math.pi
        else:
            if line.p2.y <= line.p1.y:
                angle = 2 * math.pi - angle

        return angle
def calculateFaceTilt(faceEyesIrisPoints, regionOfInterestColorObjects):
    zeroLine = Line (Point (1,0), Point (0,0));
    leftEye = Point (faceEyesIrisPoints.pop());
    rightEye =  Point (faceEyesIrisPoints.pop());
    eyeMiddlePoint = Point ((leftEye + rightEye)/2);       
    eyeLine = Line (leftEye, rightEye);
    faceSymmetryLine = eyeLine.perpendicular_line(eyeMiddlePoint);
    angle = mpmath.degrees(eyeLine.angle_between(zeroLine));
    if (int(angle) > 90):    
        return {'angle':int(angle) - 180, 'tiltline':faceSymmetryLine};
    else:
        return {'angle':int(angle), 'tiltline':faceSymmetryLine};
Example #5
0
def calculateFaceTilt(faceEyesIrisPoints, regionOfInterestColorObjects):
    zeroLine = Line(Point(1, 0), Point(0, 0))
    leftEye = Point(faceEyesIrisPoints.pop())
    rightEye = Point(faceEyesIrisPoints.pop())
    eyeMiddlePoint = Point((leftEye + rightEye) / 2)
    eyeLine = Line(leftEye, rightEye)
    faceSymmetryLine = eyeLine.perpendicular_line(eyeMiddlePoint)
    angle = mpmath.degrees(eyeLine.angle_between(zeroLine))
    if (int(angle) > 90):
        return {
            'angle': int(angle) - 180,
            'tiltline': faceSymmetryLine
        }
    else:
        return {
            'angle': int(angle),
            'tiltline': faceSymmetryLine
        }
Example #6
0
    def new_change_of_direction(self, debug=False):
        if len(self.robot) < 3:
            self.directions.append(0)
            #return 0
        else:
            # TODO: mozda napraviti provjeru da li su sve tocke razlicite
            l1 = Line(self.robot[-3], self.robot[-2])
            l2 = Line(self.robot[-2], self.robot[-1])

            # TODO: mozda raditi razliku izmedu vrsta okreta
            turn = l1.angle_between(l2)
            self.directions.append(turn)
            if turn != 0:
                self.number_of_turns += 1
            #return l1.angle_between(l2)
        if debug:
            print("Number of turns = ", self.number_of_turns)
            print("Last turn = ", self.directions[-1])
            print("Multiple visits = ", self.multiple_visits)
    def Angle(self):
        yAxis = Line(Point(0, 1), Point(0, 0))
        point1 = Point(self.Box[1][0], self.Box[1][1])
        point2 = Point(self.Box[0][0], self.Box[0][1])
        point3 = Point(self.Box[2][0], self.Box[2][1])

        if point1.distance(point2) > point1.distance(point3):
            longerLine = Line(point1, point2)
        else:
            longerLine = Line(point1, point3)

        angle = int(math.degrees(yAxis.angle_between(longerLine)))

        if (int(angle) > 90):
            if angle - 180 + 80 >= 0:
                return angle - 180 + 80
            else:
                return 0
        else:
            if angle + 80 >= 0:
                return angle + 80
            else:
                return 0
def get_rotate_angle(shape):
    s_p_1 = shape[31]
    s_p_2 = shape[9]
    line_1 = Line(s_p_1, s_p_2)
    line_2 = Line((0, 0), (1, 0))
    return line_1.angle_between(line_2)