I am using a ARSCNView for displaying AR experiences that augment the camera view with 3D SceneKit content.
ARSession shared object that manages the device camera, but in ARSession i can't found any option for flash light.
Is there any way to turn on/off camera flash light?
How to manage camera with ARKit?
How to change camera position front and back?
func toggleTorch(on: Bool) {
guard let device = AVCaptureDevice.default(for: AVMediaType.video)
else {return}
if device.hasTorch {
do {
try device.lockForConfiguration()
if on == true {
device.torchMode = .on // set on
} else {
device.torchMode = .off // set off
}
device.unlockForConfiguration()
} catch {
print("Torch could not be used")
}
} else {
print("Torch is not available")
}
}
Call this as
toggleTorch(on: true) of toggleTorch(on: false)
ref: Hacking with Swift
The other answer covers the torch, so as to your camera position question...
There’s no way to select a camera for ARKit; that is, ARKit selects the camera for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With