iOS AR学习第二天:RealityKit 2 物体捕捉

1,248 阅读4分钟

developer.apple.com/cn/augmente…

利用 macOS Monterey 上全新的物体捕捉 API,将 iPhone 或 iPad 中的照片转换为针对增强现实进行优化的高质量 3D 模型。物体捕捉功能使用摄影测量技术将 iPhone 或 iPad 上拍摄的一系列照片转换为 USDZ 文件,这些文件可以在“AR 快速查看”中查看,无缝整合到您的 Xcode 项目中,或在专业的 3D 内容工作流程中使用。

developer.apple.com/augmented-r…

macOS Monterey 和 SDK

下载 macOS Monterey 版和 Xcode 13 版,两者均支持物体捕捉 API。

使用物体捕捉功能创建 3D 模型

探索入门指南,了解如何使用 macOS 上的摄影测量 API 将您的素材资源变成栩栩如生的体验。

使用对象捕获创建3D模型

对象捕获提供了一种快速简便的方法,只需使用几张图像即可创建逼真的现实世界对象3D模型。了解如何使用 macOS 版 Photogrammetry 入门并使您的资产栩栩如生。并发现对象选择和图像捕获的最佳做法,以帮助您实现最高质量的结果。

developer.apple.com/videos/play…

为3D对象捕获拍照

使用深度和重力数据捕获高质量的图像,以便与RealityKit对象捕获一起使用。

对象捕获

class PhotogrammetrySession

管理从照片中创建3D对象的对象。

PhotogrammetrySession类从指定的图像集创建和控制3D对象重建。除图像外,您还可以提供来自某些相机的元数据,如深度缓冲区和重力信息,为重建算法提供信息。

RealityKit对象捕获仅适用于满足执行对象重建最低要求(包括至少4GB的RAM)并具有支持光线跟踪的GPU的Mac计算机。在使用任何对象捕获API之前,请检查代码正在运行的计算机是否满足这些要求,并且仅在运行时继续。

struct PhotogrammetrySample

表示一个图像及其相应元数据的对象。

Capturing Photographs for Reality​Kit Object Capture

拍摄高质量的对象图像以生成3D模型。

Creating 3D Objects from Photographs

构建虚拟对象以用于您的AR体验。

Creating a Photogrammetry Command-Line App

使用RealityKit对象捕获从图像生成3D对象。

Creating a Photogrammetry Command-Line App

使用RealityKit对象捕获从图像生成3D对象。

Inter版本的Mac 、 MacBook Pro (15-inch, 2019) 、CreatingAPhotogrammetryCommandLineApp 从图像(36张HEIC)生成3D对象花了9分钟

2021-11-17 15:16:56.334753+0800 HelloPhotogrammetry[43529:1512722] Metal GPU Frame Capture Enabled

2021-11-17 15:16:56.335505+0800 HelloPhotogrammetry[43529:1512722] Metal API Validation Enabled

2021-11-17 15:16:56.634754+0800 HelloPhotogrammetry[43529:1512722] [HelloPhotogrammetry] Using configuration: Configuration(isObjectMaskingEnabled: true, sampleOrdering: RealityFoundation.PhotogrammetrySession.Configuration.SampleOrdering.unordered, featureSensitivity: RealityFoundation.PhotogrammetrySession.Configuration.FeatureSensitivity.normal)

2021-11-17 15:16:56.673218+0800 HelloPhotogrammetry[43529:1512722] [HelloPhotogrammetry] Successfully created session.

2021-11-17 15:16:56.676605+0800 HelloPhotogrammetry[43529:1512722] [HelloPhotogrammetry] Using request: modelFile(url: file:///Users/XXX/Downloads/CreatingAPhotogrammetryCommandLineApp/Data/, detail: RealityFoundation.PhotogrammetrySession.Request.Detail.medium, geometry: nil)

2021-11-17 15:16:56.677423+0800 HelloPhotogrammetry[43529:1512722] [Photogrammetry] queueNextProcessingBatchIfNeeded(): Already running a job... not starting new one.

2021-11-17 15:16:57.016863+0800 HelloPhotogrammetry[43529:1513410] fopen failed for data file: errno = 2 (No such file or directory)

2021-11-17 15:16:57.016926+0800 HelloPhotogrammetry[43529:1513410] Errors found! Invalidating cache...

2021-11-17 15:16:57.143948+0800 HelloPhotogrammetry[43529:1513410] fopen failed for data file: errno = 2 (No such file or directory)

2021-11-17 15:16:57.144023+0800 HelloPhotogrammetry[43529:1513410] Errors found! Invalidating cache...

2021-11-17 15:16:58.340260+0800 HelloPhotogrammetry[43529:1513458] [HelloPhotogrammetry] Progress

2021-11-17 15:25:08.992054+0800 HelloPhotogrammetry[43529:1530298] [HelloPhotogrammetry] Processing is complete!

Program ended with exit code: 0

image.png

image.png

image.png

AR Quick Look, meet Object Capture 

探索将您的对象捕获资产带到AR快速查看的简单方法,同时优化视觉质量和文件大小。探索如何集成AR快速查看和对象捕获,以帮助创造全新的体验。为了充分利用此会话,我们建议您首先观看WWDC19的“AR快速查看中的进步”。您还可以通过WWDC20的“使用AR快速查看在线购物”,了解如何在网站上将Apple Pay和自定义操作与AR集成。

image.png

image.png