GithubHelp home page GithubHelp logo

jaso203 / perspectivecorrection Goto Github PK

View Code? Open in Web Editor NEW

This project forked from guicoe/perspectivecorrection

0.0 1.0 0.0 38.86 MB

This is a projective geometry project aiming to correct perspective distortions in images after a user identifies pairs of horizontal and vertical lines.

Python 100.00%

perspectivecorrection's Introduction

PerspectiveCorrection

This is a projective geometry project aiming to correct perspective distortions in images after a user identifies pairs of horizontal and vertical lines.

perspectiveplayground.py

Used for generating images with rectangles viewed from different perspectives. Some of the resulting test images can be found in test_images.

This is written using Pythonista 3 on a 2019 iPad Pro. It uses some of Pythonista's built-in modules, so you'll probably need to run it using Pythonista 3. You'll also need an Apple Pencil to tilt the plane. Future update will include sliders to tilt the plane horizontally and vertically without an Apple Pencil.

perspectivecorrection.py

This is the main part of the project containing the functions needed to correct the perspective in an image. It still needs a UI where a user can choose the image to be corrected and identify pairs of "horizontal" and "vertical" lines.

Process for Perspective Correction

  1. User identifies a pair of horizontal line segments and a pair of vertical line segments.
  2. Extend line segments until they form a quadrilateral.
  3. Find intersection for each pair of lines in projective space.
  4. Detect position of focal plane.
  5. Find vector normal to target plane.
  6. Project vertices of quadrilateral in focal plane onto target plane.
  7. Rotate target plane so that it's orthogonal to the line of sight.
  8. Project vertices of quadrilateral (should be a rectangle) in target plane to focal plane.
  9. Rotate if necessary so that the rectangle's sides are horizontal and vertical.
  10. Use old points along with new points to warp the perspective of the image accordingly.
  11. Allow user to constrain crop the output and export the corrected image.

perspectivecorrection's People

Contributors

guicoe avatar

Watchers

 avatar

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.