2016-03-24 60 views

回答

5
func cropBusinessCardForPoints(image: CIImage, topLeft: CGPoint, topRight: CGPoint, bottomLeft: CGPoint, bottomRight: CGPoint) -> CIImage { 

    var businessCard: CIImage 
    businessCard = image.imageByApplyingFilter(
     "CIPerspectiveTransformWithExtent", 
     withInputParameters: [ 
      "inputExtent": CIVector(CGRect: image.extent), 
      "inputTopLeft": CIVector(CGPoint: topLeft), 
      "inputTopRight": CIVector(CGPoint: topRight), 
      "inputBottomLeft": CIVector(CGPoint: bottomLeft), 
      "inputBottomRight": CIVector(CGPoint: bottomRight)]) 
    businessCard = image.imageByCroppingToRect(businessCard.extent) 

    return businessCard 
} 
0

夫特3,簡單的解決方案

讓faceScanningArea =的CGRect(X:0,Y:0,寬度:50,高度:50)

theFaceFrame.image = UIImage的(cgImage(orginalImage .image?.cgImage)!裁剪(到:faceScanningArea)!)