Prerequisites
- A working React Native quickstart
- Advanced filters enabled
- A readable absolute local
file://URI
Apply an image
if (await NosmaiCameraSdk.isAdvancedFiltersEnabled()) {
await NosmaiCameraSdk.setBackground({
mode: 'image',
uri: localImageFileUri,
});
}
Use mode: 'color' with normalized RGBA values, or mode: 'video' with a local video URI.
Portable image formats are JPEG, PNG, and WebP. Portable video formats are MP4, M4V, and MOV. Do not pass a Metro asset number, remote URL, query, or fragment.
Clear it
await NosmaiCameraSdk.clearBackground();
This clears manual segmentation. It does not remove an authored background package.
Verify it worked
The native preview should update without remounting NosmaiCameraView. Test both native platforms in Release builds.
Common errors
| Error | Cause | Fix |
|---|---|---|
E_BACKGROUND_RESOURCE | URI is unreadable or format is unsupported | Copy to a local file and use a supported extension |
| No visible result | Preview is not ready or capability is disabled | Wait for onReady and check isAdvancedFiltersEnabled |
| Memory rises after repeated videos | Previous resources are retained by application state | Clear the background and release temporary files when finished |