Finding the sharpest image in a sequence of captured images
At a glance
| Item | Summary |
|---|---|
| Purpose | Share image data between vDSP and vImage to compute the sharpest image from a bracketed photo sequence. |
| App architecture | A Swift sample with the source-visible chain AccelerateBlurDetectionApp → BlurDetectorView → BlurDetectorResultModel → BlurDetectionItemRenderer → Accelerate APIs. |
| Main patterns | Protocol-oriented abstraction, Delegate or data-source callbacks, SwiftUI environment injection, Publisher-backed observable state |
| Project style | 7 scanned source file(s) across Swift, organized around ranked entry, type, and file boundaries. |
Project structure
Source bundle/
├── AccelerateBlurDetection/
│ ├── AccelerateBlurDetectionApp.swift
│ ├── BlurDetector.swift
│ ├── BlurDetectorResultModel.swift
│ ├── PreviewView.swift
│ ├── BlurDetectionItemRenderer.swift
│ ├── BlurDetectorView.swift
│ ├── BlurDetectorResultsList.swift
│ ├── Base.lproj/
│ │ └── LaunchScreen.storyboard
│ └── Info.plist
├── AccelerateBlurDetection.xcodeproj/
│ ├── .xcodesamplecode.plist
│ └── project.pbxproj
└── Configuration/
└── SampleCode.xcconfig
Structure observations
- Architecturally prominent files are ranked from entry points and role-named declarations; resource-only paths are omitted.
- Primary languages: Swift.
- The verified tree contains 5 project/configuration file(s) and 11 source declaration(s).
Overall architecture
flowchart LR
N1["AccelerateBlurDetectionApp"]
N2["BlurDetectorView"]
N3["BlurDetectorResultModel"]
N4["BlurDetectionItemRenderer"]
N5["Accelerate APIs"]
N1 --> N2
N2 --> N3
N3 --> N4
N4 --> N5
Reference code
AccelerateBlurDetection/AccelerateBlurDetectionApp.swift:10 — architecture anchor
@main
struct AccelerateBlurDetectionApp: App {
// ...
}Interpretation
The arrows summarize the source-visible entry, role-named types or folders, and framework direction; when nodes come from structural folders, the sequence is a high-level interpretation rather than proof that every adjacent node calls the next. Ownership is claimed only where the next section cites a stored property or assignment. The diagram is intentionally limited to the dominant path into Accelerate.
Ownership and state
classDiagram
AccelerateBlurDetectionApp *-- BlurDetectorResultModel : blurDetectorResultModel
AccelerateBlurDetectionApp *-- BlurDetector : blurDetector
BlurDetector *-- Array : laplacian
BlurDetector *-- AVCaptureSession : captureSession
Ownership evidence
AccelerateBlurDetection/AccelerateBlurDetectionApp.swift:13 — stored dependency or nearest verified ownership anchor
@main
struct AccelerateBlurDetectionApp: App {
// ...
@StateObject private var blurDetectorResultModel = BlurDetectorResultModel()
// ...
}| Owner | Object or state | Relationship | Mutation authority |
|---|---|---|---|
AccelerateBlurDetectionApp |
BlurDetectorResultModel (blurDetectorResultModel) |
owns wrapper-managed state | Owning lexical scope |
AccelerateBlurDetectionApp |
BlurDetector (blurDetector) |
owns wrapper-managed state | Owning lexical scope |
BlurDetector |
Array (laplacian) |
owns value state | Initialized by the owner; the binding is immutable |
BlurDetector |
AVCaptureSession (captureSession) |
creates and retains | Initialized by the owner; the binding is immutable |
Composition arrows indicate a source-visible construction expression or locally owned value state; aggregation means the owner stores or receives a dependency without proving exclusive lifetime ownership.
Class and protocol design
AccelerateBlurDetection/BlurDetector.swift:312 — representative type boundary
protocol BlurDetectorResultsDelegate: AnyObject {
func itemProcessed(_ item: BlurDetectionResult)
func finishedProcessing()
}| Type | Responsibility | Depends on or conforms to |
|---|---|---|
AccelerateBlurDetectionApp |
Application entry and top-level composition | App |
BlurDetectorResultsDelegate |
Defines a capability or collaboration contract | AnyObject |
BlurDetectorResultModel |
Feature data or observable state | ObservableObject, BlurDetectorResultsDelegate |
PreviewView |
User-interface presentation and input forwarding | UIViewRepresentable |
UIPreviewView |
User-interface presentation and input forwarding | UIView |
BlurDetectionItemRenderer |
Owns drawing, GPU, or presentation processing | View |
BlurDetectorView |
User-interface presentation and input forwarding | View |
BlurDetector |
Owns feature behavior and collaborator lifecycle | NSObject, ObservableObject |
BlurDetectionResult |
Represents the result of an operation | Concrete collaborators/imported frameworks |
Mode |
Defines a closed set of feature states or choices | Concrete collaborators/imported frameworks |
The source explicitly defines local protocol relationships: BlurDetectorResultModel → BlurDetectorResultsDelegate.
Access control
| Symbol | Access | Verified effect | Likely rationale |
|---|---|---|---|
blurDetectorResultModel (AccelerateBlurDetection/AccelerateBlurDetectionApp.swift:13) |
private |
Use is restricted to the lexical declaration and same-file extensions allowed by Swift. | Inference: keep state mutation or dependency lifetime inside the owning implementation. |
blurDetector (AccelerateBlurDetection/AccelerateBlurDetectionApp.swift:14) |
private |
Use is restricted to the lexical declaration and same-file extensions allowed by Swift. | Inference: keep state mutation or dependency lifetime inside the owning implementation. |
configureSession (AccelerateBlurDetection/BlurDetector.swift:35) |
private |
Use is restricted to the lexical declaration and same-file extensions allowed by Swift. | Inference: hide an implementation step that is not part of the collaboration surface. |
BlurDetectorResultModel (AccelerateBlurDetection/BlurDetectorResultModel.swift:8) |
implicit internal |
No explicit modifier means the Swift declaration is internal to the module. | Inference: app-target collaboration needs no exported library surface. |
Reference code
AccelerateBlurDetection/AccelerateBlurDetectionApp.swift:13 — representative boundary
@main
struct AccelerateBlurDetectionApp: App {
// ...
@StateObject private var blurDetectorResultModel = BlurDetectorResultModel()
// ...
}Swift declarations without a modifier are internal; explicit private, fileprivate, private(set), public, or open entries above are interpreted by language semantics. Objective-C/C samples instead rely on header and implementation boundaries, which are not equivalent to Swift lexical privacy.
Logic ownership and placement
| Logic | Owning type or file | Placement rationale |
|---|---|---|
| Application entry and top-level composition | AccelerateBlurDetectionApp |
The source’s App suffix makes this role explicit. |
| Receives callback-driven events | BlurDetectorResultsDelegate |
The source’s Delegate suffix makes this role explicit. |
| Feature data or observable state | BlurDetectorResultModel |
The source’s Model suffix makes this role explicit. |
| Owns drawing, GPU, or presentation processing | BlurDetectionItemRenderer |
The source’s Renderer suffix makes this role explicit. |
| User-interface presentation and input forwarding | BlurDetectorView, PreviewView, UIPreviewView |
The source’s View suffix makes this role explicit. |
Design patterns
| Pattern | Source evidence | Purpose or tradeoff |
|---|---|---|
| Protocol-oriented abstraction | AccelerateBlurDetection/BlurDetectorResultModel.swift:16 |
A local protocol and concrete conformance create an explicit capability boundary. |
| Delegate or data-source callbacks | AccelerateBlurDetection/BlurDetectorResultModel.swift:16 |
Callback protocols invert event delivery back into the sample’s owner. |
| SwiftUI environment injection | AccelerateBlurDetection/BlurDetectorView.swift:14 |
The environment supplies state or a capability without threading it through every initializer. |
| Publisher-backed observable state | AccelerateBlurDetection/BlurDetectorResultModel.swift:26 |
Published properties notify observers while mutation remains with the state object. |
Naming conventions
- Types: App: AccelerateBlurDetectionApp; Delegate: BlurDetectorResultsDelegate; Model: BlurDetectorResultModel; Renderer: BlurDetectionItemRenderer; View: BlurDetectorView, PreviewView, UIPreviewView.
- Protocols:
BlurDetectorResultsDelegate. - Methods:
configure,configureSession,takePhoto,makeImage,rotate,only,photoOutput,processImage. - Files:
AccelerateBlurDetection/AccelerateBlurDetectionApp.swift,AccelerateBlurDetection/BlurDetector.swift,AccelerateBlurDetection/BlurDetectorResultModel.swift,AccelerateBlurDetection/PreviewView.swift,AccelerateBlurDetection/BlurDetectionItemRenderer.swift,AccelerateBlurDetection/BlurDetectorView.swift.
Architecture takeaways
AccelerateBlurDetectionAppis the main source-visible entry or composition anchor for this sample.- Framework work reaches SwiftUI, AVFoundation, UIKit, Accelerate through a deliberately small high-level chain; the detailed API graph remains inside the cited implementation files.
- Stored-property evidence identifies lifecycle collaboration; it does not by itself prove exclusive object ownership.
- Access-control conclusions separate verified language visibility from the likely design rationale.
- Local protocol relationships provide an explicit substitution boundary.
Source map
| Source file | Relevant symbols |
|---|---|
AccelerateBlurDetection/AccelerateBlurDetectionApp.swift |
AccelerateBlurDetectionApp |
AccelerateBlurDetection/BlurDetector.swift |
BlurDetector, BlurDetectorResultsDelegate, BlurDetectionResult |
AccelerateBlurDetection/BlurDetectorResultModel.swift |
BlurDetectorResultModel, Mode |
AccelerateBlurDetection/PreviewView.swift |
PreviewView, UIPreviewView |
AccelerateBlurDetection/BlurDetectionItemRenderer.swift |
BlurDetectionItemRenderer |
AccelerateBlurDetection/BlurDetectorView.swift |
BlurDetectorView |
AccelerateBlurDetection/BlurDetectorResultsList.swift |
BlurDetectorResultsList |