TextDetLocalVisualizer¶
- class mmocr.visualization.TextDetLocalVisualizer(name='visualizer', image=None, with_poly=True, with_bbox=False, vis_backends=None, save_dir=None, gt_color='g', gt_ignored_color='b', pred_color='r', line_width=2, alpha=0.8)[源代码]¶
The MMOCR Text Detection Local Visualizer.
- 参数
name (str) – Name of the instance. Defaults to ‘visualizer’.
image (np.ndarray, optional) – The origin image to draw. The format should be RGB. Defaults to None.
with_poly (bool) – Whether to draw polygons. Defaults to True.
with_bbox (bool) – Whether to draw bboxes. Defaults to False.
vis_backends (list, optional) – Visual backend config list. Defaults to None.
save_dir (str, optional) – Save file dir for all storage backends. If it is None, the backend storage will not save any data.
gt_color (Union[str, tuple, list[str], list[tuple]]) – The colors of GT polygons and bboxes.
colors
can have the same length with lines or just single value. Ifcolors
is single value, all the lines will have the same colors. Refer to matplotlib.colors for full list of formats that are accepted. Defaults to ‘g’.gt_ignored_color (Union[str, tuple, list[str], list[tuple]]) – The colors of ignored GT polygons and bboxes.
colors
can have the same length with lines or just single value. Ifcolors
is single value, all the lines will have the same colors. Refer to matplotlib.colors for full list of formats that are accepted. Defaults to ‘b’.pred_color (Union[str, tuple, list[str], list[tuple]]) – The colors of pred polygons and bboxes.
colors
can have the same length with lines or just single value. Ifcolors
is single value, all the lines will have the same colors. Refer to matplotlib.colors for full list of formats that are accepted. Defaults to ‘r’.line_width (int, float) – The linewidth of lines. Defaults to 2.
alpha (float) – The transparency of bboxes or polygons. Defaults to 0.8.
- 返回类型
- add_datasample(name, image, data_sample=None, draw_gt=True, draw_pred=True, show=False, wait_time=0, out_file=None, pred_score_thr=0.3, step=0)[源代码]¶
Draw datasample and save to all backends.
If GT and prediction are plotted at the same time, they are
displayed in a stitched image where the left image is the ground truth and the right image is the prediction. - If
show
is True, all storage backends are ignored, and the images will be displayed in a local window. - Ifout_file
is specified, the drawn image will be saved toout_file
. This is usually used when the display is not available.- 参数
name (str) – The image identifier.
image (np.ndarray) – The image to draw.
data_sample (
TextDetDataSample
, optional) –- TextDetDataSample which contains gt and prediction. Defaults
to None.
draw_gt (bool) – Whether to draw GT TextDetDataSample. Defaults to True.
draw_pred (bool) – Whether to draw Predicted TextDetDataSample. Defaults to True.
show (bool) – Whether to display the drawn image. Default to False.
wait_time (float) – The interval of show (s). Defaults to 0.
out_file (str) – Path to output file. Defaults to None.
pred_score_thr (float) – The threshold to visualize the bboxes and masks. Defaults to 0.3.
step (int) – Global step value to record. Defaults to 0.
- 返回类型