adaptive bbox width for asthetics

This commit is contained in:
yadonglu
2024-11-04 21:42:18 -08:00
parent a804a33bee
commit 6b4828ba66
3 changed files with 17 additions and 30 deletions

View File

@@ -90,16 +90,18 @@
"image_path = 'imgs/google_page.png'\n",
"# image_path = 'imgs/windows_home.png'\n",
"image_path = 'imgs/windows_multitab.png'\n",
"draw_bbox_config = {\n",
" 'text_scale': 0.8,\n",
" 'text_thickness': 2,\n",
" 'text_padding': 3,\n",
" 'thickness': 3,\n",
"}\n",
"\n",
"BOX_TRESHOLD = 0.03\n",
"\n",
"image = Image.open(image_path)\n",
"image_rgb = image.convert('RGB')\n",
"box_overlay_ratio = image.size[0] / 3200\n",
"draw_bbox_config = {\n",
" 'text_scale': 0.8 * box_overlay_ratio,\n",
" 'text_thickness': max(int(2 * box_overlay_ratio), 1),\n",
" 'text_padding': max(int(3 * box_overlay_ratio), 1),\n",
" 'thickness': max(int(3 * box_overlay_ratio), 1),\n",
"}\n",
"\n",
"ocr_bbox_rslt, is_goal_filtered = check_ocr_box(image_path, display_img = False, output_bb_format='xyxy', goal_filtering=None, easyocr_args={'paragraph': False, 'text_threshold':0.9}, use_paddleocr=True)\n",
"text, ocr_bbox = ocr_bbox_rslt\n",