Skip to main content

Function: useSkiaFrameProcessor()

useSkiaFrameProcessor(frameProcessor, dependencies): DrawableFrameProcessor

Returns a memoized Skia Frame Processor function wich you can pass to the <Camera>.

The Skia Frame Processor alows you to draw ontop of the Frame, and will manage it's internal offscreen Skia Canvas and onscreen Skia preview view.

(See "Frame Processors")

Make sure to add the 'worklet' directive to the top of the Frame Processor function, otherwise it will not get compiled into a worklet.

Parameters​

• frameProcessor

The Frame Processor

• dependencies: DependencyList

The React dependencies which will be copied into the VisionCamera JS-Runtime.

Returns​

DrawableFrameProcessor

The memoized Skia Frame Processor.

Worklet​

Example​

const frameProcessor = useSkiaFrameProcessor((frame) => {
'worklet'
const faces = scanFaces(frame)

frame.render()
for (const face of faces) {
const rect = Skia.XYWHRect(face.x, face.y, face.width, face.height)
frame.drawRect(rect)
}
}, [])

Defined in​

skia/useSkiaFrameProcessor.ts:330