Giter Site home page Giter Site logo

page_dewarp's People

Contributors

mzucker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

page_dewarp's Issues

dewarp deviate from orbit location

Thanks for great work @mzucker , I try to dewarp line in page, I think algorithm work well, but output of dewarp not in the same location. I wish to dewarp the same position output. How to config it. Thanks in advance
image
left is keypoint detection and optimization, right is output dewarp(but location change)

No module named cv2 / add requirements.txt file?

Very nice project. However, I just can't make it work because of missing cv2 requirement (and possibly others):

Traceback (most recent call last):
  File "../page_dewarp.py", line 15, in <module>
    import cv2
ImportError: No module named cv2

Perhaps you could add a requirements.txt file to your repo?

cannot install

Thank you for building this software but I cannot figure out how to install it. 99% of the time software comes with pip install instructions, for that 1% of the time when the software does not I have a very difficult time getting it to work.

Python3 issues

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

Regarding output

Hi,
Thanks for such an interesting implementation. I have got some doubts while I trying to implement on my image,
canara_01
I couldn't get any better output. I found most of my images got rotation error, can you suggest me from which part of the code I get the angle of rotation, so I can easily rotate it.

Thanks

incompatible with recent opencv versions?

It's a very nice project you have here.

I tried to run the project on ArchLinux with opencv 4 installed and with a virtualenv just for page_dewarp and I get the following error:

(venv) $ python page_dewarp.py example_input/boston_cooking_a.jpg 
loaded boston_cooking_a.jpg with size 2448x3264 and resized to 490x653
Traceback (most recent call last):
  File "page_dewarp.py", line 915, in <module>
    main()
  File "page_dewarp.py", line 867, in main
    cinfo_list = get_contours(name, small, pagemask, 'text')
  File "page_dewarp.py", line 450, in get_contours
    cv2.CHAIN_APPROX_NONE)
ValueError: need more than 2 values to unpack

Any idea?

Type Error TypeError: '<' not supported between instances of 'ContourInfo' and 'ContourInfo'

The code works fine for a some of my own images, but for a few images I get this TypeError:

Traceback (most recent call last):
File "page_dewarp.py", line 918, in
main()
File "page_dewarp.py", line 871, in main
spans = assemble_spans(name, small, pagemask, cinfo_list)
File "page_dewarp.py", line 493, in assemble_spans
candidate_edges.sort()
TypeError: '<' not supported between instances of 'ContourInfo' and 'ContourInfo'

implementation

Sorry for the silly question, but how is this used? I appear to have this and all requirements in place, but I don't follow how to actually use it on an image.

Installation error due to cv2 dependency

I created a virtualenv and tried to install in it like below:

$ pip install -r ./requirements.txt 
Collecting page_dewarp
  Downloading page_dewarp-0.1.5-py3-none-any.whl (23 kB)
Collecting numpy
  Using cached numpy-1.26.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.2 MB)
Collecting scipy
  Downloading scipy-1.13.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (38.6 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 38.6/38.6 MB 13.9 MB/s eta 0:00:00
Collecting Image
  Downloading image-1.5.33.tar.gz (15 kB)
  Preparing metadata (setup.py) ... done
ERROR: Could not find a version that satisfies the requirement cv2>=3.0 (from versions: none)
ERROR: No matching distribution found for cv2>=3.0

Python version:

$ python3 --version
Python 3.10.12

Error: Need more than 2 values to unpack

Sorry I cannot get this to work, and there is nothing in the readme about additional values?

Cheers for any help you can give me

loaded boston_cooking_a.jpg with size 2448x3264 and resized to 490x653
Traceback (most recent call last):
File "../page_dewarp.py", line 915, in
main()
File "../page_dewarp.py", line 867, in main
cinfo_list = get_contours(name, small, pagemask, 'text')
File "../page_dewarp.py", line 450, in get_contours
cv2.CHAIN_APPROX_NONE)
ValueError: need more than 2 values to unpack

Chinese recognition

Could you please tell me how to set the parameters for better Chinese recognition? I have tried recognizing English, and it works quite accurately, but recognizing Chinese is more challenging

Python 3

I tried to run this, but python 2 is deprecated, cv2 is not in pip anymore, there is opencv-python, but when I installed that and other dependences, I get errors...

╰─➤  page_dewarp.py example_input/boston_cooking_a.jpg
loaded boston_cooking_a.jpg with size 2448x3264 and resized to 490x653
Traceback (most recent call last):
  File "page_dewarp.py", line 1001, in <module>
    main()
  File "page_dewarp.py", line 954, in main
    cinfo_list = get_contours(name, small, pagemask, "text")
  File "page_dewarp.py", line 489, in get_contours
    mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE
ValueError: need more than 2 values to unpack

ValueError: need more than 2 values to unpack

Hello, I have ran the code as mention in comments using python page_dewarp.py Img.
Following error occurred after running the code.

python page_dewarp.py IMG_20190717_114448.jpg
loaded IMG_20190717_114448.jpg with size 2250x4000 and resized to 375x667
Traceback (most recent call last):
File "page_dewarp.py", line 915, in
main()
File "page_dewarp.py", line 867, in main
cinfo_list = get_contours(name, small, pagemask, 'text')
File "page_dewarp.py", line 450, in get_contours
cv2.CHAIN_APPROX_NONE)
ValueError: need more than 2 values to unpack

Optimization of reprojection error in C++ - looking for solver

Hi Matt,
I'm working on C++ version of this code. Only optimization of reprojection error left to translate. Could you suggest C++ library that could help in this problem? I'm looking for solver to translate lines 731-748 into C++. I tried dlib, now struggling with Ceres Solver. Do you have any suggestion?

Best regards
Artur

Page dewarp cuts text

I have been using this using the command line python page_dewarp.py image.jpg with the included images successfully but when using an image of my own I could see that the text is cropped and cut.

The image was a 2MB jpeg with the resolution of 3400x4600px

This is the original and the resulted image:
image

Do you know what might be the problem? Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.