lgvv98

[ARKit] #7 frameSemantics 본문

apple/VisionOS

[ARKit] #7 frameSemantics

lgvv 2023. 8. 15. 22:14

# frameSemantics

프레임에서의 활성화된 semantic의 집합

 

: 쉽게 말하자면 사람이 있을때 물체를 가상 물체를 어떻게 보여질건지를 결정

 

var frameSemantics: ARConfiguration.FrameSemantics { get set }

 

- ARConfiguration.FrameSemantics: 앱에서 사용할 수 있는, 선택적인 프레임 기능

- 하나의 frameSemantic은 ARKit이 프레임에서 추출하는 2D 정보를 나타냄.

 

 - 2D에서 신체(body)를 추적하는 법

static var bodyDetection: ARConfiguration.FrameSemantics
// 2D에서 신체 감지가 활성화 되었음을 나태내는 옵션

 

카메라 영상에서 ARKit이 인식하는 신체의 화면 위치 정보.

var detectedBody: ARBody2D? { get }

ARBody2D란?

// 2D 공간에서 나타내는 사람의 신체 정보

 

 -사람으로 가상 컨텐츠 가리기

static var personSegmentation: ARConfiguration.FrameSemantics
// 사람들이 앱의 가상 콘텐츠를 가리고 있음을 나타내는 정보
 - discussion
 : ARKit이 카메라 피드에서 감지하는 모든 사람이 사람의 깊이에 관계없이 가상 컨텐츠를 가리도록 지정
 이 옵션이 활성화되면 사람이 가리게끔 함.


static var personSegmentationWithDepth: ARConfiguration.FrameSemantics
// 사람들의 깊이에 따라 앱의 가상 콘텐츠를 가리는 것을 나타내는 옵션
 - discussion
 : ARKit이 카메라 피드에서 감지하는 모든 사람 장면에서 사람의 깊이에 따라 가상 콘텐츠를 가리도록 지정

 

- 2D 신체 감지를 활성화

 
ARKit이 프레임에서 인식하는 사람의 2D 위치에 대한 정보를 얻으려면 bodyDetection 프레임 시맨틱을 활성화합니다
 
if let config = mySession.configuration as? ARBodyTrackingConfiguration {
    config.frameSemantics.insert(.bodyDetection)
    // Run the configuration to effect a frame semantics change.
    mySession.run(config)
}
 
 
 
- Enable People Occlusion
 
People Occlusion은 카메라 피드의 사람들이 앱의 가상 콘텐츠를 가릴 수 있도록 하는 기능.

 

가상 콘텐츠
 
사람이 가상 콘텐츠보다 카메라에 더 가까이 있을 때 사람이 앱의 가상 콘텐츠와 겹치도록 지정하기 위해서는 구성의 frame semantics에  personSegmentationWithDepth 옵션을 추가하면 된다.
 
if let config = mySession.configuration as? ARWorldTrackingConfiguration {
    config.frameSemantics.insert(.personSegmentationWithDepth)
    // Run the configuration to effect a frame semantics change.
    mySession.run(config)
}

 

 
 
장면에서 사람의 깊이에 관계없이 사람이 앱의 가상 콘텐츠와 겹치도록 지정하려면 personSegmentation frame semantic 대신 사용하세요. 이 옵션은 green-screen 시나리오(뒷 배경이 초록 그러니까 CG에서 자주보이는 그런 뒷배경)에 특히 적합.
 
green-screen

 

표준 렌더러(ARView 및 ARSCNView)는 People-Occlusion 구현. RealityKit에서 해당 예시는 아래를 참고하기

https://developer.apple.com/documentation/arkit/arkit_in_ios/camera_lighting_and_effects/occluding_virtual_content_with_people

 
 
만약 자신만의 렌더러를 구현하려면 segmentationBuffer와 estimatedDepthData를 직접 people occlusion 구현하면 된다. ARMatteGenerator는 mask를 제공한다. 
 
 
 
 
Scene Reconstruction 활성화하면 ARKit은 ARKit이 카메라 피드에서 감지할 수 있는 사람에 따라 mesh를 조정한다. ARKit은 깊이가 있거나 없는 frame scmantic으로 정의된 대로 사람과 겹치는 mesh의 모든 부분을 제거함. 
여기 예제는
 
 
 
 
 
 
 

 

 

(참고)

https://developer.apple.com/documentation/arkit/arconfiguration/3089121-framesemantics

 

frameSemantics | Apple Developer Documentation

The set of active semantics on the frame.

developer.apple.com

 

'apple > VisionOS' 카테고리의 다른 글

[ARKit] #6 ARKit in iOS  (1) 2023.08.15
[SceneKit] #5 SCNSceneRendererDelegate  (0) 2023.08.15
[SceneKit] #4 SCNAction  (1) 2023.08.13
[SceneKit] #3 Animating SceneKit Content  (0) 2023.08.13
[SceneKit] #2 Geometry 다뤄보기  (0) 2023.08.13
Comments