From cac172bc181dfcc1e14c972ea939013e90641a51 Mon Sep 17 00:00:00 2001 From: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Date: Thu, 9 Jan 2020 16:06:20 -0800 Subject: [PATCH 1/2] fix: use `page.bounding_box` when feature is page Closes #2702 --- vision/cloud-client/document_text/doctext.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vision/cloud-client/document_text/doctext.py b/vision/cloud-client/document_text/doctext.py index 6bffc7a1dbd..bfeee4e20a8 100644 --- a/vision/cloud-client/document_text/doctext.py +++ b/vision/cloud-client/document_text/doctext.py @@ -86,7 +86,7 @@ def get_document_bounds(image_file, feature): bounds.append(block.bounding_box) if (feature == FeatureType.PAGE): - bounds.append(block.bounding_box) + bounds.append(page.bounding_box) # The list `bounds` contains the coordinates of the bounding boxes. # [END vision_document_text_tutorial_detect_bounds] From ede0e17eb2752b5ad0764b3ca668cb0319ae98c9 Mon Sep 17 00:00:00 2001 From: Bu Sun Kim Date: Thu, 9 Jan 2020 16:41:55 -0800 Subject: [PATCH 2/2] fix: outline blocks instead of pages --- vision/cloud-client/document_text/doctext.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/vision/cloud-client/document_text/doctext.py b/vision/cloud-client/document_text/doctext.py index bfeee4e20a8..29d82d6b548 100644 --- a/vision/cloud-client/document_text/doctext.py +++ b/vision/cloud-client/document_text/doctext.py @@ -85,9 +85,6 @@ def get_document_bounds(image_file, feature): if (feature == FeatureType.BLOCK): bounds.append(block.bounding_box) - if (feature == FeatureType.PAGE): - bounds.append(page.bounding_box) - # The list `bounds` contains the coordinates of the bounding boxes. # [END vision_document_text_tutorial_detect_bounds] return bounds @@ -95,7 +92,7 @@ def get_document_bounds(image_file, feature): def render_doc_text(filein, fileout): image = Image.open(filein) - bounds = get_document_bounds(filein, FeatureType.PAGE) + bounds = get_document_bounds(filein, FeatureType.BLOCK) draw_boxes(image, bounds, 'blue') bounds = get_document_bounds(filein, FeatureType.PARA) draw_boxes(image, bounds, 'red')