ARKit — 6. 평면(Plane) 인식하기

naljin
5 min readOct 30, 2018

--

본글은 ARKit 동영상 강의를 기반으로 작성한 글입니다. 출처는 아래에서 확인할 수 있습니다.

오역이나 잘못된 정보에 대한 수정은 언제든지 환영합니다 :)

평면 인식하기

평면을 인식하는 과정은 사실 매우 복잡하지만 Apple 이 모든 것을 처리해줬기 때문에 우리는 단 한 줄의 코드만 작성하면 평면 인식을 할 수 있음

평면(Plane)의 개념” 보러가기

  1. configuration에 planeDetection 설정

이전 viewWillAppear 에서 생성한 configuration 에 아래와 같이 설정을 하면 수평면을 인식했을때 알려줌. (vertical 은 없음)

configuration.planeDetection = .horizontal

2. sceneView에 debugOptions 달기

self.sceneView.debugOptions = [ARSCNDebugOptions.showFeaturePoints, ARSCNDebugOptions.showWorldOrigin]

실제로 무슨일이 일어나는지 확인하기 위해 sceneViewdebugOptions 추가 가능.

.showFeaturePoints — 얼마나 많은 특징점(feature points)이 존재하는지 볼 수 있음

.showWorldOrigin — 현실에 떠있는것 같은 x, y, z 좌표를 볼 수 있음

cf) showFeaturePoints: SCNDebugOptions- Display a point cloud showing intermediate results of the scene analysis that ARKit uses to track device position. available only when running ARWorldTrackingSessionConfiguration session.

showWorldOrigin: SCNDebugOptions - Display a coordinate axis visualization indicating the position and orientation of the AR world coordinate system. This visualization is available to all session configurations and session alignment options, but is most useful with a ARWorldTrackingSessionConfiguration session.

실제 구동 화면

인식되는 feature points. 이것들을 통해 평면 인식. showFeaturePoints 을 debugOptions 으로 설정해서 나타남
x, y, z 축. showWorldOrigindebugOptions 으로 설정해서 나타남

다중 평면 인식 확인

다른 높이에 있거나, 다른 질감(texture)으로 인해 여러개로 여겨지는 평면들은 다중으로 인식될 수 있음.

  1. sceneView에 label 추가
  2. renderer(_:didAdd:for:) 함수 안에 label 을 3초 동안 표시해주는 코드 추가

cf) renderer(_:didAdd:for:)- Tells the delegate that a SceneKit node corresponding to a new AR anchor has been added to the scene.

실제 구동 화면

이전 글 👈🏻

다음 글 👉🏻

출처

--

--

No responses yet