Search code examples
iphoneiosimage-processingquartz-2d

Perspective correction of UIImage from Points


I'm working on a app where I'll let the user take a picture e.g of a business card or photograph.

The user will then mark the four corners of the object (which they took a picture off) - Like it is seen in a lot of document/image/business card scanning apps:

enter image description here

My question is how do i crop and fix the perspective according to these four points? I've been searching for days and looked at several image proccessing libraries without any luck.

Any one who can point me in the right direction?


Solution

  • From iOS8+ there is Filter for Core Image called CIPerspectiveCorrection. All you need to do is pass the image and four points.Perspective Correction

    Also there is one more filter supporting iOS6+ called CIPerspectiveTransform which can be used in similar way (skewing image).