我有代表从相机接收帧。
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
{
CVPixelBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
// ....
}
我想以最有效的方式将像素缓冲区渲染为SKNode
。
例如,一种方式可能是render it to a UIImage
并添加更新SKSpriteNode
的{{3}}?
sprite.texture = [SKTexture textureWithImage:frameAsUIImage];
textureWithData:
会更好吗?)update:
方法内完成?