-
ARCore Geospatial API #2 [Android (Kotlin/자바)] API 사용법ARcore/Geospatial 2024. 2. 27. 17:58
https://developers.google.com/ar/develop/java/geospatial/quickstart
Android용 지리정보 빠른 시작 | ARCore | Google for Developers
이 페이지는 Cloud Translation API를 통해 번역되었습니다. 의견 보내기 Android용 지리정보 빠른 시작 컬렉션을 사용해 정리하기 내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요. 브라우저에
developers.google.com
요구사항 확인
1. 최신 버전의 AR용 Google Play 서비스
2. Android SDK Version 7.0 (API 24) 이상
3. Android Studio Version 3.0 이상
사용 환경
1. Android SDK Version 12.0 (API 31)
2. 갤럭시 노트 10+ 디바이스 사용
3. Android Studio Hedgehog | 2023.1.1 Patch 2
SDK 다운로드
1. 아래 링크에서 GitHub zip 다운로드
https://github.com/google-ar/arcore-android-sdk
GitHub - google-ar/arcore-android-sdk: ARCore SDK for Android Studio
ARCore SDK for Android Studio. Contribute to google-ar/arcore-android-sdk development by creating an account on GitHub.
github.com
2. 혹은 클론 명령어 복사
git clone https://github.com/google-ar/arcore-android-sdk.git
SDK 실행
1. 파일 구조
common 공용 샘플 소스 └ helpers └ CameraPermissionHelper 기기 CAMERA 사용권한 부여 └ DepthSettings terrainAnchor를 배치하기 위해 depth 정보를 활용 └ DisplayRotationHelper 기기의 센서값을 기준으로 회전 값에 대한 화면의 뷰포트 값을 반환 └ EisSettings 디바이스의 이미지 흔들림 보정 └ FullScreenHelper 안드로이드 디바이스 전체화면 적용 └ InstantPlacementSettings 기기를 이동하지 않고도 지형 표면을 파악하여 AR 객체를 즉시 배치가 가능함 └ LocationPermissionHelper 디바이스 위치 권한 부여 └ SnackbarHelper 에러 메세지창 및 해제된 코드에 대한 스낵바 출력 └ TapHelper 터치와 같은 모션 이벤트를 감지 └ TrackingStateHelper AR 추적 상태 감지 samplerender └ ARCore └ BackgroundRenderer AR 카메라 배경을 렌더링 한다. 여기서 렌더링 정보는 깊이 값을 참조할 수 있음 └ PlaneRenderer ARCore 평면의 렌더링을 제어
평면 감지를 시각화, 그림자 설정이 가능└ SpecularCubemapFilter 큐브맵을 통해 반사광이나 주변 환경을 캡쳐 └ Framebuffer 단일 카메라 및 멀티 카메라 프레임의 버퍼링 지원, 일관된 프레임 속도로 렌더링 지원 가능 └ GLError OpenGL error └ GpuBuffer 카메라의 비디오 프레임은 GpuBuffer 패킷으로 전달 └ IndexBuffer VertexBuffer에 종류별로 인덱싱을 하여 인덱스 데이터를 보관하는 버 └ Mesh 3D 오브젝트의 메쉬 render └ SampleRender OpenGL을 사용하여 화면 출력 └ Shader Blend 및 shader └ Texture Texture 설정 └ VertexBuffer 정점의 정보를 저장해두는 버퍼 geospatial └ GeospatialActivity Geospatial API 기능을 활용 └ PrivacyNoticeDialogFragment 개인정보보호정책 └ VpsAvailabilityNoticeDialogFragment VPS의 상태에 대해 체크해주는 부분 2. Android studio에서 다운로드한 ARCore 폴더의 samples > geospatial_java 프로젝트 열기
API 인증
1. Google Cloud에서 ARCore Api key를 발급받는다.
https://console.cloud.google.com/apis/
Google 클라우드 플랫폼
로그인 Google 클라우드 플랫폼으로 이동
accounts.google.com
2. ARCroe API KEY를 복사한 뒤 manifests > AndroidManifest.xml 파일에다가 작성
<meta-data android:name="com.google.android.ar.API_KEY" android:value="API 키 값 복사 "/>
% API KEY를 발급받지 않거나 소스를 넣지 않을 경우 아래와 같이 API를 체크하라고 하거나 VPS를 잡지 못한다고 나온다.
샘플 앱 테스트
1. 상단 검은 화면에서 아래 정보가 실시간으로 출력
LAT/LNG (위도, 경도)
ACCURACY (정확도)
ALTITUDE (고도)
ACCURACY (정확도)
ORIENTATION (방향)
YAW ACCURACY (방향 정확도)
- WGS84에 맞추어 위도와 경도 표시
- 방향은 X+ (동쪽), Y+(위쪽), Z+(남쪽)
- 정확도 간격이 작을수록 신뢰도가 높으며, 간격이 클수록 신뢰도가 낮다.
https://developers.google.com/ar/reference/java/com/google/ar/core/GeospatialPose
GeospatialPose | ARCore | Google for Developers
Send feedback GeospatialPose Stay organized with collections Save and categorize content based on your preferences. Describes a specific location, elevation, and orientation relative to Earth. It is comprised of: Latitude and longitude are specified in deg
developers.google.com
앵커 정확도 조정
GeospatialActivity.java 에서 정확도를 조정하여 앵커를 배치할 수 있다.
HORIZONTAL과 HEADING 값에 대해 값이 변경 가능하며 값이 낮을수록 정확도가 높아진다.
하지만 설정한 값보다 값이 작거나 같지 않을 경우 앵커를 배치할 수 없다.
// The thresholds that are required for horizontal and heading accuracies before entering into the // LOCALIZED state. Once the accuracies are equal or less than these values, the app will // allow the user to place anchors. private static final double LOCALIZING_HORIZONTAL_ACCURACY_THRESHOLD_METERS = 10; private static final double LOCALIZING_HEADING_ACCURACY_THRESHOLD_DEGREES = 15;
참고문헌
"Place objects instantly", 2023년12월7일 수정, 2024년2월27일 접속, https://developers.google.com/ar/develop/instant-placement
"Snackbar", Android Developer, 2023년12월15일 수정, 2024년2월27일 접속, https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar
"EIS quickstart for Android", ARCore, 2023년12월7일 수정, 2024년2월27일 접속, https://developers.google.com/ar/develop/java/electronic-image-stabilization/quickstart.
"[안드로이드] Dialog와 DialogFragment", 티스토리, 2021년7월8일 수정, 2024년2월27일 접속, https://bb-library.tistory.com/258
"[Android] Fragment 1 — Fragment의 이해와 생성", medium, 2021년4월4일 수정, 2024년2월27일 접속, https://medium.com/depayse/android-fragment-1-fragment%EC%9D%98-%EC%9D%B4%ED%95%B4%EC%99%80-%EC%83%9D%EC%84%B1-5cbfdc9b7f7c
"VpsAvailability", ARCore, 2023년6월28일 수정, 2024년2월27일 접속, https://developers.google.com/ar/reference/java/com/google/ar/core/VpsAvailability.
"버텍스 버퍼 ( Vertex Buffer ) 와 인덱스 버퍼 ( Index Buffer ), 버텍스의 Lock(), UnLock()", 네이버블로그, 2013년12월4일 수정, 2024년2월27일 접속, https://m.blog.naver.com/jsjhahi/199981820.
"[Learn OpenGL 번역] 5-3. 고급 OpenGL - Blending", 티스토리, 2018년8월7일 수정, 2024년2월27일 접속, https://heinleinsgame.tistory.com/26.
'ARcore > Geospatial' 카테고리의 다른 글
ARCore Geospatial API #1 기본 이해 (0) 2024.02.26