useDepthOutput

function useDepthOutput(__namedParameters: UseDepthOutputProps): CameraDepthFrameOutput

Use a CameraDepthFrameOutput for streaming Depth Frames.

The onDepth(...) callback will be called for every Depth Frame the Camera produces. It is a synchronous JS function running on the CameraDepthFrameOutput's thread - aka a "worklet".

Note

useDepthOutput(...) requires react-native-vision-camera-worklets (and react-native-worklets) to be installed.

Discussion

You must dispose the Depth Frame after your callback has finished processing, otherwise subsequent Frames may be dropped (see onDepthFrameDropped(...)).

Example

const depthOutput = useDepthOutput({
  onDepth(depth) {
    'worklet'
    // some depth processing
    depth.dispose()
  }
})

On this page

No Headings