karolzak / boxdetect

BoxDetect is a Python package based on OpenCV which allows you to easily detect rectangular shapes like character or checkbox boxes on scanned forms.
MIT License
105 stars 20 forks source link

AttributeError: module 'boxdetect.config' has no attribute 'update_num_iterations'. Did you mean: 'dilation_iterations'? #32

Closed darylknowles closed 1 year ago

darylknowles commented 1 year ago

I am trying to run a basic demo of the get_boxes method and there seems to be an internal error or maybe I'm missing a new parameter:

from boxdetect import config from boxdetect.pipelines import get_boxes import matplotlib.pyplot as plt

config.min_w, config.max_w = (20,50) config.min_h, config.max_h = (20,50) config.scaling_factors = [0.4] config.dilation_iterations = 0 config.wh_ratio_range = (0.5, 2.0) config.group_size_range = (1,100) config.horizontal_max_distance_multiplier = 2

image_path = 'input\large.png' rects, grouped_rects, org_image, output_image = get_boxes(image_path, config, plot=False)

print("Indv boxes (green):", rects) print("Grouped boxes (red): ",grouped_rects) plt.figure(figsize=(25,25)) plt.imshow(output_image) plt.show()

========================================== Processing file: input\large.png Traceback (most recent call last): File "c:\repos\wwex\boxes.py", line 15, in rects, grouped_rects, org_image, output_image = get_boxes(image_path, config, plot=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\repos\wwex.venv\Lib\site-packages\boxdetect\pipelines.py", line 147, in get_boxes cfg.update_num_iterations() ^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'boxdetect.config' has no attribute 'update_num_iterations'. Did you mean: 'dilation_iterations'?

darylknowles commented 1 year ago

I was able to resolve the issue by changing how I was creating the config:

from boxdetect import config from boxdetect.pipelines import get_boxes import matplotlib.pyplot as plt

cfg = config.PipelinesConfig()

cfg.min_w, cfg.max_w = (20,50) cfg.min_h, cfg.max_h = (20,50) cfg.scaling_factors = [0.4] cfg.dilation_iterations = 0 cfg.wh_ratio_range = (0.5, 2.0) cfg.group_size_range = (1,100) cfg.horizontal_max_distance_multiplier = 2

image_path = 'input\large.png' rects, grouped_rects, org_image, output_image = get_boxes(image_path, cfg, plot=False)

print("Indv boxes (green):", rects) print("Grouped boxes (red): ",grouped_rects) plt.figure(figsize=(25,25)) plt.imshow(output_image) plt.show()