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
104 stars 20 forks source link

Not detecting all the boxes #22

Open Sturaga86 opened 2 years ago

Sturaga86 commented 2 years ago

Hi,

Thanks for the amazing work! I am trying to use the config to detect boxes on my image but it's not detecting all the boxes.What i should change?

Not sure why it's not detecting some of the boxes.Any ideas?

from boxdetect import config

cfg = config.PipelinesConfig()

important to adjust these values to match the size of boxes on your image

cfg.width_range = (30,500) cfg.height_range = (40,500)

the more scaling factors the more accurate the results but also it takes more time to processing

too small scaling factor may cause false positives

too big scaling factor will take a lot of processing time

cfg.scaling_factors = [1.0]

w/h ratio range for boxes/rectangles filtering

cfg.wh_ratio_range = (0.5,4.0)

group_size_range starting from 2 will skip all the groups

with a single box detected inside (like checkboxes)

cfg.group_size_range = (0,0)

num of iterations when running dilation tranformation (to engance the image)

cfg.dilation_iterations = 1

image

karolzak commented 2 years ago

Hey @Sturaga86 ! I'd probably focus on playing around with these options:

# set these ranges to as close as the real pixel sizes of boxes you want to detect
# too large range will make the algorithm very slow
# try smaller range like: 
cfg.width_range = (25,80)
cfg.height_range = (50,100)

# scaling factors is a list of scales to use to scale the input image
cfg.scaling_factors = [1.0] # maybe try [0.7, 0.9] instead. Or in another attempt [1.2] 

If you share a raw image input I could try to figure out the right config