The CameraPhotoOutput allows you to capture processed and RAW Photo objects. You can instantiate a photo output using three different patterns depending on your architecture:
- Using the
<Camera /> component: Pass the output to the outputs prop. - Using the
useCamera hook: Pass the output to the outputs array in the hook configuration. - Using
CameraSession (Imperative): Create the output via VisionCamera.createPhotoOutput and configure it within a session.
Refer to PhotoOutputOptions for configuration details.
// Pattern 1: <Camera /> component
function App() {
const device = useCameraDevice('back')
const photoOutput = usePhotoOutput({ /* options */ })
return (
<Camera
style={StyleSheet.absoluteFill}
isActive={true}
device={device}
outputs={[photoOutput]}
/>
)
}
// Pattern 2: useCamera hook
function App() {
const device = useCameraDevice('back')
const photoOutput = usePhotoOutput({ /* options */ })
const camera = useCamera({
isActive: true,
device: device,
outputs: [photoOutput],
})
}
// Pattern 3: CameraSession (imperative)
const session = await VisionCamera.createCameraSession(false)
const photoOutput = VisionCamera.createPhotoOutput({ /* options */ })
await session.configure([
{
input: 'back',
outputs: [
{ output: photoOutput, mirrorMode: 'auto' }
],
constraints: []
}
], {})
await session.start()