Example of perspective animation of a photo.
This is an implementation of how to detect a rectangle from a camera and animate a perspective.
AVFoundation
for taking a photo.Vision
for on the fly rectangle detection from the camera.CoreImage
for filtering image.
- Launch a camera and observe output for rectangles.
- When a rectangle is detected, show it at the UI.
- Take a picture and apply a perspective correction filter to get the resulting image.
- Calculate the 4x4 transform matrix to animate from the initial image to the resulting image.
Implementation is simplified for clarity.
- Alexander Khlebnikov for rectangle detection.
- Paul Zabelin for transform matrix calculator.
- Anton Glezman for the article resource.