neycyanshi / iPhone_depth

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


Platform Language License

Code examples of Depth APIs in iOS


Use devices which have a dual camera (e.g. iPhone 8 Plus) or a TrueDepth camera (e.g. iPhone X, iPhone XS, iPhone XR)

How to build

You need Certificate, Identifiers, Devices, and finally Provisioning Profile to build on iPhone. See Test app on iPhone for details. Open iOS-Depth-Sampler.xcworkspace with Xcode 10.1 and build it!

It can NOT run on Simulator. (Because it uses Metal.)

Contents and Features

Real-time Depth

Depth visualization in real time using AV Foundation.

Real-time Depth Mask

Blending a background image with a mask created from depth.

Depth from Camera Roll

Depth visualization from pictures in the camera roll.

Please try this after taking a picture with the Camera app using the PORTRAIT mode.

Portrait Matte

Background removal demo using Portrait Effect Matte (or Portrait Effect Matte).

Plaease try this after taking a picture of a HUMAN with PORTRAIT mode.

Available in iOS 12 or later.

ARKit Depth

Depth visualization on ARKit. The depth on ARKit is available only when using ARFaceTrackingConfiguration.

2D image in 3D space

A demo to render a 2D image in 3D space.

AR occlusion

[WIP] An occlusion sample on ARKit using depth.


Modified by Shi Yan, thanks to Shuichi Tsutsumi.

Student in Tsinghua University.


License:MIT License


Language:Swift 97.9%Language:Metal 1.1%Language:Ruby 0.9%Language:C 0.1%