npm

Need private packages and team management tools?Check out npm Orgs. »

fix-perspective

1.0.0 • Public • Published

fix-perspective

Computes and applies perspective correction given 4 corners

Based on the following sources:

NPM

Build status dependencies devdependencies

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 = require('fix-perspective');
var transformation = fixPerspective(from, to);
// any point in the original (FROM) coordinate system
var out = transformation(100, 60);
// 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

install

npm i fix-perspective

Downloadsweekly downloads

34

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability