2021 Graphics & GamesSpatial Computing
WWDC21 · 28 min · Graphics & Games / Spatial Computing
Create 3D models with Object Capture
Object Capture provides a quick and easy way to create lifelike 3D models of real-world objects using just a few images. Learn how you can get started and bring your assets to life with Photogrammetry for macOS. And discover best practices with object selection and image capture to help you achieve the highest-quality results.
Watch at developer.apple.com ↗Code shown on screen · 3 snippets
Creating a PhotogrammetrySession with a folder of images
import RealityKit
let inputFolderUrl = URL(fileURLWithPath: "/tmp/Sneakers/", isDirectory: true)
let session = try! PhotogrammetrySession(input: inputFolderUrl,
configuration: PhotogrammetrySession.Configuration()) Creating the async message stream dispatcher
// Create an async message stream dispatcher task
Task {
do {
for try await output in session.outputs {
switch output {
case .requestProgress(let request, let fraction):
print("Request progress: \(fraction)")
case .requestComplete(let request, let result):
if case .modelFile(let url) = result {
print("Request result output at \(url).")
}
case .requestError(let request, let error):
print("Error: \(request) error=\(error)")
case .processingComplete:
print("Completed!")
handleComplete()
default: // Or handle other messages...
break
}
}
} catch {
print("Fatal session error! \(error)")
}
} Calling process on two models simultaneously
try! session.process(requests: [
.modelFile("/tmp/Outputs/model-reduced.usdz", detail: .reduced),
.modelFile("/tmp/Outputs/model-medium.usdz", detail: .medium)
]) Resources
Related sessions
-
26 min -
22 min -
15 min -
14 min