title: CIDetector Perspective And Crop in Swift
body: <p>I've implemented a <code>CIDetector</code> in my app to detect rectangles on a image, but now how can i use the returned <code>CGPoint</code>'s to crop the image so that i can display it back?</p>
  
  <p>For the perspective i've tried applying the CIPerspectiveCorrection filter, but couldn't get it to work.</p>
  
  <p>I've searched around and found some clues but couldn't find a solution in Swift.</p>
  
  <p>How do i use the data provided by the <code>CIDetector</code> (detected rectangle) to fix perspective and crop my image?</p>
  
  <p>For anyone who might not be familiar with what a <code>CIDetectorTypeRectangle</code> returns: it returns 4 <code>CGPoint</code>'s bottomLeft,bottomRight,topLeft,topRight.</p>