Real-time background blur for Fishjam WebRTC applications, powered by ExecuTorch segmentation models.
This package provides GPU-accelerated background blur effects using on-device ExecuTorch models for foreground / background segmentation.
- iOS 13.0+
- Android SDK 26+
- Peer dependencies:
@fishjam-cloud/react-native-client@fishjam-cloud/react-native-webrtcreact-native-executorch
yarn add react-native-executorch-webrtcFor iOS:
cd ios && pod installimport { useBackgroundBlur } from 'react-native-executorch-webrtc';
import { useCamera } from '@fishjam-cloud/react-native-client';
function VideoCall() {
const [blurEnabled, setBlurEnabled] = useState(true);
const { blurMiddleware } = useBackgroundBlur({
// NOTE: you can use React Native Executorch's Resource Fetcher to download model files
modelUri: 'file:///path/to/selfie_segmenter.pte',
blurRadius: 15,
});
const { toggleCamera } = useCamera({
cameraTrackMiddleware: blurEnabled ? blurMiddleware : undefined,
});
return (
<Button
title={blurEnabled ? 'Disable Blur' : 'Enable Blur'}
onPress={() => setBlurEnabled(!blurEnabled)}
/>
);
}React hook that provides camera track middleware for background blur.
Options:
modelUri:string- Path to the ExecuTorch segmentation model (.pte file)blurRadius:number(optional, default: 12) - Blur intensity
Returns:
blurMiddleware:TrackMiddleware- Middleware function for use with Fishjam'suseCamera
The blurRadius can be updated dynamically without reinitializing:
const { blurMiddleware } = useBackgroundBlur({
modelUri: modelPath,
blurRadius: intensity,
});Uses Core Image for GPU-accelerated blur compositing.
Uses OpenGL ES shaders for blur and compositing. OpenMP is used for parallel CPU operations.
MIT