Open farazk86 opened 3 years ago
Thanks - this is more of an issue from the detection model (it's very very hard to generate perfect bounding box detections for these models). I have script that can fix this issue, but could not share with you right now due to some copyright issues -- it should be ready within the next few weeks, and please stay tuned.
Hi there,
First thing, remove 1.05 from the below line. i.e. don't multiply at all.
left_interval = lp.Interval(0, w/2*1.05, axis='x').put_on_canvas(image)
If that does not work for you, Create your own function to append two lists and sort them using y1. Assuming that you only have 2 column layout throughout your document. Two lists to hold left and right should do the work.
text_blocks = lp.Layout([b.set(id = idx) for idx, b in enumerate(left_blocks + right_blocks)])
replace your left and right with their left and right. and ka-boom it works.
Happy coding :)
I have another approach to separate the layouts. if we want to separate left and right layout we can simply Use Kmeans clustering algorithm with number of clusters=2.
if there are two columns, find the median of right column first coordinate and calculate it difference from the all the coordinates of left columns. If the coordinates of left column block is greater than median, remove the block from left column and append it to right column. sort both blocks again. and you are done
Hi,
I'm using layout parser to perform OCR on a research paper, but on almost every page of the pdf the text boxes are not properly aligned. For example I input this page:
perform detection using:
The detected image is shown below:
As can be seen, the bottom left box is not properly aligned, which causes problem with the sort script, as given in the tutorial:
The misaligned box is given an index of
0
. Which is not correct.Is there any way to avoid this problem?
Thank you