Skip to content

Javascript implementation of the getPerspectiveTransform() method from OpenCV to calculate a 2D perspective transformation matrix.

Notifications You must be signed in to change notification settings

fccm/getPerspectiveTransform

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

getPerspectiveTransform

Javascript implementation of the getPerspectiveTransform() method from OpenCV to calculate a perspective transformation matrix.

This affine transformation matrix is calculated from 8 points:

  • the 4 first are the original points,
  • the last 4 are the transformed points,

the result is a 4x4 matrix calculated for the transform of css parameter

<script src="./getPerspectiveTransform.js"></script>
<script>
  const op = [[-100, -49], [1, -91], [-12, 101], [117, 25]];
  const np = [[-160, -120], [160, -120], [-160, 120], [160, 120]]
  const m = getPerspectiveTransform(...op, ...np)
  document.querySelector('#image').style.transform = 'matrix3d(' + m.join(',') + ')';
</script>

Perspective Transformation Result

See the OpenCV documentation for this function (at the end of the page)

See the demo

About

Javascript implementation of the getPerspectiveTransform() method from OpenCV to calculate a 2D perspective transformation matrix.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 78.2%
  • HTML 21.8%