5. Rendering

Using the sampleBuffer and metadataObjects passed to ARGSession, rendering process starts. Once rendered, didUpdateFrame of ARGSessionDelegate in ARGSession is called and it returns ARGFrame. renderedPixelBuffer in ARGFrame contains finally rendered data in CVPixelBuffer data type.

Sample App draws rendered frames using this data and OpenGLView connected to ARGScene Interface.

A sample code below shows how to obtain renderedPixelBuffer in ARGFrame from didUpdateFrame.

Objective-C
Swift
Objective-C
// Sample Code.Obtaining ARGFrame from didUpdateFrame
ARGScene *sceneView = [[ARGScene alloc] initSceneviewAt:self.view withViewTransform:displayTramsform];
- (void)didUpdateFrame:(ARGFrame *)frame {
if ([frame renderedPixelBuffer]) {
[sceneView displayPixelBuffer:[frame renderedPixelBuffer]];;
}
}
Swift
// Sample Code.Obtaining ARGFrame from didUpdateFrame
public func didUpdate(_ arFrame: ARGFrame) {
guard let renderedPixelbuffer = arFrame.renderedPixelBuffer else {
return
}
// draw sublayer(CALayer())'s contents
self.cameraPreviewCALayer.contents = renderedPixelbuffer
}