The Photo Output
Capturing Photos using the Photo Output
The CameraPhotoOutput allows capturing processed- and RAW-Photos.
Creating a Photo Output
function App() {
const device = useCameraDevice('back')
const photoOutput = usePhotoOutput({ /* options */ })
return (
<Camera
style={StyleSheet.absoluteFill}
isActive={true}
device={device}
outputs={[photoOutput]}
/>
)
}function App() {
const device = useCameraDevice('back')
const photoOutput = usePhotoOutput({ /* options */ })
const camera = useCamera({
isActive: true,
device: device,
outputs: [photoOutput],
})
}const session = await VisionCamera.createCameraSession(false)
const device = await getDefaultCameraDevice('back')
const photoOutput = VisionCamera.createPhotoOutput({ /* options */ })
await session.configure([
{
input: device,
outputs: [
{ output: photoOutput, mirrorMode: 'auto' }
],
constraints: []
}
], {})
await session.start()See PhotoOutputOptions for a full list of configuration options for the Photo Output.
Capturing Photos
Capturing Photos in-memory
To capture a Photo in-memory, use capturePhoto(...):
const photo = await photoOutput.capturePhoto(
{ /* options */ },
{ /* callbacks */ }
)
// ...
photo.dispose()Warning
Make sure to dispose the Photo when you no longer use it, as otherwise the JS Runtime might not immediately delete it, possibly exhausting system resources or stalling the Camera:
See "A Photo" to understand how the Photo type works, and how to use it.
Capturing Photos to a file
To capture a photo and directly save it to a temporary file, use capturePhotoToFile(...):
const { filePath } = await photoOutput.capturePhotoToFile(
{ /* options */ },
{ /* callbacks */ }
)See CapturePhotoSettings for a full list of configuration options, and CapturePhotoCallbacks for a full list of callbacks for the capture method.