[WWDC26] What's new in image understanding
이 글은 WWDC 세션의 transcript 와 영상 화면을 Claude Code 로 정리한 글이고, 실제로 쓴 날은 2026-11-25 다. code 는 세션 page 의 snippet 을 SDK interface 에 맞게 고쳐 Xcode 27.0 의 iOS 27, watchOS 27 simulator SDK 로 type check 했고, Vision tool 을 쓰는 부분은 macOS 27 에서 실행했다.
세션 정보
- 세션: What’s new in image understanding
- 길이: 15분 46초
- 공개일: 2026-06-08
- 발표: Megan Williams (Vision Framework Engineer)
- 코드: 세션 page 에 snippet 5개가 있고, sample code 문서 2개가 연결되어 있다 (Segmenting objects using taps, scribbles, or rectangles, Implementing saliency-based image cropping in iOS and watchOS)
한 줄 요약
Vision 에는 tap 한 번으로 아무 object 나 잘라내는 GenerateIterativeSegmentationRequest 가 생겼고, Foundation Models 는 prompt 와 tool 인자로 image 를 받게 됐으며, Vision 자체가 watchOS 27 로 넘어왔다.
세션의 구성
세션은 15분짜리이고 주제 네 개를 차례로 다룬다. 발표자는 agenda 를 미리 만들지 않았다며 sticky note 사진을 Foundation Models 에 넣어 그 자리에서 agenda 를 뽑는 것으로 시작한다. 이 장면이 두 번째 주제의 예고 역할을 한다.
| 순서 | 내용 | 발표 |
|---|---|---|
| 0:00 | Introduction | Megan Williams |
| 1:36 | Segment images with tap-to-segment | Megan Williams |
| 5:50 | Image inputs for Foundation Models | Megan Williams |
| 7:57 | Image-based tool calling | Megan Williams |
| 13:09 | Vision on watchOS | Megan Williams |
| 14:39 | Next steps | Megan Williams |
출처: WWDC26 - What’s new in image understanding
노란 sticky note 네 장에 손글씨로 Tap-to-segment, Image analysis in Foundation Models, Image-based tools, Vision on watchOS 가 적혀 있다. 세션 내내 이 사진이 chapter 구분 화면으로 다시 나온다.
출처: WWDC26 - What’s new in image understanding
iPad 앱의 왼쪽에 그 사진이 들어가 있고 오른쪽에 model 이 만든 agenda 가 네 줄로 나온다. “Segment images with tap-to-segment”, “Analyze images using Foundation Models”, “Create image-based tools”, “Explore Vision on watchOS” 다. 손글씨 메모를 읽어서 문장으로 다듬은 결과이고, 발표자는 올해 Foundation Models 가 image input 을 지원하게 되어 가능한 일이라고 설명한다.
Tap-to-segment
첫 주제는 image 에서 object 하나를 골라 mask 로 잘라내는 API 다. Vision 에는 이미 사람을 잘라내는 person segmentation 이 있었지만 대상이 사람으로 한정되어 있었다. 새 API 는 대상의 종류를 가리지 않는다.
출처: WWDC26 - What’s new in image understanding
두 사람이 board game 을 하는 실내 사진에서 테이블 오른쪽의 꽃병만 밝게 남고 나머지는 어둡게 처리되어 있다. 영상에서는 같은 사진으로 사람, board game, 꽃병 순으로 강조 대상이 바뀐다. 발표자는 옷이나 바닥 같은 것도 고를 수 있다고 말한다.
대상을 고르는 네 가지 방법
어느 object 를 원하는지는 사용자가 image 위에 표시해서 알려 준다. 세션은 cafe 사진을 띄운 iPad 앱으로 네 가지를 보여 준다.
출처: WWDC26 - What’s new in image understanding
가장 단순한 방법은 point 다. 커피잔을 한 번 tap 하면 잔만 밝게 남는다.
출처: WWDC26 - What’s new in image understanding
bounding box 를 그리면 그 안의 것을 한 덩어리로 잡는다. 화면에서는 잔과 받침 접시가 함께 선택되어 있다.
출처: WWDC26 - What’s new in image understanding
lasso 는 대상 둘레를 따라 선을 그리는 방법이다. croissant 둘레를 그리자 croissant 만 남았다.
출처: WWDC26 - What’s new in image understanding
scribble 은 대상 위를 문지르듯 그리는 방법이고, 여러 object 를 한꺼번에 고를 때 쓴다. 화면에서는 croissant 와 그 아래 나무 도마, 잼 그릇이 함께 선택되어 있다.
Mask 다듬기
한 번에 원하는 mask 가 나오지 않으면 점을 더해 고친다. API 이름의 iterative 가 이 과정을 가리킨다.
출처: WWDC26 - What’s new in image understanding
잔만 선택된 상태에서 접시 위에 점을 하나 더 찍으면 접시까지 포함된다.
출처: WWDC26 - What’s new in image understanding
반대로 빼고 싶은 곳에 제외 점을 찍을 수도 있다. 화면에는 잔이 빠지고 잔 안의 커피 표면만 동그랗게 남아 있다.
Request 의 흐름
code 로는 Vision 의 다른 request 와 같은 모양이다.
출처: WWDC26 - What’s new in image understanding
“Segment images” slide 다. 커피잔 사진 아래에 ImageRequestHandler, 가운데에 GenerateIterativeSegmentationRequest, 오른쪽에 검은 바탕의 흰 잔 모양 mask 와 PixelBufferObservation 이 놓여 있다. handler 에 image 를 넣고, request 를 perform 하면 mask 가 pixel buffer 로 나온다는 뜻이다.
출처: WWDC26 - What’s new in image understanding
영상의 code slide 다. initializer 가 GenerateIterativeSegmentationRequest(point: point) 로 적혀 있다. 세션 page 의 snippet 은 같은 자리가 seed: point 이고, Xcode 27.0 SDK 의 실제 이름은 seedPoint: 다. 세 군데가 다 다르므로 SDK 기준으로 쓴 code 를 싣는다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import CoreGraphics
import CoreVideo
import Vision
func segmentCup(in image: CGImage) async throws -> CVReadOnlyPixelBuffer? {
let handler = ImageRequestHandler(image)
let point = NormalizedPoint(x: 0.42, y: 0.35)
let request = GenerateIterativeSegmentationRequest(seedPoint: point)
let observation = try await handler.perform(request)
let mask = observation?.pixelBuffer
// Refine the mask with a new point
let platePoint = NormalizedPoint(x: 0.60, y: 0.22)
try request.addIncludedPoint(platePoint)
let refinedObservation = try await handler.perform(request)
return refinedObservation?.pixelBuffer ?? mask
}
좌표 값은 임의로 넣은 것이다. page snippet 과 다른 점은 두 가지다. initializer label 이 seedPoint: 이고, addIncludedPoint(_:) 가 throws 라서 try 가 필요하다. 같은 request 객체에 점을 더한 뒤 다시 perform 하는 구조라서 request 를 새로 만들지 않는다.
제외 점과 bounding box 도 같은 방식이다.
1
2
3
4
5
6
7
8
9
10
11
12
func segmentCoffeeOnly(in image: CGImage) async throws -> CVReadOnlyPixelBuffer? {
let handler = ImageRequestHandler(image)
let request = GenerateIterativeSegmentationRequest(seedPoint: NormalizedPoint(x: 0.42, y: 0.40))
try request.addExcludedPoint(NormalizedPoint(x: 0.30, y: 0.33))
return try await handler.perform(request)?.pixelBuffer
}
func segmentArea(in image: CGImage, box: NormalizedRect) async throws -> CVReadOnlyPixelBuffer? {
let request = GenerateIterativeSegmentationRequest(seedBox: box)
request.qualityLevel = .accurate
return try await ImageRequestHandler(image).perform(request)?.pixelBuffer
}
SDK interface 에 있는 initializer 는 seedPoint:, seedBox:, seedScribbleBuffer: 세 개다. lasso 전용 initializer 는 보이지 않는다. qualityLevel 은 세션에 나오지 않지만 interface 에 accurate, balanced, fast 세 값이 있다.
GenerateIterativeSegmentationRequest
seed (point, box, scribble) 를 받아 그 위치의 object mask 를 만드는 Vision request 다. 결과는 PixelBufferObservation? 이고, addIncludedPoint(_:) 와 addExcludedPoint(_:) 로 점을 더한 뒤 다시 perform 해서 mask 를 고친다. iOS 27.0, macOS 27.0, tvOS 27.0, visionOS 27.0 에서 쓸 수 있고 watchOS 에서는 쓸 수 없다. 문서는 GenerateIterativeSegmentationRequest 에 있다.
ImageRequestHandler
image 하나에 대해 Vision request 를 실행하는 type 이다. 같은 image 로 request 를 여러 번 perform 할 때 handler 를 재사용한다. 문서는 ImageRequestHandler 에 있다.
좌표와 lasso 폭
세션은 주의할 점 두 가지를 따로 짚는다.
출처: WWDC26 - What’s new in image understanding
“Use normalized coordinates” slide 다. 커피잔 사진의 왼쪽과 아래에 0 에서 1 까지의 축이 그려져 있고, 가운데 파란 점에 X: 0.5, Y: 0.5 라는 label 이 붙어 있다. Vision 의 좌표는 pixel 이 아니라 0 에서 1 사이의 비율이고, 원점이 왼쪽 아래다. UIKit 이나 SwiftUI 의 touch 좌표는 원점이 왼쪽 위이므로 y 를 뒤집어야 한다.
출처: WWDC26 - What’s new in image understanding
“Use wide lasso strokes” slide 다. 왼쪽은 가는 선으로 잔 둘레를 그린 예이고 빨간 X 가 붙어 있다. 오른쪽은 굵은 선으로 그린 예이고 초록 check 가 붙어 있다. 발표자는 lasso 의 선 폭이 image 폭의 1% 이상이어야 한다고 말한다. 4000 pixel 폭 사진이라면 선이 40 pixel 이상이어야 한다는 뜻이다.
Model download
이 request 는 처음 쓰기 전에 model 을 내려받아야 한다.
출처: WWDC26 - What’s new in image understanding
“Download segmentation model” slide 에 세 줄이 있다. “Download model before performing request”, “Use request.downloadAssets()”, “Check if model is ready with request.assetStatus” 다.
1
2
3
4
5
6
func prepareSegmentationModel() async throws {
let request = GenerateIterativeSegmentationRequest(seedPoint: NormalizedPoint(x: 0.5, y: 0.5))
if await request.assetStatus != .ready {
try await request.downloadAssets()
}
}
assetStatus 는 async getter 라서 await 가 붙는다. 값은 notReady, downloading, ready, error 네 가지다. download 는 instance method 라서 request 를 하나 만들어야 부를 수 있고, 위 code 의 seed 는 그 용도로만 넣은 값이다. interface 에는 진행률을 받는 downloadAssets(progress:) 도 있다.
DownloadableAssetsRequest
model 을 내려받아야 쓸 수 있는 Vision request 가 따르는 protocol 이다. downloadAssets() 와 assetStatus 가 여기서 온다. 문서는 DownloadableAssetsRequest 에 있다.
Foundation Models 의 image input
두 번째 주제는 Vision 이 아니라 Foundation Models framework 다. 작년까지 text 만 받던 on-device model 이 올해 image 를 함께 받는다.
출처: WWDC26 - What’s new in image understanding
야외에서 체스를 두는 할머니와 손녀 사진 옆에 model 이 만든 caption 이 있다. 할머니와 손녀가 화창한 날 밖에서 체스를 두며 시간을 보낸다는 한 문장이다.
출처: WWDC26 - What’s new in image understanding
열린 냉장고 사진을 넣자 “Quick Stir-Fry (15 minutes)” 라는 recipe 가 Prep, Sauté, Season, Protein, Finish 다섯 단계로 나온다. 사진 속 재료 (토마토, 피망, 달걀) 가 recipe 에 들어가 있다. 영상에서는 이 사이에 빈 방 사진으로 인테리어 조언을 받는 예도 지나간다.
code 는 prompt 에 attachment 를 하나 더 넣는 것이 전부다.
1
2
3
4
5
6
7
8
9
10
11
import FoundationModels
func caption(for image: CGImage) async throws -> String {
let session = LanguageModelSession()
let prompt = Prompt {
"Generate a caption for this image"
Attachment(image)
}
let response = try await session.respond(to: prompt)
return response.content
}
page snippet 은 session 이 어디서 오는지 생략되어 있어서 함수로 감싸고 session 을 만드는 줄을 더했다. Attachment 는 CGImage 말고도 CIImage, pixel buffer, file URL 로 만들 수 있다.
Attachment
prompt 에 text 가 아닌 내용을 싣는 type 이다. image 의 경우 Attachment(image) 로 만들고, label(_:) 로 이름을 붙일 수 있다. 문서는 Attachment 에 있다.
LanguageModelSession
on-device model 과의 대화 한 줄기를 나타내는 type 이다. respond(to:) 로 prompt 를 보내고 응답을 받는다. 문서는 LanguageModelSession 에 있다.
두 framework 의 구분
image 를 이해하는 방법이 두 가지가 됐으니 언제 무엇을 쓸지가 문제다.
출처: WWDC26 - What’s new in image understanding
“Analyze images” slide 가 둘을 나란히 적는다. Foundation Models framework 아래에는 “Uses large language models”, “Works across a wide range of tasks” 가 있다. Vision framework 아래에는 “Fixed set of computer vision APIs”, “Optimized for specific use cases”, “Optimized for on-device performance” 가 있다.
정리하면 Foundation Models 는 질문을 자유롭게 바꿀 수 있는 대신 무겁고, Vision 은 할 수 있는 일이 정해져 있는 대신 빠르다. 발표자는 Vision 이 실시간 video 처리에도 쓸 수 있을 만큼 최적화되어 있다고 말한다. barcode 를 읽거나 얼굴 위치를 찾는 것처럼 답의 형태가 정해진 일은 Vision 이 맞고, 사진을 보고 설명하거나 제안하는 일은 Foundation Models 가 맞다.
Image 를 받는 tool
세 번째 주제는 두 framework 를 잇는 방법이다. model 이 스스로 못 하는 일을 tool 로 넘기는데, 그 tool 이 image 를 인자로 받을 수 있게 됐다.
Tool calling 이란?
Tool calling 은 model 이 응답을 만드는 도중에 앱이 제공한 함수를 호출하고 그 결과를 응답에 쓰는 방식이다. model 은 학습한 것만 알고 있으므로, 오늘 날씨나 앱 안의 data 같은 것은 tool 로 가져온다.
출처: WWDC26 - What’s new in image understanding
“Tool calling” slide 다. 사용자가 “What’s the weather tomorrow?” 라고 묻자 Model 이 Weather tool 을 6/10/26 이라는 인자로 호출하고, tool 이 72°F 를 돌려주며, model 이 “The weather will be a perfect 72°F.” 라고 답한다. 날짜를 뽑아 인자로 만드는 것은 model 이고, 실제 값을 가져오는 것은 tool 이다. 자세한 내용은 작년 세션 Deep dive into the Foundation Models framework 에 있다.
ImageReference
올해는 tool 의 인자에 image 를 쓸 수 있다.
출처: WWDC26 - What’s new in image understanding
분홍색과 주황색 꽃 사진과 함께 “What is this flower?” 를 보내자 Model 에서 PlantID tool 로 “Image reference” 라는 화살표가 나가고, tool 에서 “Alstroemeria” 가 돌아오며, 사용자에게 “That’s an alstroemeria.” 라는 답이 간다. 화살표의 이름이 중요하다. model 은 image data 전체를 tool 에 넘기지 않고 어느 image 인지를 가리키는 reference 만 넘긴다. tool 이 그 reference 로 원본 image 를 찾는다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import CoreVideo
import FoundationModels
enum AppError: Error { case imageNotFound }
func classifyPlant(_ image: CVReadOnlyPixelBuffer) -> String {
"Monstera deliciosa"
}
struct PlantIdentifierTool: Tool {
let name = "identifyPlant"
let description = "Identifies the plant in an image."
@SessionProperty(\.history) var history
@Generable
struct Arguments {
var image: ImageReference
}
func call(arguments: Arguments) async throws -> String {
let imageReference = arguments.image
guard let imageAttachment = imageReference.resolved(in: history) else {
throw AppError.imageNotFound
}
let image = try imageAttachment.pixelBuffer()
return classifyPlant(image)
}
}
classifyPlant 는 세션에서 정의하지 않은 함수라서 고정 문자열을 돌려주는 자리 표시로 채웠다. 실제로는 Core ML 분류 model 같은 것이 들어갈 자리다. page snippet 과 다른 점은 세 가지다.
Tool은name과description을 요구한다. snippet 에는 둘 다 없어서 conform 하지 못한다.- snippet 은
Transcript(history)로 transcript 를 만든 뒤imageReference.resolve(in: transcript)를 부른다. SDK 에 있는 method 는resolved(in:)이고 transcript entry 의 sequence 를 받으므로history를 바로 넘기면 된다. AppError와classifyPlant가 정의되어 있지 않다.
@SessionProperty(\.history) 는 tool 이 자신을 호출한 session 의 대화 기록을 읽는 통로다. image 는 사용자가 prompt 에 attachment 로 실은 것이므로 대화 기록 안에 있고, reference 를 그 기록에 대조해서 attachment 를 찾는다. 찾은 attachment 에서 pixelBuffer(), cgImage, ciImage 로 실제 image 를 꺼낸다.
ImageReference
tool 인자로 쓰는 image 의 참조다. Generable 이라서 @Generable struct 의 property 로 둘 수 있고, resolved(in:) 으로 transcript 안의 image attachment 를 찾는다. 문서는 ImageReference 에 있다.
Tool
model 이 호출할 수 있는 함수를 정의하는 protocol 이다. name, description, Arguments, call(arguments:) 를 구현한다. 문서는 Tool 에 있다.
Vision 이 제공하는 tool
tool 을 매번 직접 만들 필요는 없다. Vision 이 바로 쓸 수 있는 tool 두 개를 제공한다고 세션은 소개한다.
출처: WWDC26 - What’s new in image understanding
“Read QR codes” slide 다. “THE GREAT FOLD-OFF!” 라는 origami 대회 flyer 를 Model 에 넣자 location 은 “1 Apple Park Way, Cupertino”, date 는 “6/08/26” 으로 나오는데 website 는 빨간 글씨로 “unknown” 이다. 날짜와 장소는 flyer 에 글자로 적혀 있지만 website 는 QR code 안에만 있어서 model 이 읽지 못한 것이다.
출처: WWDC26 - What’s new in image understanding
Model 위에 초록색 “Barcode reader tool” 이 붙고 둘 사이에 화살표가 오간다. 이번에는 website 가 “example.com” 으로 채워진다. model 이 QR code 를 직접 해석하지 않고 tool 에 맡긴 결과다.
출처: WWDC26 - What’s new in image understanding
“Vision tools” slide 에 두 개가 적혀 있다. BarcodeReaderTool 은 “Scan barcodes and QR codes”, OCRTool 은 “Read dense text in 30+ languages” 다. 오른쪽에는 글자가 빽빽한 책 사진이 있다. model 도 image 안의 글자를 어느 정도 읽지만 작은 글씨가 많은 문서는 OCR tool 이 더 낫다는 설명이다.
세션이 보여 주는 사용법은 간단하다. Vision 을 import 하고, session 을 만들 때 tools: 에 BarcodeReaderTool() 을 넣고, attachment 에 .label("flyer") 를 붙인다. label 은 model 이 tool 에 넘길 image 를 가리킬 때 쓰는 이름이다. image 가 한 장이어도 label 은 빼면 안 된다. macOS 27.0.1 에서 같은 code 를 .label("flyer") 만 빼고 돌리면 model 이 image1 이라는 label 을 지어내 tool 에 넘기고, respond 는 ToolCallError 를 던진다. 안에 든 error 는 VisionError.invalidImage("No image in transcript with label image1") 다. label 을 붙이면 tool call 의 argument 가 {"image": {"attachmentLabel": "flyer"}} 로 나가고 QR code 의 주소가 돌아온다.
두 type 은 Vision 에도 Foundation Models 에도 들어 있지 않다. 두 framework 를 한 파일에서 함께 import 했을 때만 따라 들어오는 _Vision_FoundationModels 라는 module 에 선언되어 있다 (이런 구성을 cross-import overlay 라고 한다). 그래서 import Vision 과 import FoundationModels 가 둘 다 있어야 이름이 보이고, 한쪽만 있으면 cannot find 'BarcodeReaderTool' in scope 가 난다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import FoundationModels
import Vision
@Generable
struct EventInfo {
var date: String
var location: String
var website: String
}
func readFlyer(_ image: CGImage) async throws -> EventInfo {
let session = LanguageModelSession(tools: [BarcodeReaderTool()])
let response = try await session.respond(generating: EventInfo.self) {
"Get the date, location, and website from this flyer"
Attachment(image)
.label("flyer")
}
return response.content
}
BarcodeReaderTool과 OCRTool로 image 속 code와 글자 읽기
BarcodeReaderTool 과 OCRTool 은 둘 다 Tool 을 채택한 struct 다. initializer 는 init(name:description:) 이고 두 값 모두 기본값이 nil 이라 BarcodeReaderTool() 처럼 비워 두면 된다. 비워 두었을 때 model 에게 보이는 tool 이름은 BarcodeReaderTool 이 readBarcodes, OCRTool 이 getText 다. 두 tool 의 Arguments 는 image 하나뿐이고, 그 안에 attachment 의 label 을 담는 attachmentLabel 이 들어간다. .label("flyer") 를 붙이는 이유가 이것이다.
EventInfo 는 세션에 이름만 나오는 type 이라 slide 의 출력 항목 세 개로 채웠다. 나머지는 page snippet 과 같다.
macOS 27 에서 이 code 를 실제로 돌려 봤다. 날짜와 장소를 글자로 적고 https://example.com/garden-party 를 QR code 로 넣은 flyer image 를 만들어 넘겼다.
| tools | date | location | website |
|---|---|---|---|
| 없음 | Saturday, June 20, 2026 at 3 PM | Rose Pavilion, Golden Gate Park | (빈 문자열) |
BarcodeReaderTool() | Saturday, June 20, 2026 at 3 PM | Rose Pavilion, Golden Gate Park | https://example.com/garden-party |
OCRTool() | Saturday, June 20, 2026 | Rose Pavilion, Golden Gate Park | (빈 문자열) |
| 둘 다 | Saturday, June 20, 2026 | Rose Pavilion, Golden Gate Park | https://example.com/garden-party |
세션의 slide 와 같은 결과다. tool 이 없으면 글자로 적힌 날짜와 장소는 읽지만 website 는 비고, BarcodeReaderTool 을 주면 채워진다. transcript 를 보면 model 이 readBarcodes 를 {"image": {"attachmentLabel": "flyer"}} 로 부르고, tool 은 barcodeType 이 qr, content 가 그 주소인 JSON 을 돌려준다. OCRTool 은 image 의 글자 네 줄을 줄바꿈으로 이어 돌려준다. 둘을 함께 주면 model 은 한 번에 두 tool 을 모두 부른다.
Xcode 27.0 에서 따라 할 때 막히는 곳이 하나 있다. 이 module 은 iOS, macOS, visionOS 의 기기용 SDK 에는 있는데 iOS simulator SDK 에는 빠져 있다. 그래서 같은 code 가 기기나 Mac 을 대상으로는 빌드되고, simulator 를 대상으로 하면 cannot find 'BarcodeReaderTool' in scope 로 멈춘다. simulator 에서도 돌려야 하면 같은 일을 하는 tool 을 직접 만들어 tools: 에 대신 넣는다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
struct QRCodeTool: Tool {
let name = "readQRCode"
let description = "Reads the QR codes and barcodes in an image and returns their contents."
@SessionProperty(\.history) var history
@Generable
struct Arguments {
var image: ImageReference
}
func call(arguments: Arguments) async throws -> String {
guard let attachment = arguments.image.resolved(in: history) else {
throw AppError.imageNotFound
}
let barcodes = try await DetectBarcodesRequest().perform(on: attachment.cgImage)
let payloads = barcodes.compactMap(\.payloadString)
return payloads.isEmpty ? "No code found." : payloads.joined(separator: "\n")
}
}
QRCodeTool 은 앞의 PlantIdentifierTool 과 구조가 같고 안에서 부르는 것만 Vision 의 DetectBarcodesRequest 로 바뀌었다. readFlyer 에서 BarcodeReaderTool() 자리에 QRCodeTool() 을 넣으면 simulator SDK 로도 type check 를 통과한다.
DetectBarcodesRequest
image 에서 barcode 와 QR code 를 찾아 내용을 돌려주는 Vision request 다. 결과인 BarcodeObservation 의 payloadString 에 code 안의 문자열이 들어 있다. 문서는 DetectBarcodesRequest 에 있다.
직접 만드는 Vision tool
제공되는 tool 은 두 개지만 Vision 의 나머지 request 도 같은 방식으로 tool 로 감쌀 수 있다.
출처: WWDC26 - What’s new in image understanding
“Analyze images with Vision” slide 에 다섯 갈래가 적혀 있다. Image segmentation, Facial analysis, Pose estimation, Detection and classification, Trajectory analysis and object tracking 이다. 오른쪽에는 삼각대에 올린 iPhone 으로 잔디밭을 찍는 사진이 있다. 발표자는 Vision 이 30가지가 넘는 분석을 제공한다고 말하고, 아래 줄에서 WWDC24 의 Discover Swift enhancements in the Vision framework 를 가리킨다.
위에서 DetectBarcodesRequest 로 만든 QRCodeTool 이 이 방식의 예다. model 은 무엇을 물어볼지와 결과를 어떻게 말로 풀지를 맡고, 정확한 값을 뽑는 일은 Vision request 가 맡는다.
watchOS 의 Vision
마지막 주제는 짧다. Vision framework 를 watchOS 에서 쓸 수 있게 됐다.
출처: WWDC26 - What’s new in image understanding
Apple Watch 에서 도는 Nature Guide 라는 예제 앱이다. Red-eyed Tree Frog 항목에 들어가면 사진이 나오는데, 원본이 넓은 풍경 사진이라 개구리가 화면 가운데 작은 점으로만 보인다. 작은 화면에서는 사진을 그대로 줄이는 것만으로는 부족하다는 문제를 보여 주는 장면이다.
Saliency 란?
Saliency 는 image 에서 눈에 띄는 영역을 찾는 분석이다. Vision 에는 사람의 시선이 갈 곳을 찾는 attention 기반과 object 로 보이는 영역을 찾는 objectness 기반 두 종류가 있고, 세션은 후자를 쓴다.
출처: WWDC26 - What’s new in image understanding
“Identify subjects with saliency analysis” slide 다. 어두운 잎 사이의 개구리 둘레에 노란 사각형이 그려져 있다. 이 사각형이 saliency 분석이 돌려준 주 피사체의 bounding box 이고, 이 영역으로 사진을 잘라 내면 개구리가 화면을 채운다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import CoreGraphics
import Vision
func generateImageCrop(in image: CGImage) async throws -> NormalizedRect? {
let request = GenerateObjectnessBasedSaliencyImageRequest()
let observation = try await request.perform(on: image)
let prominentObjects = observation.salientObjects
return prominentObjects.first?.boundingBox
}
func cropToSubject(_ image: CGImage) async throws -> CGImage {
guard let rect = try await generateImageCrop(in: image) else { return image }
let size = CGSize(width: image.width, height: image.height)
let pixelRect = rect.toImageCoordinates(size, origin: .upperLeft)
return image.cropping(to: pixelRect) ?? image
}
첫 함수는 page snippet 에서 마지막 줄만 고쳤다. snippet 은 return prominentObjects.first 인데 salientObjects 의 원소가 RectangleObservation 이라서 NormalizedRect? 로 돌려줄 수 없다. .first?.boundingBox 로 꺼내야 한다.
두 번째 함수는 세션에 없는 부분이고, 받은 사각형으로 실제로 자르는 과정을 채운 것이다. NormalizedRect 는 원점이 왼쪽 아래인 0 에서 1 사이 좌표인데 CGImage.cropping(to:) 은 원점이 왼쪽 위인 pixel 좌표를 받는다. toImageCoordinates(_:origin:) 에 .upperLeft 를 넘겨 한 번에 바꿨다. 이 두 함수는 watchOS 27 simulator SDK 로도 type check 를 통과했다.
출처: WWDC26 - What’s new in image understanding
crop 을 적용한 뒤의 같은 화면이다. 빨간 눈의 개구리가 사진 영역을 가득 채우고, 아래에 Red-eyed Tree Frog 와 학명 Agalychnis callidryas 가 보인다.
GenerateObjectnessBasedSaliencyImageRequest
image 에서 object 로 보이는 영역을 찾는 Vision request 다. 결과의 salientObjects 에 영역별 RectangleObservation 이 들어 있다. iOS 18.0 부터 있던 API 이고 watchOS 는 27.0 부터다. 문서는 GenerateObjectnessBasedSaliencyImageRequest 에 있다.
NormalizedRect
Vision 이 쓰는 0 에서 1 사이 비율 좌표의 사각형이다. toImageCoordinates(_:origin:) 으로 pixel 좌표의 CGRect 로 바꾼다. 문서는 NormalizedRect 에 있다.
watchOS 에서 되는 것과 안 되는 것
세션은 “Vision 이 watchOS 에서 된다” 고만 말하지만 전부가 넘어온 것은 아니다. watchOS 27 simulator SDK 의 Vision interface 를 보면 watchOS 27.0 availability 가 붙은 선언이 127곳이고, watchOS unavailable 로 표시된 선언이 4곳이다. 이 글의 첫 주제인 GenerateIterativeSegmentationRequest 가 그 unavailable 쪽에 있다. tap-to-segment code 를 watchOS target 으로 type check 하면 type 을 찾지 못한다는 error 가 난다.
Foundation Models 쪽은 Attachment, ImageReference, Tool 모두 watchOS 27.0 availability 가 붙어 있다. BarcodeReaderTool 도 watchOS 27.0 이 붙어 있고, OCRTool 은 watchOS unavailable 로 표시되어 있다.
세션의 마무리
발표자는 네 가지를 다시 짚는다. tap-to-segment 로 아무 object 나 잘라낼 수 있고, Foundation Models 가 image 를 입력으로 받으며, tool 이 image 를 인자로 받아 Vision 과 이어지고, Vision 이 watchOS 로 왔다.
출처: WWDC26 - What’s new in image understanding
“Next steps” slide 다. 나무 책상 위에 선글라스를 쓴 노란 고무 오리가 놓여 있고 왼쪽에 세 줄이 있다. “Download sample code”, “Learn more about Vision APIs”, “Deep dive in Foundation Models” 다. 아래에는 관련 세션 두 개가 적혀 있다. WWDC24 의 “Discover Swift enhancements in the Vision framework” 와 WWDC26 의 What’s new in the Foundation Models framework 다.
정리
세션에 나온 API 의 availability 를 SDK interface 와 문서에서 확인한 대로 적으면 다음과 같다.
| API | 도입 | watchOS |
|---|---|---|
GenerateIterativeSegmentationRequest | iOS 27.0, macOS 27.0, tvOS 27.0, visionOS 27.0 | 사용 불가 |
DownloadableAssetsRequest | iOS 27.0 | 27.0 |
Attachment, ImageReference | iOS 27.0, macOS 27.0, visionOS 27.0 (tvOS 사용 불가) | 27.0 |
BarcodeReaderTool | iOS 27.0, macOS 27.0, visionOS 27.0 (Xcode 27.0 의 iOS simulator SDK 에는 없음) | 27.0 |
OCRTool | iOS 27.0, macOS 27.0, visionOS 27.0 (Xcode 27.0 의 iOS simulator SDK 에는 없음) | 사용 불가 |
GenerateObjectnessBasedSaliencyImageRequest | iOS 18.0, macOS 15.0 | 27.0 |
세션 page 의 snippet 과 Xcode 27.0 SDK 가 어긋나는 곳도 모아 둔다.
| snippet | SDK 에서 통과한 형태 |
|---|---|
GenerateIterativeSegmentationRequest(seed: point) | GenerateIterativeSegmentationRequest(seedPoint: point) |
request.addIncludedPoint(newPoint) | try request.addIncludedPoint(newPoint) |
PlantIdentifierTool 에 name, description 없음 | 두 property 추가 |
imageReference.resolve(in: Transcript(history)) | imageReference.resolved(in: history) |
BarcodeReaderTool() | 기기와 Mac SDK 에서는 그대로 통과. iOS simulator SDK 에는 type 없음 |
return prominentObjects.first | return prominentObjects.first?.boundingBox |
실제 프로젝트에 가져갈 점은 다음과 같다.
- 사진에서 대상만 잘라내는 기능 (sticker, 배경 제거, 부분 편집) 은
GenerateIterativeSegmentationRequest하나로 만들 수 있다. 처음 결과가 틀리면 request 를 새로 만들지 말고 같은 request 에 점을 더해서 다시 perform 한다. - 이 request 는 model download 가 필요하다. 사용자가 처음 tap 하는 순간에 받기 시작하면 늦으므로, 기능 화면에 들어올 때
assetStatus를 보고 미리downloadAssets()를 부른다. - touch 좌표를 Vision 에 넘길 때는 0 에서 1 로 나누고 y 를 뒤집는다. Vision 결과를
CGImage에 쓸 때는toImageCoordinates(_:origin:)에.upperLeft를 넘긴다. - image 를 설명하거나 제안하는 일은 Foundation Models 에, 형태가 정해진 값을 뽑는 일은 Vision 에 맡긴다. 둘 다 필요하면 Vision request 를
Tool로 감싸서 model 이 부르게 한다. - image 를 받는 tool 은 인자를
ImageReference로 선언하고@SessionProperty(\.history)로 원본을 찾는다. attachment 에는 image 가 한 장이어도 label 을 붙인다.BarcodeReaderTool은 label 이 없으면 image 를 찾지 못하고 error 를 던진다. - watchOS 앱에서 사진을 보여 줄 때는 saliency crop 이 싸고 효과가 크다. 다만 watchOS 에서 Vision 의 모든 request 가 되는 것은 아니므로 target 을 watchOS 로 두고 빌드해서 확인한다.