Skip to content

joyeecheung/perspective-correction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Dependencies

These scripts need python 2.7+ and the following libraries to work:

  1. pillow(~2.8.1)
  2. numpy(~1.9.0)
  3. python-opencv(~2.4.11)

The simplest way to install all of them is to install python(x,y).

If you can't install python(x,y), You can install python, numpy and python-opencv seperately, then install pip and pillow.

  1. Install python. Just use the installer from python's website
  2. Install numpy. Just use the installer from scipy's website. (You don't need scipy to run this project, so you can just install numpy alone).
  3. Install python-opencv. Download the release from its sourceforge site. (Choose the release based on your operating system, then choose version 2.4.11). The executable is just an archive. Extract the files, then copy cv2.pyd to the lib/site-packages folder on your python installation path.
  4. Install pip. Download the script for installing pip, open cmd (or termianl if you are using Linux/Mac OS X), go to the path where the downloaded script resides, and run python get-pip.py
  5. Install pillow. Run pip install pillow.

If you are running the code under Linux/Mac OS X and the scripts throw AttributeError: __float__, make sure your pillow has jpeg support (consult Pillow's document) e.g. try:

sudo apt-get install libjpeg-dev
sudo pip uninstall pillow
sudo pip install pillow

If you have any problem installing the dependencies, contact the author.

How to generate the results

  1. To generate all results, enter the src directory, run
python main.py

It will use images under dataset directory to produce the results. The results will show up in result directory. Intermediate results will be saved too.

  1. To see how long the script will need to generate the results (without saving them or the intermediate images), run
python main.py -t
  1. To generate resized final results (by 1/3), run
python main.py -r
  1. To generate intermediate results, run
python main.py -i

Or if you want resized intermidate results:

python main.py -i -r

##Directory structure

.
├─ README.md
├─ doc (report and other documents)
│   └── ...
├─ dataset (source images)
│   └── ...
├─ result (the results)
│   └── ...
└─ src (the python source code)
      ├── perspective.py (perspective correction module)
      └── main.py (generate the results for the report)

##About

About

Automatic perspective correction on photos of A4 papers using Canny detector and Hough transform with opencv-python.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages