I have found some code which should work, but don't.. What am I doing wrong / is missing?
Source: How to find table like structure in image
def find_table_in_boxes(boxes, cell_threshold=10, min_columns=2):
for box in boxes:
(x, y, w, h) = box
print(box)
col_key = x // cell_threshold
if __name__ == '__main__':
text_boxes = [
{
'x': 123,
'y': 512,
'w': 100,
'h': 150
},
{
'x': 500,
'y': 512,
'w': 100,
'h': 150
}
]
cells = find_table_in_boxes(text_boxes)
error
# python test.py
{'x': 123, 'w': 100, 'y': 512, 'h': 150}
Traceback (most recent call last):
File "test.py", line 22, in <module>
cells = find_table_in_boxes(text_boxes)
File "test.py", line 5, in find_table_in_boxes
col_key = x // cell_threshold
TypeError: unsupported operand type(s) for //: 'str' and 'int'