(points, image, visible=None, correct=None)
| 64 | |
| 65 | |
| 66 | def plot_points(points, image, visible=None, correct=None): |
| 67 | colors = get_n_colors(len(points), pastel_factor=0.2) |
| 68 | if correct is None: |
| 69 | correct = [1] * len(points) |
| 70 | for i, (coord, color, visible_, correct_) in enumerate( |
| 71 | zip(points, colors, visible, correct) |
| 72 | ): |
| 73 | if visible_ == 1: |
| 74 | color = [255 * c for c in color] |
| 75 | if correct_: |
| 76 | image = cv2.circle( |
| 77 | np.ascontiguousarray(image), |
| 78 | tuple(coord.astype("int32")), |
| 79 | 4, |
| 80 | color, |
| 81 | 2, |
| 82 | ) |
| 83 | else: |
| 84 | # plot x |
| 85 | image = cv2.line( |
| 86 | np.ascontiguousarray(image), |
| 87 | tuple(coord.astype("int32") - 4), |
| 88 | tuple(coord.astype("int32") + 4), |
| 89 | color, |
| 90 | 2, |
| 91 | ) |
| 92 | image = cv2.line( |
| 93 | np.ascontiguousarray(image), |
| 94 | tuple(coord.astype("int32") + np.array([-4, 4])), |
| 95 | tuple(coord.astype("int32") - np.array([-4, 4])), |
| 96 | color, |
| 97 | 2, |
| 98 | ) |
| 99 | # plot index next to point |
| 100 | image = cv2.putText( |
| 101 | np.ascontiguousarray(image), |
| 102 | str(i), |
| 103 | tuple(coord.astype("int32") + np.array([4, 4])), |
| 104 | cv2.FONT_HERSHEY_SIMPLEX, |
| 105 | 0.5, |
| 106 | color, |
| 107 | 1, |
| 108 | ) |
| 109 | return image |
| 110 | |
| 111 | |
| 112 | def visualize_vertices(verts, img, cmap="hot"): |
no test coverage detected