If you're looking for a programmatic way of capturing spatial videos, check out https://developer.apple.com/videos/play/wwdc2024/10166/?time=6m39s
Post
Replies
Boosts
Views
Activity
VNGenerateForegroundInstanceMaskRequest is what you want. https://developer.apple.com/videos/play/wwdc2023/10176/ explains how to do it.
If the foreground object is a person, you can use this sample code. https://developer.apple.com/documentation/vision/original_objective-c_and_swift_api/applying_matte_effects_to_people_in_images_and_video
This sample code may help.