[ocrfeeder] Make the boxes adjustments dependent on the LayoutAnalysis's settings



commit dcd85af5cdacd2325c2bb5be1d8d111c83685525
Author: Joaquim Rocha <jrocha igalia com>
Date:   Wed Jul 14 11:01:51 2010 +0200

    Make the boxes adjustments dependent on the LayoutAnalysis's settings
    
    layoutAnalysis.LayoutAnalysis: Add the adjust_boxes_bounds and the
    adjustment_size settings; Use the adjustment_size for the boxes'
    adjustment and only perform this operation if the adjust_boxes_bounds
    is set to True.

 feeder/layoutAnalysis.py |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/feeder/layoutAnalysis.py b/feeder/layoutAnalysis.py
index 29e603a..9a49e26 100644
--- a/feeder/layoutAnalysis.py
+++ b/feeder/layoutAnalysis.py
@@ -382,12 +382,16 @@ class LayoutAnalysis(object):
                  window_size = None,
                  improve_column_detection = True,
                  column_size = None,
-                 clean_text = True):
+                 clean_text = True,
+                 adjust_boxes_bounds = True,
+                 boxes_bounds_adjustment_size = None):
         self.ocr_engine = ocr_engine
         self.window_size = window_size
         self.column_size = column_size
         self.improve_column_detection = improve_column_detection
         self.clean_text = clean_text
+        self.adjust_boxes_bounds = adjust_boxes_bounds
+        self.boxes_bounds_adjustment_size = boxes_bounds_adjustment_size
 
     def recognize(self, path_to_image, page_resolution):
         image_processor = ImageProcessor(path_to_image,
@@ -409,9 +413,10 @@ class LayoutAnalysis(object):
             block_bounds = bounds_optimized
 
         # Adjust margins (optimization of results)
-        block_bounds = [image_processor.adjustImageClipMargins(bounds, \
-                                                     self.column_size) \
-                        for bounds in block_bounds]
+        if self.adjust_boxes_bounds:
+            block_bounds = [image_processor.adjustImageClipMargins(bounds, \
+                                        self.boxes_bounds_adjustment_size) \
+                            for bounds in block_bounds]
 
         image = image_processor.original_image
         data_boxes = [self.__recognizeImageFromBounds(image,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]