1

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?
Community
  • 1
  • 1
Robert
  • 37,670
  • 37
  • 171
  • 213
  • Have you gotten one of these approaches working? If so, implement the other and run some performance tests. If you haven't gotten one of these approaches working, your question about performance is one step too far ahead. – CodeSmile May 26 '14 at 19:34
  • @LearnCocos2D - Fair point - I'm trying to get it working currently. I guess I just wanted someone to tell me if I am doing something stupid! :) – Robert May 26 '14 at 20:05
  • see this: http://stackoverflow.com/questions/14383932/convert-cmsamplebufferref-to-uiimage – vim Jun 22 '14 at 08:15

0 Answers0