How to fix image perspective distortion and rotati

2019-03-21 12:13发布

问题:

I have some images that takes using mobile phone. Is there any JavaScript library which can straighten the photo of a paper and flatten it? For example I want to create a rectangular image without any distortion from this image.

In the other words I want to know how to fix perspective distortion and rotation with JavaScript?

For example I found below sample image from this article:

How to fix this type of image with javascript?

回答1:

Looks like https://www.npmjs.com/package/perspective-transform is what you are looking for.

Create functions to map points from one arbitrary quadrilateral to another and vice versa with the inverse



回答2:

JSFeat can do that for you. There even is an example for perspective distortion. You'll have to add/compute the source and destination points yourself.