MCPcopy Create free account
hub / github.com/PeizeSun/SparseR-CNN / draw_text

Method draw_text

detectron2/utils/visualizer.py:820–865  ·  view source on GitHub ↗

Args: text (str): class label position (tuple): a tuple of the x and y coordinates to place text on image. font_size (int, optional): font of the text. If not provided, a font size proportional to the image width is calculated and used.

(
        self,
        text,
        position,
        *,
        font_size=None,
        color="g",
        horizontal_alignment="center",
        rotation=0
    )

Source from the content-addressed store, hash-verified

818 """
819
820 def draw_text(
821 self,
822 text,
823 position,
824 *,
825 font_size=None,
826 color="g",
827 horizontal_alignment="center",
828 rotation=0
829 ):
830 """
831 Args:
832 text (str): class label
833 position (tuple): a tuple of the x and y coordinates to place text on image.
834 font_size (int, optional): font of the text. If not provided, a font size
835 proportional to the image width is calculated and used.
836 color: color of the text. Refer to `matplotlib.colors` for full list
837 of formats that are accepted.
838 horizontal_alignment (str): see `matplotlib.text.Text`
839 rotation: rotation angle in degrees CCW
840
841 Returns:
842 output (VisImage): image object with text drawn.
843 """
844 if not font_size:
845 font_size = self._default_font_size
846
847 # since the text background is dark, we don't want the text to be dark
848 color = np.maximum(list(mplc.to_rgb(color)), 0.2)
849 color[np.argmax(color)] = max(0.8, np.max(color))
850
851 x, y = position
852 self.output.ax.text(
853 x,
854 y,
855 text,
856 size=font_size * self.output.scale,
857 family="sans-serif",
858 bbox={"facecolor": "black", "alpha": 0.8, "pad": 0.7, "edgecolor": "none"},
859 verticalalignment="top",
860 horizontalalignment=horizontal_alignment,
861 color=color,
862 zorder=10,
863 rotation=rotation,
864 )
865 return self.output
866
867 def draw_box(self, box_coord, alpha=0.5, edge_color="g", line_style="-"):
868 """

Callers 3

overlay_instancesMethod · 0.95
draw_binary_maskMethod · 0.95

Calls 1

maxMethod · 0.80

Tested by

no test coverage detected