GithubHelp home page GithubHelp logo

homography's Introduction

homography

learning about homography, contours and fixing skewed images with OpenCV and matplotlib, as well as some Blender scripting!

motivation:

I was looking at some buildings in London via Google Maps for some inspiration for buildings to model in Blender and while looking at them from the perspective of the Google car camera thought it would awesome if I could take a snapshot of the buildings and somehow create some automation to construct at least the face of them in 3D.

The first step in doing so I thought would be to correct the perspective of the building images taken from Google Maps. With this code, the perspective correction isn't perfect but it does seem to work as it should (see example below).

original, skewed image corrected image

This code allows a user to select 4 points that enclose the area of an image they wish to perform perspective correction on.

how to run:

I recommend using miniconda. With miniconda installed you can run the following (assuming in the directory of this repo):

> conda create --name homography opencv numpy matplotlib    
> conda activate homography    
> python homography.py    

example usage:

example usage gif

next steps:

Now we can get a mostly perspective-corrected image. With this image, the next step would be to figure out how, if possible, to create a 3D representation of it in Blender (just the face of the building of course).

I was able to create a script to transfer contour data (just vertices and edges) into Blender (see blender_script.py and collect_contour_test.py) but there's still a lot of things to be figured out and reworked (especially since getting the right contour data that you might need may take some trial and error with fiddling with some parameters). Here's an example though using the unwarped image:
unwarped image in Blender

acknowledgements:

many thanks to Ashuta's great tutorial on homography: https://blog.ekbana.com/skew-correction-using-corner-detectors-and-homography-fda345e42e65

homography's People

Contributors

syncopika avatar

Watchers

 avatar  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.