반응형

**들어가기

- 해당 문서는 qiita.com/shu223/items/722077b4bbe868f58ddc 의 번역 글입니다

- 더 자세한 내용은 추가적으로 찾아보길 바랍니다

 

 

** 번역시작

 

제목 : ARKit 4 LiDAR Depth API 

 

iOS 기기에서 처음 LiDAR 스캐너를 탑재 한 iPad Pro의 발매와 동시에 출시 된 ARKit 3.5에서는 LiDAR를 이용하여 reconstraction 한 3D 메쉬는 얻을 수 있었지만, 그 계산에 이용되고있는 것 뎁스 (깊이) 데이터에 액세스 할 수 없었다.

 

 

이후 발표 된 ARKit 4 / iOS 14 (/ iPadOS 14)에서 드디어 LiDAR에서 측정 한 깊이를 얻을 수있게되었다. 기존의 깊이와 구별하기 위해 "장면 깊이 (Scene Depth) '이라고도하는 것 같다.

 

LiDAR 깊이의 취득 방법

 

LiDAR 유래의 깊이 데이터는 ARWorldTrackingConfiguration 이용시 frameSemantics 속성에 .sceneDepth 옵션을 지정하여 검색 가능하게된다.

 

let session = ARSession()
let configuration = ARWorldTrackingConfiguration()

// sceneDepth 옵션을 사용할 수 있는지 확인
if type(of: configuration).supportsFrameSemantics(.sceneDepth) {
   // Activate sceneDepth
   configuration.frameSemantics = .sceneDepth
}
session.run(configuration)

 

ARFrame에 새롭게 추가 된 sceneDepth 속성보다 LiDAR에서 측정 한 깊이 데이터를 얻을 수있다.

 

func session(_ session: ARSession, didUpdate frame: ARFrame) {
   guard let depthData = frame.sceneDepth else { return }
   // Use depth data
}

 

사용 가능한 구성

ARConfiguration 프로토콜에 정의 된 frameSemantics 속성에 sceneDepth을 설정하기 때문에 API으로 사용할 수는 있지만, API 레퍼런스의 sceneDepth 절에 설명보기 한 월드 추적 이외의 구성에서 사용할 수없는스러운

 

developer.apple.com/documentation/arkit/arconfiguration/framesemantics/3516902-scenedepth

 

Apple Developer Documentation

 

developer.apple.com

 

If you enable this option on a world-tracking configuration's frameSemantics,  ARKit includes depth information for regions of the current frame's capturedImage. The world-tracking configuration exposes depth information in the sceneDepth property that it updates every frame.

하드웨어적인 제약

마찬가지로 sceneDepth 참조 페이지를 보자.

ARKit supports scene depth only on LiDAR-capable devices

 

칩이 A12 이상이나 조건은 아닌 것 같다. (LiDAR이 실리 → 필연적으로 고성능 칩이기 때문 일까)

 


<종래의 깊이 데이터와의 차이>

 

지금까지도 (특정 조건에서) ARKit 이용시 깊이 데이터 액세스하는 것은 가능했다. ARFramecapturedDepthData 속성 estimatedDepth 종래부터 있던 깊이 API입니다. 이번에 추가  깊이 API와 무엇이 다른가.

 

 

 

깊이 데이터의 종류와 취득 조건

 

우선 물론 깊이 데이터 종류가 다르다. 그리고 이에 따라 얻을 수있는 조건도 다르다. capturedDepthData True-Depth 카메라 유래 깊이 데이터에서 페이스 트래킹 이용시에만 얻을 수있다.

 

estimatedDepth는 frameSemantics에 personSegmentationWithDepth 옵션을 지정한 경우에 얻을 수있는 것으로, 듀얼 카메라와 True-Depth 카메라 유래의 깊이가 아니라 그 속성 이름에서 알 수 있듯이 추정 깊이 데이터이다. 요 A12 칩 이상.

 

sceneDepth는 상술 한 바와 같이 frameSemantics에 sceneDepth를 지정한 경우에 취득 할 수있어 AR 구성으로는 월드 추적에만 장치로 LiDAR를 탑재하고있을 필요가있다

 

 

프레임 레이트 / 생성 알고리즘의 차이

 

capturedDepthData는 True-Depth 카메라 유래의 깊이 데이터이기 때문에 ARFrame 컬러 데이터 (capturedImage 속성)보다 업데이트 빈도가 낮고, 깊이를 이용한 효과 등을 걸고있는 피사체 (페이스 트래킹이므로 자신)이 빨리 움직일 경우에 추종 할 수없는 것이 있었다.
한편 estimatedDepth은 기계 학습 기반으로 추정되며, A12 이후의 고성능 칩을 조건으로하고 있기 때문에 카메라 프레임과 동일한 프레임 속도로 업데이트된다.
sceneDepth도 LiDAR로 취득한 깊이 데이터와 광각 카메라에서 가져온 컬러 데이터를 기반으로 기계 학습 알고리즘을 이용하여 생성된다. 60fps로 동작하는, 즉 이쪽도 ARFrame를 얻을 때마다 업데이트되고있다.
(WWDC 2020의 "Explore ARKit 4"세션에서)

 

The colored RGB image from the wide-angle camera and the depth ratings from the LiDAR scanner are fused together using advanced machine learning algorithms to create a dense depth map that is exposed through the API.
(광각 카메라의 컬러 RGB 이미지와 LiDAR 스캐너에서 심도 정격이 고급 기계 학습 알고리즘을 사용하여 융합 된 API를 통해 공개되는 고밀도의 깊이 맵이 생성됩니다.)

This operation runs at 60 times per second with the depth map available on every AR frame. 
(이 작업은 초당 60 번 실행되며 AR 프레임마다 깊이 맵을 사용할 수 있습니다.)

 

형식의 차이

 

capturedDepthData AVDepthData , 

estimatedDepth CVPixelBuffer , 

그리고 sceneDepth ARDepthData 얻을 수있다.


 

<ARDepthData>

상술 한 바와 같이 sceneDepth 속성에서 얻을 수 LiDAR 유래의 깊이 데이터는 ARDepthData 형 얻을 수있다. 이곳은 iOS 14에 추가 된 새로운 클래스.

developer.apple.com/documentation/arkit/arconfiguration/framesemantics/3516902-scenedepth

 

Apple Developer Documentation

 

developer.apple.com

이것을 잘 이용한 공식 샘플이 나와 있으므로 자세한 설명은 샘플을 읽으면서 다른 기사에 쓴다.

 

 

LiDAR의 정확도 / 측정 가능한 거리는?

WWDC 2020은 아니지만, ARKit 3.5 릴리스되었을 때 "Advanced Scene Understanding in AR"라는 Tech Talk가 공개되어 있으며, 그 중 LiDAR의 정확성에 대해 언급했다.

 


The new iPad Pro comes equipped with a LiDAR Scanner. This is used to determine distance by measuring at nanosecond speeds how long it takes for light to reach an object in front of you and reflect back. This is effective up to five meters away and operates both indoors and outdoors. 

(새로운 iPad Pro는 LiDAR 스캐너가 탑재되어 있습니다. 이것은 눈앞의 물체에 빛이 도달하여 반사되어 돌아올 때까지의 시간을 나노초의 속도로 측정하여 거리를 판단 하는 데 사용됩니다. 이것은 5 미터까지 유효, 실내에서도 야외에서도 사용할 수 있습니다.)

 

LiDAR에서 몇 미터 앞까지 측정 할 것인가라는 질문을받은 적이 몇 번 있지만, 이런 것은 공식적으로 언급되지 않은 느낌 이었기 때문에, "샘플에서 실제로 시도해 보면 좋아요"라고 답변을했다. 기준해라 귀중한 공식 정보가 있으므로 참고.


 

personSegmentationWithDepth과 장면 깊이

 

ARConfiguration의 frameSemantics 속성에 personSegmentationWithDepth 옵션을 지정하는 경우, 씬 깊이를 얻을 수있는 장치라면 자동으로 장면 깊이를 얻을 수있는 것 같다.

 

let session = ARSession()
let configuration = ARWorldTrackingConfiguration()

// Set required frame semantics
let semantics: ARConfiguration.FrameSemantics = .personSegmentationWithDepth

// Check if configuration and device supports the required semantics
if type(of: configuration).supportsFrameSemantics(semantics) {
   // Activate .personSegmentationWithDepth
   configuration.frameSemantics = semantics
}
session.run(configuration)

 

게다가 추가 전력 비용도 들지 않는 것.

 

Additionally if you have an AR app that uses people occlusion feature, and then search the personSegmentationWithDepth frameSemantic, then you will automatically get sceneDepth on devices that support the sceneDepth frameSemantic with no additional power cost to your application.

 

 

smoothedSceneDepth

상술 한 sceneDepth은 WWDC 2020 개최 시점 (iOS 14 beta 1 때) 이미 공개되어 있었지만, iOS 14 beta 5에서 갑자기 smoothedSceneDepth되는 API가 추가되었다.

 

 

Shuichi Tsutsumi on Twitter

“iOS 14 beta 5でARKitにデプス系のAPIがさらに追加されたのか! 確かにARFrameにsmoothedSceneDepthなるプロパティが増えている👀 https://t.co/TwvgQ5YThr”

twitter.com

 

 

이 때 (2020 년 8 월) 문서를 바로 보러 갔는데 자세한 내용은 아무것도 쓰여지지 않았다.
지금 보러 가면 제대로 설명이 적혀있어 sceneDepth의 차이도 명기되어있다. DeepL 이용의 일본어 번역을 병기하여 여기에 정리해 둔다.

 

smoothedSceneDepth: ARConfiguration.FrameSemantics

ARConfiguration.FrameSemantics 유형 속성

developer.apple.com/documentation/arkit/arconfiguration/framesemantics/3674208-smoothedscenedepth

 

Apple Developer Documentation

 

developer.apple.com

 


An option that provides the distance from the device to real-world objects, averaged across several frames.
(장치에서 실제 객체 사이의 거리를 제공하는 옵션으로 여러 프레임에서 평균화됩니다.)

 

 

Declaration

static var smoothedSceneDepth: ARConfiguration.FrameSemantics { get }

 

Discussion

 


Enable this option on a world-tracking configuration (ARWorldTrackingConfiguration) to instruct ARKit to provide your app with the distance between the user’s device and the real-world objects pictured in the frame's capturedImage. ARKit samples this distance using the LiDAR scanner and provides the results through the smoothedSceneDepth property on the session’s currentFrame.

(월드 추적 설정 (ARWorldTrackingConfiguration)에서이 옵션을 사용하면 사용자의 장치 및 프레임 캡처 사진에 찍혀있는 실제 객체와의 거리를 응용 프로그램에 제공하도록 ARKit에 지시합니다 .ARKit은 LiDAR 스캐너를 사용하여이 거리를 샘플링 세션 currentFrame의 smoothedSceneDepth 속성을 통해 결과를 제공합니다.)

LiDAR 스캐너를 사용할 수 여기에 명기되어있다.

 


To minimize the difference in LiDAR readings across frames, ARKit processes the data as an average. The averaged readings reduce flickering to create a smoother motion effect when depicting objects with depth, as demonstrated in Creating a Fog Effect Using Scene Depth. Alternatively, to access a discrete LiDAR reading at the instant the framework creates the current frame, use sceneDepth

(프레임 간의 LiDAR 측정 값의 차이를 최소화하기 위해 ARKit은 데이터를 평균으로 처리합니다. 평균화 된 판독 값은 "장면 깊이를 사용한 안개 효과 만들기"에서 입증 된 같이 깊이있는 개체를 묘사 할 때 깜박임을 줄이고 더 부드러운 모션 효과를 만들어냅니다. 또한 프레임 워크가 현재의 프레임을 만든 순간에 개별 LiDAR 판독 값에 액세스하려면 sceneDepth를 사용합니다.)

 

여기가 제일 중요하다. sceneDepth의 차이가 명기되어 있으며, 장점과 구분도 적혀있다.

 


ARKit supports scene depth only on LiDAR-capable devices, so call supportsFrameSemantics(
:) to ensure device support before attempting to enable scene depth.

(ARKit은 LiDAR 지원 장치에서만 장면 심도를 지원하고 있기 때문에, 장면 심도를 사용하기 전에 supportsFrameSemantics (:)을 호출 해 디바이스의 지원을 확인하십시오.)

smoothedSceneDepth: ARDepthData

ARFrame의 smoothedSceneDepth 속성

 

 

Apple Developer Documentation

 

developer.apple.com


An average of distance measurements between a device's rear camera and real-world objects that creates smoother visuals in an AR experience.
(장치의 후면 카메라와 실제 객체 사이의 거리 측정의 평균치에서 AR 체험으로 더 부드러운 영상을 만들 수 있습니다.)

Declaration

var smoothedSceneDepth: ARDepthData? { get }

 

Discussion

 

his property describes the distance between a device's camera and objects or areas in the real world, including ARKit’s confidence in the estimated distance. This is similar to sceneDepth except that the framework smoothes the depth data over time to lessen its frame-to-frame delta

(이 속성은 장치의 카메라와 실제 객체와 지역과의 거리를 설명합니다. 이것은 sceneDepth와 비슷하지만 프레임 워크는 프레임 간의 차이를 줄이기 위해 심도 데이터를 시간이 지남 부드럽게합니다.)


This property is nil by default. Add the smoothedSceneDepth frame semantic to your configuration’s frameSemantics to instruct the framework to populate this value with ARDepthData captured by the LiDAR scanner.

(이 속성은 기본적으로 nil입니다. 프레임 워크에 LiDAR 스캐너에 의해 캡처 된 ARDepthData에서이 값을 입력하도록 지시하기 위해 설정 frameSemantics에 smoothedSceneDepth 프레임 시맨틱을 추가합니다.)

Call supportsFrameSemantics(:) on your app’s configuration to support smoothed scene depth on select devices and configurations.

(앱 설정에서 supportsFrameSemantics (:)을 호출하여 선택한 장치 설정에서 평활화 된 장면 심도를 지원합니다.)
반응형

+ Recent posts