Beispiel #1
0
    def make_text_center_line(self, sideline1, sideline2, center_line, radius, \
                              tcl_mask, radius_map, sin_map, cos_map, expand=0.2, shrink=1):

        # TODO: shrink 1/2 * radius at two line end
        for i in range(shrink, len(center_line) - 1 - shrink):

            c1 = center_line[i]
            c2 = center_line[i + 1]
            top1 = sideline1[i]
            top2 = sideline1[i + 1]
            bottom1 = sideline2[i]
            bottom2 = sideline2[i + 1]

            sin_theta = vector_sin(c2 - c1)
            cos_theta = vector_cos(c2 - c1)

            p1 = c1 + (top1 - c1) * expand
            p2 = c1 + (bottom1 - c1) * expand
            p3 = c2 + (bottom2 - c2) * expand
            p4 = c2 + (top2 - c2) * expand
            polygon = np.stack([p1, p2, p3, p4])

            self.fill_polygon(tcl_mask, polygon, value=1)
            self.fill_polygon(radius_map, polygon, value=radius[i])
            self.fill_polygon(sin_map, polygon, value=sin_theta)
            self.fill_polygon(cos_map, polygon, value=cos_theta)
Beispiel #2
0
 def stride(disks, other_contour, left, step=0.3):
     if len(disks) < 2:
         return False
     if left:
         last_point, before_point = disks[:2]
     else:
         before_point, last_point = disks[-2:]
     radius = last_point[2]
     cos = vector_cos(last_point[:2] - before_point[:2])
     sin = vector_sin(last_point[:2] - before_point[:2])
     new_point = last_point[:2] + radius * step * np.array([cos, sin])
     return self.in_contour(other_contour, new_point)