perspectiveRotate()
Rotates an image in a 3D space.
Declaration
class func perspectiveRotate() -> any CIFilter & CIPerspectiveRotateReturn Value
The adjusted image.
Discussion
This method applies the perspective rotate filter to an image. The effect rotates the image in 3D space to simulate the observer changing viewing position.
The perspective rotate filter uses the following properties:
inputImageAn image with the type CIImage.
pitchA
floatrepresenting the adjustment along the pitch axis in 3D space as an NSNumber.yawA
floatrepresenting the adjustment along the vertical axis as an NSNumber.rollA
floatrepresenting the amount of horizontal axis in 3D space as an NSNumber.focalLengthA
floatrepresenting the simulated focal length as an NSNumber.
The following code creates a filter that rotates the image:
func perspectiveRotate(inputImage: CIImage) -> CIImage {
let perspectiveRotateFilter = CIFilter.perspectiveRotate()
perspectiveRotateFilter.inputImage = inputImage
perspectiveRotateFilter.pitch = 0
perspectiveRotateFilter.yaw = 0.1
perspectiveRotateFilter.roll = 0.3
perspectiveRotateFilter.focalLength = 18
return perspectiveRotateFilter.outputImage!
}[Image]