Skip to main content

Interface: CameraProps

Hierarchy​

  • ViewProps

    ↳ CameraProps

Properties​

androidPreviewViewType​

• Optional androidPreviewViewType: "surface-view" | "texture-view"

Specifies the implementation mode for the Preview View on Android.

  • "surface-view": Uses a SurfaceView for rendering. This is more efficient and supports HDR rendering, but doesn't support masks, transparency, rotations or clipping.
  • "texture-view": Uses a TextureView for rendering. This is less efficient and doesn't support HDR rendering, but supports masks, transparency, rotations and clipping.

Default

'surface-view'

Defined in​

CameraProps.ts:174


audio​

• Optional audio: boolean

Enables audio capture for video recordings (see "Recording Videos")

Note: Requires audio permission.

Defined in​

CameraProps.ts:68


codeScanner​

• Optional codeScanner: CodeScanner

A CodeScanner that can detect QR-Codes or Barcodes using platform-native APIs.

See the Code Scanner documentation for more information

Example

const codeScanner = useCodeScanner({
codeTypes: ['qr', 'ean-13'],
onCodeScanned: (codes) => {
console.log(`Scanned ${codes.length} codes!`)
}
})

return <Camera {...props} codeScanner={codeScanner} />

#### Defined in

CameraProps.ts:344

___

### device

• **device**: [`CameraDevice`](CameraDevice.md)

The Camera Device to use.

See the [Camera Devices](https://react-native-vision-camera.com/docs/guides/devices) section in the documentation for more information about Camera Devices.

**`Example`**

```tsx
const device = useCameraDevice('back')

if (device == null) return <NoCameraErrorView />
return (
<Camera
device={device}
isActive={true}
style={StyleSheet.absoluteFill}
/>
)

Defined in​

CameraProps.ts:44


enableBufferCompression​

• Optional enableBufferCompression: boolean

Enables or disables lossy buffer compression for the video stream. If you only use video or a frameProcessor, this can increase the efficiency and lower memory usage of the Camera.

If buffer compression is enabled, the video pipeline will try to use a lossy-compressed pixel format instead of the normal one.

If you use a frameProcessor, you might need to change how pixels are read inside your native frame processor function as this is different from the usual yuv or rgb layout.

If buffer compression is not available but this property is enabled, the normal pixel formats will be used and no error will be thrown.

Platform

iOS

Default

- true // if frameProcessor={undefined}
- false // otherwise

Defined in​

CameraProps.ts:222


enableDepthData​

• Optional enableDepthData: boolean

Enables or disables depth data delivery for photo capture.

Make sure the given format supports depth data (see format.supportsDepthCapture).

Default

false

Defined in​

CameraProps.ts:266


enableFpsGraph​

• Optional enableFpsGraph: boolean

If true, show a debug view to display the FPS of the Video Pipeline (Frame Processor). This is useful for debugging your Frame Processor's speed.

Default

false

Defined in​

CameraProps.ts:282


enableGpuBuffers​

• Optional enableGpuBuffers: boolean

Enables or disables GPU-sampled buffers for the video stream. This only takes effect when using a frameProcessor.

When recording a Video (video) while a Frame Processor is running (frameProcessor), the Frames will need to be forwarded to the Media Encoder.

  • When enableGpuBuffers is false, the Video Pipeline will use CPU buffers causing an additional copy from the Frame Processor to the Media Encoder, which potentially results in increased latency.
  • When enableGpuBuffers is true, the Video Pipeline will use shared GPU buffers which greatly increases it's efficiency as an additional buffer copy is avoided. (See USAGE_GPU_SAMPLED_IMAGE)

In general, it is recommended to set this to true if possible, as this can increase performance and efficiency of the Video Pipeline.

This is an experimental feature flag, use at your own risk. Some devices (especially Samsungs) may crash when trying to use GPU buffers.

Platform

Android (API 29+)

Default

false

Defined in​

CameraProps.ts:241


enableLocation​

• Optional enableLocation: boolean

Enables location streaming to add GPS EXIF tags to captured photos and videos.

Note: Requires location permission.

Defined in​

CameraProps.ts:95


enablePortraitEffectsMatteDelivery​

• Optional enablePortraitEffectsMatteDelivery: boolean

A boolean specifying whether the photo render pipeline is prepared for portrait effects matte delivery.

When enabling this, you must also set enableDepthData to true.

Platform

iOS 12.0+

Default

false

Defined in​

CameraProps.ts:275


enableZoomGesture​

• Optional enableZoomGesture: boolean

Enables or disables the native pinch to zoom gesture.

If you want to implement a custom zoom gesture, see the Zooming with Reanimated documentation.

Default

false

Defined in​

CameraProps.ts:126


exposure​

• Optional exposure: number

Specifies the Exposure bias of the current camera. A lower value means darker images, a higher value means brighter images.

The Camera will still continue to auto-adjust exposure and focus, but will premultiply the exposure setting with the provided value here.

This values ranges from device.minExposure to device.maxExposure.

The value between min- and max supported exposure is considered the default, neutral value.

Defined in​

CameraProps.ts:139


format​

• Optional format: CameraDeviceFormat

Selects a given format. By default, the best matching format is chosen. See CameraDeviceFormat

The format defines the possible values for properties like:

  • fps: format.minFps...format.maxFps
  • videoHdr: format.supportsVideoHdr
  • photoHdr: format.supportsPhotoHdr
  • pixelFormat: `format.pixelFormats``
  • {@linkcode enableDepthData}: `format.supportsDepthCapture``
  • {@linkcode videoStabilizationMode}: `format.videoStabilizationModes``

In other words; enableDepthData can only be set to true if format.supportsDepthCapture is true.

Defined in​

CameraProps.ts:156


fps​

• Optional fps: number

Specify the frames per second this camera should stream frames at.

Make sure the given format can stream at the target fps value (see format.minFps and format.maxFps).

Defined in​

CameraProps.ts:180


frameProcessor​

• Optional frameProcessor: FrameProcessor

A worklet which will be called for every frame the Camera "sees".

See the Frame Processors documentation for more information

Example

const frameProcessor = useFrameProcessor((frame) => {
'worklet'
const faces = scanFaces(frame)
console.log(`Faces: ${faces}`)
}, [])

return <Camera {...cameraProps} frameProcessor={frameProcessor} />

Defined in​

CameraProps.ts:327


isActive​

• isActive: boolean

Whether the Camera should actively stream video frames, or not. See the documentation about the isActive prop for more information.

This can be compared to a Video component, where isActive specifies whether the video is paused or not.

Note: If you fully unmount the <Camera> component instead of using isActive={false}, the Camera will take a bit longer to start again. In return, it will use less resources since the Camera will be completely destroyed when unmounted.

Defined in​

CameraProps.ts:52


lowLightBoost​

• Optional lowLightBoost: boolean

Enables or disables low-light boost on this camera device.

Enabling low light boost allows the FPS rate to be throttled to up to half of what it is set to to allow for more exposure in low light conditions.

Make sure the given device supports low-light-boost (see device.supportsLowLightBoost).

Defined in​

CameraProps.ts:250


onError​

• Optional onError: (error: CameraRuntimeError) => void

Type declaration​

â–¸ (error): void

Called when any kind of runtime error occured.

Parameters​
NameType
errorCameraRuntimeError
Returns​

void

Defined in​

CameraProps.ts:292


onInitialized​

• Optional onInitialized: () => void

Type declaration​

â–¸ (): void

Called when the camera session was successfully initialized. This will get called everytime a new device is set.

Returns​

void

Defined in​

CameraProps.ts:296


onShutter​

• Optional onShutter: (event: OnShutterEvent) => void

Type declaration​

â–¸ (event): void

Called just before a photo or snapshot is captured.

Inside this callback you can play a custom shutter sound or show visual feedback to the user.

Parameters​
NameType
eventOnShutterEvent
Returns​

void

Defined in​

CameraProps.ts:310


onStarted​

• Optional onStarted: () => void

Type declaration​

â–¸ (): void

Called when the camera started the session (isActive={true})

Returns​

void

Defined in​

CameraProps.ts:300


onStopped​

• Optional onStopped: () => void

Type declaration​

â–¸ (): void

Called when the camera stopped the session (isActive={false})

Returns​

void

Defined in​

CameraProps.ts:304


orientation​

• Optional orientation: Orientation

Represents the orientation of all Camera Outputs (Photo, Video, and Frame Processor). If this value is not set, the device orientation is used.

Defined in​

CameraProps.ts:286


photo​

• Optional photo: boolean

Enables photo capture with the takePhoto function (see "Taking Photos")

Defined in​

CameraProps.ts:58


photoHdr​

• Optional photoHdr: boolean

Enables or disables HDR Photo Capture via a double capture routine that combines low- and high exposure photos.

Make sure the given format supports HDR (see format.supportsPhotoHdr).

Defined in​

CameraProps.ts:192


photoQualityBalance​

• Optional photoQualityBalance: "speed" | "balanced" | "quality"

Configures the photo pipeline for a specific quality balance prioritization.

  • 'speed': Prioritizes fast capture speed over quality (faster edge-detection, distortion correction, AF/AE/AWB times, etc.)
  • 'balanced': A balanced set of prioritization configurations
  • 'quality': Prioritizes high quality capture over speed (higher accuracy edge-detection, distortion correction, AF/AE/AWB times, etc.)

Default

'balanced'

Defined in​

CameraProps.ts:201


pixelFormat​

• Optional pixelFormat: "yuv" | "rgb" | "native"

Specifies the pixel format for the video pipeline.

Make sure the given format supports the given pixelFormat.

Affects:

  • frameProcessor: The format of Frames from a Frame Processor. While 'native' and 'yuv' are the most efficient formats, some ML models (such as TensorFlow Face Detection Models) require input Frames to be in RGB colorspace, otherwise they just output nonsense.
  • video: The format of Frames streamed in the Video Pipeline. The format 'native' is most efficient here.

The following values are supported:

  • native: The hardware native GPU buffer format. This is the most efficient format. (PRIVATE on Android, sometimes YUV on iOS)
  • yuv: The YUV (Y'CbCr 4:2:0 or NV21, 8-bit) format, either video- or full-range, depending on hardware capabilities. This is the second most efficient format.
  • rgb: The RGB (RGB, RGBA or ABGRA, 8-bit) format. This is least efficient and requires explicit conversion.

Default

  • Without a Frame Processor: native
  • With a Frame Processor: yuv

Defined in​

CameraProps.ts:89


resizeMode​

• Optional resizeMode: "cover" | "contain"

Specifies the Preview's resize mode.

  • "cover": Keep aspect ratio and fill entire parent view (centered).
  • "contain": Keep aspect ratio and make sure the entire content is visible inside the parent view, even if it introduces additional blank areas (centered).

Default

"cover"

Defined in​

CameraProps.ts:164


torch​

• Optional torch: "off" | "on"

Set the current torch mode.

Make sure the given device has a torch (see device.hasTorch).

Default

"off"

Defined in​

CameraProps.ts:106


video​

• Optional video: boolean

Enables video capture with the startRecording function (see "Recording Videos")

Defined in​

CameraProps.ts:62


videoHdr​

• Optional videoHdr: boolean

Enables or disables HDR Video Streaming for Preview, Video and Frame Processor via a 10-bit wide-color pixel format.

Make sure the given format supports HDR (see format.supportsVideoHdr).

Defined in​

CameraProps.ts:186


videoStabilizationMode​

• Optional videoStabilizationMode: VideoStabilizationMode

Specifies the video stabilization mode to use.

Make sure the given format supports the given videoStabilizationMode.

Defined in​

CameraProps.ts:256


zoom​

• Optional zoom: number

Specifies the zoom factor of the current camera, in "factor"/scale.

This value ranges from minZoom (e.g. 1) to maxZoom (e.g. 128). It is recommended to set this value to the CameraDevice's neutralZoom per default and let the user zoom out to the fish-eye (ultra-wide) camera on demand (if available)

Note: Linearly increasing this value always appears logarithmic to the user.

Default

1.0

Defined in​

CameraProps.ts:118