add:annotator add new_with_font

This commit is contained in:
moweilin 2024-12-05 16:58:31 +08:00
parent 4e932c4910
commit 9db432d172
1 changed files with 45 additions and 1 deletions

View File

@ -115,7 +115,51 @@ impl Annotator {
pub fn new() -> Self { pub fn new() -> Self {
Default::default() Default::default()
} }
pub fn new_with_fonts(font: &str) -> Self {
Self {
font: match Self::load_font(font) {
Ok(x) => x,
Err(err) => panic!("Failed to load font: {}", err),
},
_scale: 6.666667,
scale_dy: 28.,
polygons_alpha: 179,
saveout: None,
saveout_subs: vec![],
saveout_base: String::from("runs"),
decimal_places: 4,
without_bboxes: false,
without_bboxes_conf: false,
without_bboxes_name: false,
bboxes_text_color: Rgba([0, 0, 0, 255]),
bboxes_thickness: 1,
bboxes_thickness_threshold: 0.3,
without_bboxes_text_bg: false,
without_mbrs: false,
without_mbrs_conf: false,
without_mbrs_name: false,
without_mbrs_text_bg: false,
mbrs_text_color: Rgba([0, 0, 0, 255]),
without_keypoints: false,
with_keypoints_conf: false,
with_keypoints_name: false,
keypoints_radius: 3,
skeletons: None,
keypoints_palette: None,
without_keypoints_text_bg: false,
keypoints_text_color: Rgba([0, 0, 0, 255]),
without_polygons: false,
without_contours: false,
contours_color: Rgba([255, 255, 255, 255]),
with_polygons_name: false,
with_polygons_conf: false,
with_polygons_text_bg: false,
polygons_text_color: Rgba([255, 255, 255, 255]),
probs_topk: 5usize,
without_masks: false,
colormap: None,
}
}
pub fn with_decimal_places(mut self, x: usize) -> Self { pub fn with_decimal_places(mut self, x: usize) -> Self {
self.decimal_places = x; self.decimal_places = x;
self self