Interface: CameraProps
Hierarchy​
-
ViewProps
↳
CameraProps
Properties​
audio​
• Optional
audio: boolean
Enables audio capture for video recordings (see "Recording Videos")
Defined in​
CameraProps.ts:62
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:251
___
### 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:38
enableBufferCompression​
• Optional
enableBufferCompression: boolean
Enables or disables lossless 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 lossless-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 video={true} and frameProcessor={undefined}
- false // otherwise
Defined in​
CameraProps.ts:155
enableDepthData​
• Optional
enableDepthData: boolean
Also captures data from depth-perception sensors. (e.g. disparity maps)
Default
false
Defined in​
CameraProps.ts:175
enableFpsGraph​
• Optional
enableFpsGraph: boolean
If true
, show a debug view to display the FPS of the Camera session.
This is useful for debugging your Frame Processor's speed.
Default
false
Defined in​
CameraProps.ts:203
enableHighQualityPhotos​
• Optional
enableHighQualityPhotos: boolean
Indicates whether the Camera should prepare the photo pipeline to provide maximum quality photos.
This enables:
- High Resolution Capture (
isHighResolutionCaptureEnabled
) - Virtual Device fusion for greater detail (
isVirtualDeviceConstituentPhotoDeliveryEnabled
) - Dual Device fusion for greater detail (
isDualCameraDualPhotoDeliveryEnabled
) - Sets the maximum quality prioritization to
.quality
(maxPhotoQualityPrioritization
)
Default
false
Defined in​
CameraProps.ts:196
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:184
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:107
format​
• Optional
format: CameraDeviceFormat
Selects a given format. By default, the best matching format is chosen.
Defined in​
CameraProps.ts:114
fps​
• Optional
fps: number
Specify the frames per second this camera should use. Make sure the given format
includes a frame rate range with the given fps
.
Requires format
to be set that supports the given fps
.
Defined in​
CameraProps.ts:128
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:234
hdr​
• Optional
hdr: boolean
Enables or disables HDR on this camera device. Make sure the given format
supports HDR mode.
Requires format
to be set that supports photoHDR
/videoHDR
.
Defined in​
CameraProps.ts:134
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 usingisActive={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:46
lowLightBoost​
• Optional
lowLightBoost: boolean
Enables or disables low-light boost on this camera device. Make sure the given format
supports low-light boost.
Requires a format
to be set that supports lowLightBoost
.
Defined in​
CameraProps.ts:161
onError​
• Optional
onError: (error
: CameraRuntimeError
) => void
Type declaration​
â–¸ (error
): void
Called when any kind of runtime error occured.
Parameters​
Name | Type |
---|---|
error | CameraRuntimeError |
Returns​
void
Defined in​
CameraProps.ts:213
onInitialized​
• Optional
onInitialized: () => void
Type declaration​
â–¸ (): void
Called when the camera was successfully initialized.
Returns​
void
Defined in​
CameraProps.ts:217
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:207
photo​
• Optional
photo: boolean
Enables photo capture with the takePhoto
function (see "Taking Photos")
Defined in​
CameraProps.ts:52
pixelFormat​
• Optional
pixelFormat: "yuv"
| "rgb"
| "native"
Specifies the pixel format for the video pipeline.
Frames from a Frame Processor will be streamed in the pixel format specified here.
While native
and yuv
are the most efficient formats, some ML models (such as MLKit Barcode detection) require input Frames to be in RGB colorspace, otherwise they just output nonsense.
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
native
Defined in​
CameraProps.ts:76
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:122
torch​
• Optional
torch: "off"
| "on"
Set the current torch mode.
Note: The torch is only available on "back"
cameras, and isn't supported by every phone.
Default
"off"
Defined in​
CameraProps.ts:87
video​
• Optional
video: boolean
Enables video capture with the startRecording
function (see "Recording Videos")
Note: If both the photo
and video
properties are enabled at the same time and the device is running at a hardwareLevel
of 'legacy'
or 'limited'
, VisionCamera might use a lower resolution for video capture due to hardware constraints.
Defined in​
CameraProps.ts:58
videoStabilizationMode​
• Optional
videoStabilizationMode: VideoStabilizationMode
Specifies the video stabilization mode to use.
Requires a format
to be set that contains the given videoStabilizationMode
.
Defined in​
CameraProps.ts:167
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:99