mzucker / page_dewarp

Text page dewarping using a "cubic sheet" model
https://mzucker.github.io/2016/08/15/page-dewarping.html
MIT License
1.43k stars 238 forks source link

Python3 issues #27

Open cybernard opened 2 years ago

cybernard commented 2 years ago

First all print statements need to be converted from print "" to print()

floating point errors here: 561 wrap values in int() due to floating point error 795 int(width...) 796 int(height....)


general errors which need handling

some text is white washed away

DSC05331 z

Traceback (most recent call last): File "page_dewarp.py", line 915, in main() File "page_dewarp.py", line 868, in main cinfo_list = get_contours(name, small, pagemask, 'text') File "page_dewarp.py", line 470, in get_contours contours_out.append(ContourInfo(contour, rect, tight_mask)) File "page_dewarp.py", line 376, in init self.center, self.tangent = blob_mean_and_tangent(contour) File "page_dewarp.py", line 352, in blob_mean_and_tangent mean_x = moments['m10'] / area ZeroDivisionError: float division by zero

apparently area can be 0 so we need to protect against this

If area==0: area=1

Resizing the image resulted in problems for me, so I nulled it out with img=src

rramphal commented 2 years ago

It looks like there are already some open PRs to update the codebase: #14, #15, #20, #25 (most recent) in case they are useful to you.