Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scenekit snapshot() doesn't include camera exposure settings

I'm providing screenshot functionality for my AR app, and I noticed that the screenshots I take (via sceneView.snapshot()) are much darker than what I see from the camera. I'm using the ARKit example code from Apple, and it seems like this is affecting it:

camera.wantsHDR = true
camera.wantsExposureAdaptation = true
camera.exposureOffset = -1
camera.minimumExposure = -1
camera.maximumExposure = 3

When I remove the exposure settings, the snapshot works fine. Any way to make sure the snapshot considers those exposure settings?

like image 992
pushmatrix Avatar asked Sep 29 '17 13:09

pushmatrix


1 Answers

UPDATED: November 25, 2019.

#First Reason

The main reason that snapshots taken in AR apps are darker than a video stream coming from a rear RGB camera is because you have two absolutely different scenes: the first one is SCNScene with 3D models having its own exposure and the second one is a RGB camera's view with its own exposure. In ARSCNView these exposures are added together forming an average exposure value, what can be darker (like in your case) or can be lighter.

#Second Reason

Also, you need to take into account a whitePoint instance property also known as a luminance level for use as the upper end of a tone mapping curve.

var whitePoint: CGFloat { get set }

When using a High Dynamic Range (HDR) camera, SceneKit applies a process called tone mapping to translate the wide range of luminance values in the visible scene to the narrower range of brightness values that can be shown on a display. SceneKit determines a tone mapping curve from the minimumExposure, maximumExposure, exposureOffset, and whitePoint properties, along with a measure of scene luminance.

The default value of whitePoint is 1.0. By setting this property to a higher or lower value, you can produce more gradual or more abrupt transitions between shadows and highlights. This property has no effect if the wantsHDR value is false.

camera.whitePoint = 1.5

#Third Reason

Color models of RGB camera stream, rendered SCNView and an iPhone's display are slightly different in Gamma Correction.

like image 77
Andy Jazz Avatar answered Sep 24 '22 02:09

Andy Jazz