To my surprise, there is nothing information about VTPixelRotationSession on the Internet. I tried Baidu and Bing, and I got nothing about it. Here is my code:
var rotationSession: VTPixelRotationSession!
override func viewDidLoad() { let state = VTPixelRotationSessionCreate(kCFAllocatorDefault, &rotationSession) if state != 0 { return } VTSessionSetProperty(rotationSession, key: kVTPixelRotationPropertyKey_Rotation, value: kVTRotation_CW90) }
func rotate(sourceBuffer: CVImageBuffer) { let pixelFormat = CVPixelBufferGetPixelFormatType(sourceBuffer) var rotatedImage: CVPixelBuffer? CVPixelBufferCreate(kCFAllocatorDefault, 640, 480, pixelFormat, nil, &rotatedImage) let state = VTPixelRotationSessionRotateImage(rotationSession, sourceBuffer, rotatedImage) if state == kCVReturnSuccess { ...... }
}
The rotatedImageBuffer does not get any pixels of the sourceImageBuffer after calling VTPixelRotationSessionRotateImage.
Anyone can explain this issue? Apple official does not give any examples about it.