I have a delegate receiving frames from the camera.
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
{
CVPixelBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
// ....
}
I want to render the pixel buffer into a SKNode in the most efficient way possible.
For example one way might be to render it to a UIImage and add updating the texture property of a SKSpriteNode?
sprite.texture = [SKTexture textureWithImage:frameAsUIImage];
- What would be the most efficient way to do this? (e.g. would
textureWithData:be better?) - Would it need to be done inside the
update:method of the SpriteKit run loop?