Nosmai  Effects Nosmai  Moderation Nosmai Try-ons coming soon
Docs menu iOS
How-to guide

Replace the background in iOS

Replace the live iOS camera background with a color, image, or looping video using Nosmai segmentation.

Platform iOS SDK version 3.0.4 Updated Aug 22, 2026 Time 7 min

Prerequisites

  • A working iOS quickstart
  • Advanced filters enabled for the project
  • A bundled image or local video URL

Replace with an image

NosmaiBackgroundSegmentationConfig *config =
    [[NosmaiBackgroundSegmentationConfig alloc] init];
config.mode = NosmaiBackgroundSegmentationModeImage;
config.replacementImage = [UIImage imageNamed:@"studio_background"];

[[NosmaiCore shared].effects setBackgroundSegmentation:config];

For a color, use NosmaiBackgroundSegmentationModeColor and set replacementColor. For a looping video, use NosmaiBackgroundSegmentationModeVideo and a readable local replacementVideoURL.

Change or clear it

Apply another configuration to switch the background. Clear manual segmentation when leaving the feature:

[[NosmaiCore shared].effects clearBackgroundSegmentation];

Quality guidance

Use a well-lit subject, a background that contrasts with hair and clothing, and an asset near the preview aspect ratio. Low light, motion blur, transparent objects, and heavy occlusion can soften the segmentation edge.

Verify it worked

The subject should remain visible while the source background is replaced. Rotate the device and test both cameras before release.

Common errors

SymptomCauseFix
Image does not appearAsset was not added to the application bundleCheck target membership and imageNamed: result
Video does not startURL is remote or unreadableCopy the supported video into a readable local URL
Edge quality is unstableLighting or motion is unsuitableImprove lighting, reduce motion blur, and test at 720p

Next steps

References

Was this page helpful?

Your response helps us prioritize documentation improvements.

Nosmai

An AR and AI company. Founded on the idea that the next decade of software will be visual, and that the tools for it should be within reach of anyone building.

Newsletter

Product updates and release notes. No spam.

© 2026 nosmai, inc · all rights reserved