fix-perspective
Computes and applies perspective correction given 4 corners
Based on the following sources:
- http://codepen.io/fta/pen/JoGybG?editors=111
- http://codepen.io/fta/full/JoGybG/
- http://franklinta.com/2014/09/08/computing-css-matrix3d-transforms/
Given 4 starting points and 4 end points calculates transformation function (and matrix) that transforms any starting point. Usually used to remove perspective distortion.
// from, to are arrays with 4 points each (x, y)var from = x: 100 y: 20 x: 200 y: 50 ...;var to = x: 20 y: 0 x: 100 y: 0 ...;var fixPerspective = ;var transformation = ;// any point in the original (FROM) coordinate systemvar out = ;// out = { x: ..., y: ... };// the transformation matrix (4x4) is available as transformation.H
Small print
Author: Gleb Bahmutov © 2015
License: MIT - do anything with the code, but don't blame uTest if it does not work.
Spread the word: tweet, star on github, etc.
Support: if you find any problems with this module, email / tweet / open issue on Github