def draw_angle2(image, angle, offset=(0, 0), color=(0, 0, 255), thickness=1, color2=(255, 0, 0), thickness2=1): line0 = instantiators['line'](angle.b, angle.a) line1 = instantiators['line'](angle.b, angle.c) # draw_line(image, line0, offset=offset, color=color, thickness=thickness) # draw_line(image, line1, offset=offset, color=color, thickness=thickness) # radius = 0.3 * min(line_length(line0), line_length(line1)) radius = 12 circle = instantiators['circle'](angle.b, radius) # FIXME : this arc definition is broken. Okay for now, but needs to fix. arc = instantiators['arc'](circle, angle.a, angle.c) caa = cartesian_angle(arc.circle.center, arc.a) * 180 / np.pi cab = cartesian_angle(arc.circle.center, arc.b) * 180 / np.pi if caa > cab: caa -= 360 if cab - caa > 95: return image center = tuple(round_vector(np.array(arc.circle.center) + offset)) radius = int(round(arc.circle.radius)) return cv2.ellipse(image, center, (radius, radius), 0, caa, cab, color2, thickness2)
def draw_circle2(image, circle, offset=(0, 0), color=(255, 255, 0), thickness=1): center = round_vector(np.array(circle.center) + offset) return cv2.circle(image, center, circle.radius, color, thickness=thickness)
def draw_arc(image, arc, offset=(0, 0), color=(0, 0, 255), thickness=1): caa = cartesian_angle(arc.circle.center, arc.a) * 180/np.pi cab = cartesian_angle(arc.circle.center, arc.b) * 180/np.pi if caa > cab: caa -= 360 center = tuple(round_vector(np.array(arc.circle.center) + offset)) radius = int(round(arc.circle.radius)) cv2.ellipse(image, center, (radius, radius), 0, caa, cab, color, thickness)
def draw_label(image, label, offset=(0, 0), fontScale=2, color=(0, 0, 0), thickness=1): position = round_vector(np.array(label.position) + offset) cv2.putText(image, label.text, position, cv2.FONT_HERSHEY_PLAIN, fontScale, color, thickness=thickness)
def draw_circle(image, circle, offset=(0, 0), color=(0, 0, 255), thickness=1): center = round_vector(np.array(circle.center) + offset) cv2.circle(image, center, circle.radius, color, thickness=thickness)
def draw_line(image, line, offset=(0, 0), color=(0, 0, 255), thickness=1): pt1 = round_vector(np.array(line.a) + offset) pt2 = round_vector(np.array(line.b) + offset) cv2.line(image, pt1, pt2, color, thickness=thickness)