/perspective-animation-ios

Example of perspective photo animation from camera

Primary LanguageSwiftMIT LicenseMIT

📱 Perspective Animation

Redmadrobot License Platform

Example of perspective animation of a photo.

This is an implementation of how to detect a rectangle from a camera and animate a perspective.

Used frameworks

  • AVFoundation for taking a photo.
  • Vision for on the fly rectangle detection from the camera.
  • CoreImage for filtering image.

Algorithm

  1. Launch a camera and observe output for rectangles.
  2. When a rectangle is detected, show it at the UI.
  3. Take a picture and apply a perspective correction filter to get the resulting image.
  4. Calculate the 4x4 transform matrix to animate from the initial image to the resulting image.

Implementation is simplified for clarity.

See also

Special thanks