### start() Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraSession Starts the CameraSession. It is recommended to call configure() before starting the session. ```APIDOC ## start() ### Description Starts the CameraSession. It is good practice to configure the session via configure() before calling this method to avoid runtime issues. ### Returns - **Promise** - A promise that resolves when the session has started. ``` -------------------------------- ### Install VisionCamera Core Source: https://visioncamera.margelo.com/api/react-native-vision-camera Install the core library using npm. ```sh npm install react-native-vision-camera ``` -------------------------------- ### Install react-native-vision-camera-resizer Source: https://visioncamera.margelo.com/api/react-native-vision-camera-resizer Use npm to install the library into your project. ```sh npm install react-native-vision-camera-resizer ``` -------------------------------- ### Start CameraSession Method Signature Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraSession Starts the camera session after configuration is complete. ```ts start(): Promise ``` -------------------------------- ### CameraSession.start Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraSession Starts the camera session after it has been configured. ```APIDOC ## start() ### Description Starts the camera session. It is recommended to call this only after the session has been successfully configured. ``` -------------------------------- ### Example usage of PhotoHDRConstraint Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/PhotoHDRConstraint A basic example showing how to enable photo HDR. ```ts { photoHDR: true } ``` -------------------------------- ### startRecording() Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/Recorder Starts a video recording session to a temporary file. ```APIDOC ## startRecording(onRecordingFinished, onRecordingError, onRecordingPaused?, onRecordingResumed?) ### Description Starts the video recording to a temporary file. Resolves once the recording has successfully started. ### Parameters - **onRecordingFinished** (function) - Callback invoked when recording finishes. - **onRecordingError** (function) - Callback invoked on recording errors. - **onRecordingPaused** (function) - Optional callback invoked when recording is paused. - **onRecordingResumed** (function) - Optional callback invoked when recording is resumed. ``` -------------------------------- ### Install react-native-vision-camera-worklets Source: https://visioncamera.margelo.com/api/react-native-vision-camera-worklets Install the package using npm. ```sh npm install react-native-vision-camera-worklets ``` -------------------------------- ### Focusing Examples Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraController Examples demonstrating how to focus the camera at a specific point or based on user interaction. ```ts const point = VisionCamera.createNormalizedMeteringPoint(0.5, 0.5) await controller.focusTo(point, { responsiveness: 'steady' }) ``` ```ts const onViewTapped = (tapX: number, tapY: number) => { const point = previewViewRef.createMeteringPoint(tapX, tapY) await controller.focusTo(point, { responsiveness: 'snappy' }) } ``` ```ts const point = previewViewRef.createMeteringPoint(tapX, tapY) await controller.focusTo(point, { responsiveness: 'snappy', adaptiveness: 'locked', autoResetAfter: null }) ``` -------------------------------- ### Install VisionCamera Location Source: https://visioncamera.margelo.com/api/react-native-vision-camera-location Install the package using npm. ```sh npm install react-native-vision-camera-location ``` -------------------------------- ### Install dependencies Source: https://visioncamera.margelo.com/api/react-native-vision-camera-worklets Ensure VisionCamera Core and react-native-worklets are installed. ```sh # Make sure VisionCamera Core is installed. npm install react-native-worklets ``` -------------------------------- ### startUpdating() Source: https://visioncamera.margelo.com/api/react-native-vision-camera-location/hybrid-objects/LocationManager Starts the location update stream. ```APIDOC ### Signature `startUpdating(): Promise` ### Description Begins receiving location updates. Throws an error if the location permission status is not 'authorized'. ``` -------------------------------- ### useCameraDevice usage example Source: https://visioncamera.margelo.com/api/react-native-vision-camera/functions/useCameraDevice An example of selecting a back camera with a specific physical device requirement. ```ts const device = useCameraDevice('back', { physicalDevices: ['wide-angle'] }) ``` -------------------------------- ### Install Required Dependencies Source: https://visioncamera.margelo.com/api/react-native-vision-camera Install the necessary Nitro modules and image dependencies. ```sh npm install react-native-nitro-modules react-native-nitro-image ``` -------------------------------- ### Basic useCamera usage Source: https://visioncamera.margelo.com/api/react-native-vision-camera/functions/useCamera Example of initializing the camera with basic configuration properties. ```ts const camera = useCamera({ isActive: true, device: 'back', outputs: [] }) ``` -------------------------------- ### Capturing a photo with usePhotoOutput Source: https://visioncamera.margelo.com/api/react-native-vision-camera/functions/usePhotoOutput Example showing how to initialize the output and capture a photo. ```ts const photoOutput = usePhotoOutput({ targetResolution: CommonResolutions.UHD_4_3, qualityPrioritization: 'quality', }) // ... const photo = await photoOutput.capturePhoto({ flashMode: 'on' }, {}) // ... photo.dispose() ``` -------------------------------- ### Install react-native-vision-camera-skia Source: https://visioncamera.margelo.com/api/react-native-vision-camera-skia Use npm to install the VisionCamera Skia package. ```sh npm install react-native-vision-camera-skia ``` -------------------------------- ### useObjectOutput usage example Source: https://visioncamera.margelo.com/api/react-native-vision-camera/functions/useObjectOutput An example of how to initialize useObjectOutput with specific types and an object scanning callback. ```ts const objectOutput = useObjectOutput({ types: ['qr'], onObjectsScanned(objects) { console.log(`Scanned ${objects.length} objects!`) } }) ``` -------------------------------- ### Install dependencies Source: https://visioncamera.margelo.com/api/react-native-vision-camera-skia Install the required peer dependencies, react-native-reanimated and react-native-worklets, following their respective installation guides. ```sh # Install react-native-reanimated + react-native-worklets via their guides ``` -------------------------------- ### Recording video with useVideoOutput Source: https://visioncamera.margelo.com/api/react-native-vision-camera/functions/useVideoOutput Example demonstrating how to initialize a video output, create a recorder, and manage recording lifecycle. ```ts const videoOutput = useVideoOutput({ targetResolution: CommonResolutions.FHD_16_9, enableAudio: true, }) // ... const recorder = await videoOutput.createRecorder({}) await recorder.startRecording( (filePath) => console.log(`Recorded to ${filePath}`), (error) => console.error(error), ) // later... await recorder.stopRecording() ``` -------------------------------- ### Start Zoom Animation Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/CameraRef Defines the signature for animating camera zoom and provides an example of zooming to the maximum level. ```ts startZoomAnimation(zoom: number, rate: number): Promise ``` ```ts const controller = ... const maxZoom = controller.device.maxZoom await controller.startZoomAnimation(maxZoom, 2) ``` -------------------------------- ### Usage Example for PreviewStabilizationModeConstraint Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/PreviewStabilizationModeConstraint An example object demonstrating how to set the preview stabilization mode to 'preview-optimized'. ```ts { previewStabilizationMode: 'preview-optimized' } ``` -------------------------------- ### useResizer implementation example Source: https://visioncamera.margelo.com/api/react-native-vision-camera-resizer/functions/useResizer Demonstrates how to configure the resizer and use it within a frame processor context. ```ts function App() { const { resizer } = useResizer({ width: 192, height: 192, channelOrder: 'rgb', dataType: 'float32', scaleMode: 'cover', pixelLayout: 'planar', }) const frameOutput = useFrameOutput({ pixelFormat: 'yuv', onFrame(frame) { 'worklet' if (resizer != null) { const resized = resizer.resize(frame) const buffer = resized.getPixelBuffer() resized.dispose() } frame.dispose() } }) } ``` -------------------------------- ### Initialize a Resizer instance Source: https://visioncamera.margelo.com/api/react-native-vision-camera-resizer/functions/createResizer Example usage of createResizer with specific configuration options. ```ts const resizer = await createResizer({ width: 192, height: 192, channelOrder: 'rgb', dataType: 'float32', scaleMode: 'cover', pixelLayout: 'planar' }) ``` -------------------------------- ### Simple Resize Example Source: https://visioncamera.margelo.com/api/react-native-vision-camera-resizer/hybrid-objects/Resizer A basic implementation of frame resizing within a worklet. ```ts const resizer = ... const frameOutput = useFrameOutput({ pixelFormat: 'yuv', onFrame(frame) { 'worklet' if (resizer != null) { const resized = resizer.resize(frame) const buffer = resized.getPixelBuffer() resized.dispose() } frame.dispose() } }) ``` -------------------------------- ### useDepthOutput implementation example Source: https://visioncamera.margelo.com/api/react-native-vision-camera/functions/useDepthOutput An example showing how to use the hook with an onDepth callback, ensuring the frame is disposed of after processing. ```ts const depthOutput = useDepthOutput({ onDepth(depth) { 'worklet' // some depth processing depth.dispose() } }) ``` -------------------------------- ### Usage Example for VideoStabilizationModeConstraint Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/VideoStabilizationModeConstraint An example object demonstrating how to set the video stabilization mode to cinematic. ```ts { videoStabilizationMode: 'cinematic' } ``` -------------------------------- ### Add CameraSession started listener Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraSession Register a callback for when the camera session begins running. ```ts addOnStartedListener(onStarted: () => void): ListenerSubscription ``` -------------------------------- ### Create CameraVideoOutput Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraVideoOutput Examples for initializing a video output using either the Hooks API or the Imperative API. ```ts const videoOutput = useVideoOutput() ``` ```ts const videoOutput = VisionCamera.createVideoOutput({ targetResolution: CommonResolutions.FHD_16_9, }) ``` -------------------------------- ### Define onStarted callback Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/CameraProps Triggered when the camera session has successfully started. ```ts optional onStarted?: () => void ``` -------------------------------- ### Create CameraPhotoOutput instances Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraPhotoOutput Examples of creating a photo output using either the Hooks API or the Imperative API. ```ts const photoOutput = usePhotoOutput() ``` ```ts const photoOutput = VisionCamera.createPhotoOutput({ targetResolution: CommonResolutions.UHD_4_3, containerFormat: 'native', quality: 0.9, qualityPrioritization: 'balanced', }) ``` -------------------------------- ### addOnStartedListener Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraSession Registers a callback function to be invoked when the camera session starts running. ```APIDOC ### addOnStartedListener(onStarted: () => void) **Returns**: `ListenerSubscription` Adds a listener to when the `CameraSession` started running. ``` -------------------------------- ### Using useCameraDeviceExtensions Source: https://visioncamera.margelo.com/api/react-native-vision-camera/functions/useCameraDeviceExtensions Example usage of the hook to retrieve extensions for a back-facing camera device. ```ts const device = useCameraDevice('back') const extensions = useCameraDeviceExtensions(device) // ...enable extension if available ``` -------------------------------- ### Install VisionCamera Barcode Scanner Source: https://visioncamera.margelo.com/api/react-native-vision-camera-barcode-scanner Install the required npm packages for the barcode scanner and Nitro Image support. ```sh npm install react-native-vision-camera-barcode-scanner react-native-nitro-image ``` -------------------------------- ### Configure allowDeferredStart Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/DepthFrameOutputOptions Boolean flag to allow the output to start after the initial capture pipeline startup. ```ts allowDeferredStart: boolean ``` -------------------------------- ### Update Native Dependencies Source: https://visioncamera.margelo.com/api/react-native-vision-camera-barcode-scanner Run the pod installation command to update native iOS dependencies after installation. ```sh npx pod-install ``` -------------------------------- ### Rendering frames with useFrameRenderer Source: https://visioncamera.margelo.com/api/react-native-vision-camera/functions/useFrameRenderer Example showing how to initialize a renderer and use it within a frame output callback and view component. ```tsx const frameRenderer = useFrameRenderer() const frameOutput = useFrameOutput({ onFrame(frame) { 'worklet' frameRenderer.renderFrame(frame) frame.dispose() } }) return ( ) ``` -------------------------------- ### useOrientation usage example Source: https://visioncamera.margelo.com/api/react-native-vision-camera/functions/useOrientation Demonstrates how to initialize the hook with the 'device' source to track physical phone orientation. ```ts const orientation = useOrientation('device') // orientation: 'up' | 'right' | 'down' | 'left' | undefined ``` -------------------------------- ### Verify VisionCamera Core Dependency Source: https://visioncamera.margelo.com/api/react-native-vision-camera-location Ensure that the VisionCamera Core dependency is installed. ```sh # Make sure VisionCamera Core is installed. ``` -------------------------------- ### Maximum Performance Resize Example Source: https://visioncamera.margelo.com/api/react-native-vision-camera-resizer/hybrid-objects/Resizer An optimized implementation using platform-specific pixel formats for better performance. ```ts const targetPixelFormat = Platform.select({ ios: 'yuv-420-8-bit-full', android: 'private' }) const resizer = ... const frameOutput = useFrameOutput({ pixelFormat: 'native', onFrame(frame) { 'worklet' if (resizer != null) { const resized = resizer.resize(frame) const buffer = resized.getPixelBuffer() resized.dispose() } frame.dispose() } }) const constraints: Constraint[] = [ { pixelFormat: targetPixelFormat } ] ``` -------------------------------- ### Starting Orientation Updates Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/OrientationManager Registers a callback function to receive orientation change events. ```ts startOrientationUpdates(onChanged: (orientation: CameraOrientation) => void): void ``` -------------------------------- ### Starting Location Updates Source: https://visioncamera.margelo.com/api/react-native-vision-camera-location/hybrid-objects/LocationManager Initiates location tracking. Throws an error if permissions are not authorized. ```ts startUpdating(): Promise ``` -------------------------------- ### Create Single CameraSession Imperatively Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraSession Configure and start a camera session using the imperative VisionCamera API. ```ts const session = await VisionCamera.createCameraSession(false) const [controller] = await session.configure([ { input: device, outputs: [ { output: previewOutput, mirrorMode: 'auto' }, { output: photoOutput, mirrorMode: 'auto' }, ], constraints: [] } ]) await session.start() ``` -------------------------------- ### VisionCamera Core Dependency Note Source: https://visioncamera.margelo.com/api/react-native-vision-camera-barcode-scanner Reminder to ensure the VisionCamera Core dependency is installed. ```sh # Make sure VisionCamera Core is installed as well. ``` -------------------------------- ### Preview Lifecycle Callbacks Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/PreviewViewProps Callbacks triggered when the preview starts or stops. ```ts optional onPreviewStarted?: () => void ``` ```ts optional onPreviewStopped?: () => void ``` -------------------------------- ### Example of multi-camera combination structure Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraDeviceFactory A JSON representation of a supported multi-camera device combination. ```json [ [{ position: 'back', ... }, { position: 'front', ... }] ] ``` -------------------------------- ### Implement onFrame worklet Source: https://visioncamera.margelo.com/api/react-native-vision-camera-skia/interfaces/SkiaCameraProps Example implementation of the onFrame callback using a worklet to render the frame texture to the canvas. ```ts onFrame(frame, render) { 'worklet' render(({ frameTexture, canvas }) => { canvas.drawImage(frameTexture, 0, 0) }) frame.dispose() } ``` -------------------------------- ### Creating a Resizer Instance Source: https://visioncamera.margelo.com/api/react-native-vision-camera-resizer/hybrid-objects/ResizerFactory Demonstrates how to use the factory to create a new Resizer with specific configuration options. ```ts const factory = ... const resizer = await factory.createResizer({ width: 192, height: 192, channelOrder: 'rgb', dataType: 'float32', pixelLayout: 'planar' }) ``` -------------------------------- ### NativeBuffer Usage Example Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/NativeBuffer Demonstrates retrieving a native buffer from a frame, processing it, and manually releasing it. ```ts const frame = ... const nativeBuffer = frame.getNativeBuffer() // your processing... nativeBuffer.release() frame.dispose() ``` -------------------------------- ### getCameraDevice Usage Example Source: https://visioncamera.margelo.com/api/react-native-vision-camera/functions/getCameraDevice Retrieves a back-facing camera device that supports a wide-angle lens. ```ts const device = getCameraDevice(devices, 'back', { physicalDevices: ['wide-angle'] }) ``` -------------------------------- ### useFrameOutput Usage Example Source: https://visioncamera.margelo.com/api/react-native-vision-camera/functions/useFrameOutput Basic implementation of useFrameOutput with a worklet callback that disposes of the frame. ```ts const frameOutput = useFrameOutput({ onFrame(frame) { 'worklet' // some frame processing frame.dispose() } }) ``` -------------------------------- ### Configure Simple Preview and Photo Connection Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraSession Sets up a basic camera session using the default back camera device. ```ts const session = ... const [controller] = await session.configure([ { input: 'back', outputs: [ { output: previewOutput, mirrorMode: 'auto' }, { output: photoOutput, mirrorMode: 'auto' }, ], constraints: [] } ]) ``` -------------------------------- ### Create Recorder Instance Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraVideoOutput Prepares a new recorder instance for capturing video. ```ts createRecorder(settings: RecorderSettings): Promise ``` -------------------------------- ### Define Resolution Bias Constraints Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/ResolutionBiasConstraint Examples showing how to order constraints to prioritize either photo or video output resolution. ```ts [ { resolutionBias: photoOutput }, { resolutionBias: videoOutput } ] ``` ```ts [ { resolutionBias: videoOutput }, { resolutionBias: photoOutput } ] ``` -------------------------------- ### startZoomAnimation(zoom: number, rate: number) Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraController Starts animating the Camera's zoom to a specified value at a given rate. ```APIDOC ## startZoomAnimation(zoom: number, rate: number) ### Description Starts animating the Camera's zoom to the specified zoom value at the specified rate. ### Signature `startZoomAnimation(zoom: number, rate: number): Promise` ### Parameters - **zoom** (number) - The target zoom level to animate to. - **rate** (number) - The rate at which the zoom animation should occur. ### Throws - Throws an error if the CameraDevice does not support the given zoom value (must be within minZoom and maxZoom). ### Example ```ts const controller = ... const maxZoom = controller.device.maxZoom await controller.startZoomAnimation(maxZoom, 2) ``` ``` -------------------------------- ### isActive Source: https://visioncamera.margelo.com/api/react-native-vision-camera-skia/interfaces/SkiaCameraProps Controls the state of the CameraSession. Setting to true starts the session, false stops it. ```APIDOC ### isActive - **Type**: `boolean` - **Required**: Yes Starts the CameraSession when set to true, and stops it when set back to false. ``` -------------------------------- ### Using isResizerAvailable for conditional logic Source: https://visioncamera.margelo.com/api/react-native-vision-camera-resizer/functions/isResizerAvailable Example demonstrating how to use isResizerAvailable to choose between a GPU-accelerated Resizer and a CPU fallback. ```ts function getResizer(options: ResizerOptions): Resizer | CPUFallbackResizer { if (isResizerAvailable()) { // GPU accelerated Resizer pipeline is available! return createResizer(options) } else { // GPU accelerated Resizer pipeline is not available on this device, // fall back to a CPU implementation. return ... } } ``` -------------------------------- ### Using useLocation in a Component Source: https://visioncamera.margelo.com/api/react-native-vision-camera-location/functions/useLocation Example demonstrating how to request location permissions and access the location object reactively. ```tsx const location = useLocation() useEffect(() => { if (!location.hasPermission) { location.requestPermission() } }, [location.hasPermission]) if (location.hasPermission) { console.log(location.location) } ``` -------------------------------- ### prepareSettings(settings) Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraPhotoOutput Pre-configures the camera output with specific settings to reduce latency for future capture calls. ```APIDOC ## prepareSettings(settings) ### Description Asynchronously prepares the CameraPhotoOutput with the given settings array to improve capture responsiveness for subsequent capturePhoto calls. On Android, this method is a no-op. ### Signature `prepareSettings(settings: CapturePhotoSettings[]): Promise` ### Parameters - **settings** (CapturePhotoSettings[]) - Required - An array of settings to prepare. ### Example ```ts const photoOutput = usePhotoOutput({}) useEffect(() => { photoOutput.prepareSettings([ { flashMode: 'off', enableDistortionCorrection: true }, { flashMode: 'on', enableDistortionCorrection: false }, ]) }, []) ``` ``` -------------------------------- ### AsyncRunner Usage Example Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/AsyncRunner Demonstrates using runAsync within a Frame Processor to handle heavy processing without blocking the main thread. ```ts const frameOutput = useFrameOutput({ onFrame(frame) { 'worklet' const wasHandled = asyncRunner.runAsync(() => { 'worklet' doSomeHeavyProcessing(frame) // Async task finished - dispose the Frame now. frame.dispose() }) if (!wasHandled) { // `AsyncRunner` is busy - drop this Frame! frame.dispose() } } }) ``` -------------------------------- ### Filtering Devices by Physical Type Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/DeviceFilter Examples of using getCameraDevice with different physical device configurations to balance startup speed and zoom capabilities. ```typescript // This device is simpler, so it starts up faster. getCameraDevice(devices, 'back', { physicalDevices: ['wide-angle'] }) // This device is more complex, so it starts up slower, but you can switch between devices on 0.5x, 1x and 2x zoom. getCameraDevice(devices, 'back', { physicalDevices: ['ultra-wide-angle', 'wide-angle', 'telephoto'] }) ``` -------------------------------- ### Usage example for FPSConstraint Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/FPSConstraint A simple object literal demonstrating how to set the FPS constraint to 60. ```ts { fps: 60 } ``` -------------------------------- ### Configure HDR Dynamic Range Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/VideoDynamicRangeConstraint Examples for setting the video dynamic range constraint using common presets or specific HDR configurations. ```typescript { videoDynamicRange: CommonDynamicRanges.ANY_HDR } ``` ```typescript { videoDynamicRange: { bitDepth: 'hdr-10-bit', colorSpace: 'hlg-bt2020', colorRange: 'full' } } ``` -------------------------------- ### Create Preview Output Method Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraFactory Creates a new CameraPreviewOutput instance. ```ts createPreviewOutput(): CameraPreviewOutput ``` -------------------------------- ### Requesting Camera Permission Source: https://visioncamera.margelo.com/api/react-native-vision-camera/functions/useCameraPermission Example of using the hook to check and request camera permissions within a component. ```ts const { hasPermission, requestPermission } = useCameraPermission() useEffect(() => { if (!hasPermission) { requestPermission() } }, [hasPermission, requestPermission]) ``` -------------------------------- ### Configure Connection with Custom Device Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraSession Initializes a camera session using a specific custom device instance. ```ts const session = ... const device = ... const [controller] = await session.configure([ { input: device, outputs: [ { output: previewOutput, mirrorMode: 'auto' }, { output: photoOutput, mirrorMode: 'auto' }, ], constraints: [] } ]) ``` -------------------------------- ### width Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/Frame Gets the total width of the Frame. ```APIDOC ## width ### Description Returns the total width of the Frame. Note that for planar frames, individual planes may have different dimensions. ### Signature `readonly width: number` ### Notes - If the Frame is invalid, returns 0. ``` -------------------------------- ### createRecorder(settings: RecorderSettings) Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraVideoOutput Creates and prepares a new Recorder instance with the given settings. The recorder will record to the configured file path or a temporary file if none is provided. ```APIDOC ### createRecorder(settings: RecorderSettings) #### Description Creates and prepares a new `Recorder` instance. The `Recorder` can only be used for a single recording session. #### Parameters - **settings** (`RecorderSettings`) - Required - The configuration settings for the recorder. #### Returns - `Promise` - A promise that resolves to the created `Recorder` instance. ``` -------------------------------- ### timestamp Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/Frame Gets the presentation timestamp of the Frame. ```APIDOC ## timestamp ### Description Returns the presentation timestamp at which this Frame was captured. ### Signature `readonly timestamp: number` ### Notes - If the Frame is invalid, returns 0. ``` -------------------------------- ### Requesting Microphone Permission Source: https://visioncamera.margelo.com/api/react-native-vision-camera/functions/useMicrophonePermission Example of using the hook to check and request microphone permissions within a component. ```ts const { hasPermission, requestPermission } = useMicrophonePermission() useEffect(() => { if (!hasPermission) { requestPermission() } }, [hasPermission, requestPermission]) ``` -------------------------------- ### cancelZoomAnimation() Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/CameraRef Cancels any zoom animations previously started with startZoomAnimation. ```APIDOC ### cancelZoomAnimation() Cancels any zoom animations previously started with `startZoomAnimation`. ``` -------------------------------- ### isActive Property Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/CameraProps Controls the lifecycle of the CameraSession by starting or stopping it. ```ts isActive: boolean ``` -------------------------------- ### configure(connections: CameraSessionConnection[], config?: CameraSessionConfiguration) Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraSession Configures the CameraSession with the specified connections and optional configuration. Returns a list of CameraController instances corresponding to each connection. ```APIDOC ## configure(connections: CameraSessionConnection[], config?: CameraSessionConfiguration) ### Description Configures the CameraSession with the given connections and returns one CameraController per CameraSessionConnection. This method defines the input device and its associated outputs. ### Parameters - **connections** (CameraSessionConnection[]) - Required - The list of connections from one input to multiple outputs. - **config** (CameraSessionConfiguration) - Optional - Session-wide configuration settings. ### Returns - **Promise** - A promise that resolves to an array of CameraController instances. ### Throws - Throws if Camera Permission has not been granted. - Throws if multiple connections are added but the session was not created as a multi-cam session. - Throws if hardware resources are exhausted. - Throws if multi-cam connection inputs are not supported together. ``` -------------------------------- ### Access pixelFormat Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/Depth Gets the pixel format of the depth frame. ```ts readonly pixelFormat: DepthPixelFormat ``` -------------------------------- ### Access depthDataQuality Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/Depth Gets the quality classification of the depth data. ```ts readonly depthDataQuality: DepthDataQuality ``` -------------------------------- ### Access depthDataAccuracy Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/Depth Gets the measurement accuracy of the depth data. ```ts readonly depthDataAccuracy: DepthDataAccuracy ``` -------------------------------- ### pixelFormat Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/Frame Gets the PixelFormat of the Frame's pixel data. ```APIDOC ## pixelFormat ### Description Returns the PixelFormat of the Frame. Common formats include 'yuv-420-8-bit-video', 'rgb-bgra-8-bit', or 'private' for GPU-only buffers. ### Signature `readonly pixelFormat: PixelFormat` ### Notes - If the Frame is 'private', pixel data may not be accessible on the CPU. - If the Frame is invalid, returns 'unknown'. ``` -------------------------------- ### Get camera device type Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraDevice Returns the hardware type of the camera. ```ts readonly type: DeviceType ``` -------------------------------- ### Create Device Factory Method Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraFactory Asynchronously creates a new CameraDeviceFactory. ```ts createDeviceFactory(): Promise ``` -------------------------------- ### Initialize CameraPreviewOutput Source: https://visioncamera.margelo.com/api/react-native-vision-camera/functions/usePreviewOutput Basic usage of the usePreviewOutput hook to obtain a preview output instance. ```ts const previewOutput = usePreviewOutput() ``` -------------------------------- ### Draw Frame to Canvas Source: https://visioncamera.margelo.com/api/react-native-vision-camera-skia/interfaces/SkiaOnFrameState Example of drawing the frame texture directly to the canvas. ```ts canvas.drawImage(frameTexture, 0, 0) ``` -------------------------------- ### Configure a Multi-Cam session Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraDeviceFactory Demonstrates how to check for multi-cam support and configure a session using supported device combinations. ```ts if (VisionCamera.supportsMultiCamSessions) { const deviceFactory = await VisionCamera.createDeviceFactory() const deviceCombinations = deviceFactory.supportedMultiCamDeviceCombinations[0] if (deviceCombinations != null) { const connections = deviceCombinations.map((device) => { const previewOutput = VisionCamera.createPreviewOutput() return { input: device, outputs: [ { output: previewOutput, mirrorMode: 'auto' } ], constraints: [] } satisfies CameraSessionConnection }) const session = await VisionCamera.createCameraSession(true) const controllers = await session.configure(connections) await session.start() } } ``` -------------------------------- ### Reset Focus Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/CameraRef Defines the signature for resetting focus and provides a usage example. ```ts resetFocus(): Promise ``` ```ts await controller.resetFocus() ``` -------------------------------- ### configure(config) Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraController Configures the CameraController with the provided configuration object. ```APIDOC ### configure(config) Configures the controller. Setting a value to undefined in the config object leaves the current value unchanged. #### Signature `configure(config: CameraControllerConfiguration): Promise` #### Parameters - **config** (CameraControllerConfiguration) - The configuration object to apply. ``` -------------------------------- ### Get Pixel Buffer Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/Frame Retrieves the raw pixel data as an ArrayBuffer if available. ```ts if (frame.hasPixelBuffer) { const pixelBuffer = frame.getPixelBuffer() console.log(`Frame has ${pixelBuffer.byteLength} bytes.`) } ``` -------------------------------- ### usePreviewOutput() Source: https://visioncamera.margelo.com/api/react-native-vision-camera/functions/usePreviewOutput Initializes a CameraPreviewOutput instance that can be connected to a CameraSession and displayed via a PreviewView. ```APIDOC ## function usePreviewOutput() ### Description Creates and returns a `CameraPreviewOutput` instance. This object is used to facilitate the rendering of the camera's live preview stream. ### Signature `function usePreviewOutput(): CameraPreviewOutput` ### Returns - **CameraPreviewOutput** - An instance that can be connected to a `CameraSession` for display in a `PreviewView`. ### Example ```ts const previewOutput = usePreviewOutput(); ``` ``` -------------------------------- ### Get CameraSession running status Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraSession Check if the camera session is currently active. ```ts readonly isRunning: boolean ``` -------------------------------- ### Manage outputOrientation Property Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraObjectOutput Gets or sets the output orientation for the camera output. ```ts outputOrientation: CameraOrientation ``` -------------------------------- ### Create Multi-Cam CameraSession Imperatively Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraSession Configure a multi-camera session to stream from both front and back devices simultaneously. ```ts if (VisionCamera.supportsMultiCamSessions) { const deviceFactory = await VisionCamera.createDeviceFactory() const deviceCombinations = deviceFactory.supportedMultiCamDeviceCombinations // ... get `frontDevice` and `backDevice` from one of // the combinations in `deviceCombinations`. const session = await VisionCamera.createCameraSession(true) const [frontController, backController] = await session.configure([ // Front Camera { input: frontDevice, outputs: [ { output: frontPreviewOutput, mirrorMode: 'on' }, { output: frontPhotoOutput, mirrorMode: 'off' }, ], constraints: [] }, // Back Camera { input: backDevice, outputs: [ { output: backPreviewOutput, mirrorMode: 'off' }, { output: backPhotoOutput, mirrorMode: 'off' }, ], constraints: [] } ]) await session.start() } ``` -------------------------------- ### Implementation Mode Property Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/PreviewViewProps Sets the PreviewImplementationMode for the PreviewView, defaulting to 'performance'. ```ts optional implementationMode?: PreviewImplementationMode ``` ```ts 'performance' ``` -------------------------------- ### Create CameraSession with Default Device Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraSession Initialize a session using the default back camera via the hooks API. ```ts const photoOutput = ... const camera = useCamera({ isActive: true, input: 'back', outputs: [photoOutput] }) ``` -------------------------------- ### Create Camera Session Method Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraFactory Creates a new CameraSession, optionally enabling multi-camera support. ```ts createCameraSession(enableMultiCam: boolean): Promise ``` -------------------------------- ### Zoom to maximum using startZoomAnimation Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraController Demonstrates how to trigger a zoom animation to the device's maximum zoom level. ```ts const controller = ... const maxZoom = controller.device.maxZoom await controller.startZoomAnimation(maxZoom, 2) ``` -------------------------------- ### Accessing Barcode Value Source: https://visioncamera.margelo.com/api/react-native-vision-camera-barcode-scanner/hybrid-objects/Barcode Example of accessing the raw value property of a detected barcode. ```ts const barcode = ... console.log(`Barcode value: ${barcode.rawValue}`) ``` -------------------------------- ### Use a PixelFormatConstraint object Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/PixelFormatConstraint An example of a constraint object specifying a target pixel format. ```ts { pixelFormat: 'yuv-420-8-bit-full' } ``` -------------------------------- ### useCamera(props: CameraProps) Source: https://visioncamera.margelo.com/api/react-native-vision-camera/functions/useCamera Initializes a camera session and returns a CameraController or undefined. ```APIDOC ## useCamera(props: CameraProps) ### Description Creates a CameraSession, manages inputs and outputs, and returns a CameraController for managing the camera state. ### Signature `function useCamera(props: CameraProps): CameraController | undefined` ### Parameters - **props** (CameraProps) - Required - Configuration object for the camera, including isActive, device, and outputs. ### Example ```ts const camera = useCamera({ isActive: true, device: 'back', outputs: [] }) ``` ``` -------------------------------- ### Embedding Location in Photo EXIF Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/Location Example of passing a location object to the capturePhoto method. ```ts const photoOutput = ... const location = ... await photoOutput.capturePhoto({ location: location }, {}) ``` -------------------------------- ### Create a Worklet Runtime Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/NativeThreadFactory Demonstrates creating a NativeThread and wrapping it in a Worklet Runtime. ```ts const thread = NativeThreadFactory.createNativeThread('async-processor') const runtime = createWorkletRuntimeForThread(thread) ``` -------------------------------- ### Create CameraPreviewOutput Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraPreviewOutput Methods to instantiate a CameraPreviewOutput using either Hooks or the Imperative API. ```ts const previewOutput = usePreviewOutput() ``` ```ts const previewOutput = VisionCamera.createPreviewOutput() ``` -------------------------------- ### Configure Preview-Sized Output Buffers Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/UseFrameOutputProps Optional boolean property to enable smaller, preview-sized buffers for optimized ML and computer vision workloads. ```ts optional enablePreviewSizedOutputBuffers?: boolean ``` ```ts false ``` -------------------------------- ### Get Native Buffer Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/Depth Provides a NativeBuffer for cross-library interoperability; must be released by the consumer. ```ts getNativeBuffer(): NativeBuffer ``` -------------------------------- ### useResizer(options: ResizerOptions): ResizerState Source: https://visioncamera.margelo.com/api/react-native-vision-camera-resizer/functions/useResizer Initializes a Resizer instance with the provided configuration options. Returns a state object containing the resizer instance and potential error information. ```APIDOC ## useResizer(options: ResizerOptions) ### Description Initializes a Resizer instance for resizing and converting frames. This hook is intended for use in ML processing pipelines. ### Parameters - **options** (ResizerOptions) - Required - Configuration object including width, height, channelOrder, dataType, scaleMode, and pixelLayout. ### Returns - **ResizerState** - An object containing the `resizer` instance and an `error` property if initialization fails. ### Example ```ts const { resizer } = useResizer({ width: 192, height: 192, channelOrder: 'rgb', dataType: 'float32', scaleMode: 'cover', pixelLayout: 'planar', }) ``` ``` -------------------------------- ### getFileData() Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/Photo Gets the raw file data of the Photo after processing and including EXIF flags. ```APIDOC ## getFileData() ### Description Gets the raw file data of the Photo after processing and including EXIF flags. ### Signature `getFileData(): ArrayBuffer` ``` -------------------------------- ### Get the default camera device Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraDeviceFactory Retrieves the default camera device for a specified position. ```ts getDefaultCamera(position: TargetCameraPosition): CameraDevice | undefined ``` -------------------------------- ### Create Video Output Method Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraFactory Creates a new CameraVideoOutput with specified options. ```ts createVideoOutput(options: VideoOutputOptions): CameraVideoOutput ``` -------------------------------- ### Get all camera devices Source: https://visioncamera.margelo.com/api/react-native-vision-camera/functions/getAllCameraDevices Retrieves a synchronous list of all currently discovered camera devices. ```ts function getAllCameraDevices(): CameraDevice[] ``` -------------------------------- ### Get supported camera extensions Source: https://visioncamera.margelo.com/api/react-native-vision-camera/functions/getSupportedExtensions Retrieves a list of supported CameraExtensions for a specified CameraDevice. ```ts function getSupportedExtensions(device: CameraDevice): Promise ``` -------------------------------- ### startZoomAnimation method signature Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraController Defines the method signature for initiating a zoom animation on the camera. ```ts startZoomAnimation(zoom: number, rate: number): Promise ``` -------------------------------- ### Create CameraSession with Custom Device Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraSession Initialize a session using a specific camera device via the hooks API. ```ts const device = ... const photoOutput = ... const camera = useCamera({ isActive: true, input: device, outputs: [photoOutput] }) ``` -------------------------------- ### Create Photo Output Method Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraFactory Creates a new CameraPhotoOutput with specified options. ```ts createPhotoOutput(options: PhotoOutputOptions): CameraPhotoOutput ``` -------------------------------- ### Create Output Synchronizer Method Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraFactory Creates a CameraOutputSynchronizer to synchronize multiple camera outputs. ```ts createOutputSynchronizer(outputs: CameraOutput[]): CameraOutputSynchronizer ``` -------------------------------- ### NativePreviewView Usage Example Source: https://visioncamera.margelo.com/api/react-native-vision-camera/views/NativePreviewView Basic implementation of the NativePreviewView component within a React functional component. ```tsx function App() { const previewView = useRef(null) const previewOutput = usePreviewOutput() return ( { previewView.current = r })} /> ) } ``` -------------------------------- ### Prefer binned format Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/BinnedConstraint Use this configuration to prioritize low-light sensitivity and performance. ```ts { binned: true } ``` -------------------------------- ### Focus Camera Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/CameraRef Defines the signature for focusing the camera and provides an example of focusing on the center of the view. ```ts focusTo(viewPoint: Point, options?: FocusOptions): Promise ``` ```tsx // Focus center await camera.current.focusTo({ x: width / 2, y: height / 2 }) ``` -------------------------------- ### Create Object Output Method Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraFactory Creates a new CameraObjectOutput with specified options. ```ts createObjectOutput(options: ObjectOutputOptions): CameraObjectOutput ``` -------------------------------- ### getPixelBuffer() Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/Photo Get the Photo's native pixel buffer for readonly access to individual pixels. ```APIDOC ## getPixelBuffer() ### Description Get the Photo's native pixel buffer. This allows readonly access to the individual pixels. This does not contain any EXIF data. ### Signature `getPixelBuffer(): ArrayBuffer` ### Throws Throws if hasPixelBuffer is false. ``` -------------------------------- ### getFileDataAsync() Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/Photo Asynchronously gets the raw file data of the Photo after processing and including EXIF flags. ```APIDOC ## getFileDataAsync() ### Description Asynchronously gets the raw file data of the Photo after processing and including EXIF flags. ### Signature `getFileDataAsync(): Promise` ``` -------------------------------- ### Get File Data Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/Photo Retrieves the raw file data of the Photo including EXIF flags. ```ts getFileData(): ArrayBuffer ``` -------------------------------- ### isAvailable Source: https://visioncamera.margelo.com/api/react-native-vision-camera-resizer/hybrid-objects/ResizerFactory Checks if the GPU-accelerated resizer pipeline is supported on the current device. ```APIDOC ## isAvailable() ### Description Returns a boolean indicating whether the GPU-accelerated resizer pipeline is supported. On iOS, this is always available via Metal. On Android, it requires Vulkan and AHardwareBuffer extensions. ### Returns - **boolean** - True if the pipeline is supported, false otherwise. ``` -------------------------------- ### controller Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/GestureController The controller property allows you to get or set the CameraController instance that the gesture controller should manipulate. ```APIDOC ### Property: controller #### Description Gets or sets the `CameraController` instance that this `GestureController` should control. This property links the gesture logic to the camera state. #### Type `CameraController | undefined` ``` -------------------------------- ### Access Native Buffers Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/Frame Demonstrates retrieving, using, and releasing native buffers for GPU interoperability. ```ts if (frame.hasNativeBuffer) { const nativeBuffer = frame.getNativeBuffer() console.log(`Native Buffer pointer: ${nativeBuffer.pointer}`) nativeBuffer.release() } ``` ```ts if (frame.hasNativeBuffer) { const nativeBuffer = frame.getNativeBuffer() const image = Skia.Image.MakeImageFromNativeBuffer(nativeBuffer.pointer) // Render `image` via Skia APIs image.dispose() nativeBuffer.release() } ``` ```ts const device = ... // WebGPU device if (frame.hasNativeBuffer) { const nativeBuffer = frame.getNativeBuffer() const videoFrame = RNWebGPU.createVideoFrameFromNativeBuffer(nativeBuffer.pointer) const externalTexture = device.importExternalTexture({ source: videoFrame, label: 'camera-frame' }) // After submitting commands that sample `externalTexture`: externalTexture.destroy() videoFrame.release() nativeBuffer.release() } ``` -------------------------------- ### Set Output Settings Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraVideoOutput Configures video output settings after attachment to a session and before creating a recorder. ```ts setOutputSettings(settings: VideoOutputSettings): Promise ``` -------------------------------- ### Create Frame Output Method Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraFactory Creates a new CameraFrameOutput with specified options. ```ts createFrameOutput(options: FrameOutputOptions): CameraFrameOutput ``` -------------------------------- ### Get Depth Data Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/Depth Retrieves the depth data as an ArrayBuffer, potentially triggering a GPU to CPU download. ```ts getDepthData(): ArrayBuffer ``` -------------------------------- ### usePreviewOutput Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraPreviewOutput Creates a CameraPreviewOutput instance using the Hooks API. ```APIDOC ## usePreviewOutput() ### Description Creates a new CameraPreviewOutput instance using the React Hooks API. ### Example ```ts const previewOutput = usePreviewOutput(); ``` ``` -------------------------------- ### GestureController Controller Property Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/GestureController The property used to get or set the CameraController instance associated with the gesture controller. ```ts controller: CameraController | undefined ``` -------------------------------- ### CameraSession.configure Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraSession Configures the camera session with specific inputs, outputs, and constraints. This method returns an array of controllers for the configured connections. ```APIDOC ## configure(configurations: Array) ### Description Configures the camera session with one or more input/output combinations. This should be called before starting the session to ensure proper setup. ### Parameters - **configurations** (Array) - Required - An array of configuration objects defining the input device, outputs, and constraints for the session. ``` -------------------------------- ### Configure Camera Controller Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraController Applies a configuration object to the controller, where undefined values in the config object preserve existing settings. ```ts configure(config: CameraControllerConfiguration): Promise ``` -------------------------------- ### Attach barcode scanner to Camera or CameraSession Source: https://visioncamera.margelo.com/api/react-native-vision-camera-barcode-scanner/functions/useBarcodeScannerOutput Examples of attaching the scanner output to either a Camera component or a CameraSession. ```tsx const device = ... const scannerOutput = useBarcodeScannerOutput({ barcodeFormats: ['all-formats'], onBarcodeScanned(barcodes) { console.log(`Scanned ${barcodes.length} barcodes!`) }, onError(error) { console.error(`Failed to scan barcodes!`, error) } }) return ( ) ``` ```ts const device = ... const scannerOutput = useBarcodeScannerOutput({ barcodeFormats: ['all-formats'], onBarcodeScanned(barcodes) { console.log(`Scanned ${barcodes.length} barcodes!`) }, onError(error) { console.error(`Failed to scan barcodes!`, error) } }) const camera = useCamera({ isActive: true, device: device, outputs: [scannerOutput] }) ``` -------------------------------- ### Create Metering Point from Preview View Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/MeteringPoint Generate a metering point based on user interaction coordinates within a PreviewView. ```tsx function App() { const previewView = useRef(null) const controller = ... const onTap = async (viewX, viewY) => { const meteringPoint = previewView.current?.createMeteringPoint(viewX, viewY) await controller.focusTo(meteringPoint, {}) } return ( ) } ``` -------------------------------- ### Get zoom lens switch factors Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraDevice Returns zoom factors where a virtual device switches physical lenses. ```ts readonly zoomLensSwitchFactors: number[] ``` ```ts const camera = ... // Triple-Camera (0.5x, 1x, 3x) camera.zoomLensSwitchFactors // [1, 3] ``` -------------------------------- ### Get File Data Asynchronously Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/Photo Asynchronously retrieves the raw file data of the Photo including EXIF flags. ```ts getFileDataAsync(): Promise ``` -------------------------------- ### useLocationManager(options?) Source: https://visioncamera.margelo.com/api/react-native-vision-camera-location/functions/useLocationManager Initializes and returns a stable LocationManager instance based on the provided options. ```APIDOC ## useLocationManager ### Description Returns a stable `LocationManager` instance. This hook accepts an optional configuration object to initialize the manager. ### Signature `function useLocationManager(__namedParameters?: Partial): LocationManager` ### Parameters - **__namedParameters** (Partial) - Optional - Configuration options for the LocationManager instance. ### Returns - **LocationManager** - A stable instance of the LocationManager hybrid object. ``` -------------------------------- ### Get Supported Video Codecs Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraVideoOutput Retrieves available video codecs; must be called after attachment to a Camera Session. ```ts getSupportedVideoCodecs(): VideoCodec[] ``` -------------------------------- ### Prepare capture settings Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraPhotoOutput Pre-configures the camera output with specific settings to reduce latency for future capture calls. This method is a no-op on Android. ```ts prepareSettings(settings: CapturePhotoSettings[]): Promise ``` ```ts const photoOutput = usePhotoOutput({}) useEffect(() => { photoOutput.prepareSettings([ { flashMode: 'off', enableDistortionCorrection: true }, { flashMode: 'on', enableDistortionCorrection: false }, ]) }, []) ``` -------------------------------- ### Get a camera device by ID Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraDeviceFactory Retrieves a specific CameraDevice using its unique identifier, returning undefined if not found. ```ts getCameraForId(id: string): CameraDevice | undefined ``` -------------------------------- ### allowHapticsAndSystemSoundsPlayback Property Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/CameraSessionConfiguration Configuration for haptics and system sound playback during a camera session. ```typescript optional allowHapticsAndSystemSoundsPlayback?: boolean ``` ```typescript false ``` -------------------------------- ### Take Snapshot Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/CameraRef Defines the signature for capturing a snapshot of the current PreviewView contents. ```ts takeSnapshot(): Promise ``` -------------------------------- ### Barcode scanning in a frame processor Source: https://visioncamera.margelo.com/api/react-native-vision-camera-barcode-scanner/functions/useBarcodeScanner Example of using the barcode scanner within a frame processor to detect and log barcodes. ```ts const barcodeScanner = useBarcodeScanner({ barcodeFormats: ['all-formats'] }) const frameOutput = useFrameOutput({ onFrame(frame) { 'worklet' const barcodes = barcodeScanner.scanCodes(frame) console.log(`Detected ${barcodes.length} barcodes!`) frame.dispose() } }) ``` -------------------------------- ### onConfigured Callback Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/CameraProps Triggered after the CameraSession is configured and output connections are established. ```ts optional onConfigured?: () => void ``` -------------------------------- ### Preview Image Target Size Configuration Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/PhotoOutputOptions Sets the optional size for a preview image delivered before the final photo. Defaults to undefined. ```ts optional previewImageTargetSize?: Size ``` ```ts undefined ``` -------------------------------- ### Get Current Thread Marker Source: https://visioncamera.margelo.com/api/react-native-vision-camera-worklets/hybrid-objects/WorkletQueueFactory Retrieves a C++ thread's incrementing marker, useful for thread-confined rendering libraries. ```ts getCurrentThreadMarker(): number ``` -------------------------------- ### Create CameraObjectOutput via Imperative API Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraObjectOutput Instantiate a CameraObjectOutput using the VisionCamera imperative API. ```ts const objectOutput = VisionCamera.createObjectOutput({ enabledObjectTypes: ['qr-code'], }) ``` -------------------------------- ### userPreferredCamera Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraDeviceFactory Gets or sets the user's default preferred camera device, with preferences persisting across application sessions. ```APIDOC ## optional userPreferredCamera: CameraDevice ### Description Allows retrieving or setting the preferred camera device. Setting this value persists the user's choice between app launches. ``` -------------------------------- ### Configure Session with Constraints Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraSession Applies specific hardware constraints, such as frame rate, to the camera session. ```ts const session = ... const device = ... const [controller] = await session.configure([ { input: device, outputs: [ { output: previewOutput, mirrorMode: 'auto' }, { output: photoOutput, mirrorMode: 'auto' }, ], constraints: [ { fps: 60 } ] } ]) await session.start() ``` -------------------------------- ### Get default camera device signature Source: https://visioncamera.margelo.com/api/react-native-vision-camera/functions/getDefaultCameraDevice The function signature for retrieving the default camera device based on the target position. ```ts function getDefaultCameraDevice(position: TargetCameraPosition): Promise ``` -------------------------------- ### Access controller property Source: https://visioncamera.margelo.com/api/react-native-vision-camera-skia/interfaces/SkiaCameraRef Retrieves the CameraController, available after onStarted has been called. ```ts controller: | CameraController | undefined ``` -------------------------------- ### Access userPreferredCamera property Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraDeviceFactory Gets or sets the user's default preferred camera device, which persists across app sessions. ```ts optional userPreferredCamera?: CameraDevice ``` -------------------------------- ### Add CameraSession interruption started listener Source: https://visioncamera.margelo.com/api/react-native-vision-camera/hybrid-objects/CameraSession Register a callback for when the camera session is interrupted by external factors like overheating or incoming calls. ```ts addOnInterruptionStartedListener(onInterruptionStarted: (reason: InterruptionReason) => void): ListenerSubscription ``` -------------------------------- ### startZoomAnimation Source: https://visioncamera.margelo.com/api/react-native-vision-camera/interfaces/CameraRef Animates the Camera's zoom level. ```APIDOC ## startZoomAnimation(zoom: number, rate: number) ### Description Starts animating the Camera's zoom to the specified zoom value at the specified rate. ### Parameters - **zoom** (number) - Required - The target zoom level. - **rate** (number) - Required - The rate of the animation. ### Throws - Throws if the CameraDevice does not support the given zoom value. ### Example ```ts await controller.startZoomAnimation(maxZoom, 2) ``` ```