2016-03-24 23 views

cevap

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

Swift 3, basit bir çözüm

izin faceScanningArea = CGRect (x: 0, y 0, genişliği: 50, yükseklik: 50)

theFaceFrame.image = UIImage (cgImage (orginalImage .image? .cgImage) !. kırpma (için: faceScanningArea)!)

İlgili konular