Visualize points on top of an image. Args: coords (np.ndarray): A 2D array of shape (N, 2). labels (np.ndarray): A 1D array of shape (N,). image (np.ndarray): A 3D array of shape (H, W, 3). Returns: np.ndarray: A 3D array of shape (H,
(self, coords: np.ndarray, labels: np.ndarray,
image: np.ndarray)
| 899 | self.sam_predictor.set_image(img) |
| 900 | |
| 901 | def show_points(self, coords: np.ndarray, labels: np.ndarray, |
| 902 | image: np.ndarray) -> np.ndarray: |
| 903 | """Visualize points on top of an image. |
| 904 | |
| 905 | Args: |
| 906 | coords (np.ndarray): A 2D array of shape (N, 2). |
| 907 | labels (np.ndarray): A 1D array of shape (N,). |
| 908 | image (np.ndarray): A 3D array of shape (H, W, 3). |
| 909 | Returns: |
| 910 | np.ndarray: A 3D array of shape (H, W, 3) with the points |
| 911 | visualized on top of the image. |
| 912 | """ |
| 913 | pos_points = coords[labels == 1] |
| 914 | neg_points = coords[labels == 0] |
| 915 | for p in pos_points: |
| 916 | image = cv2.circle( |
| 917 | image, p.astype(int), radius=3, color=(0, 255, 0), thickness=-1) |
| 918 | for p in neg_points: |
| 919 | image = cv2.circle( |
| 920 | image, p.astype(int), radius=3, color=(255, 0, 0), thickness=-1) |
| 921 | return image |
| 922 | |
| 923 | |
| 924 | def segment_image_with_click(self, img, is_positive: bool, |
no outgoing calls
no test coverage detected