-
Notifications
You must be signed in to change notification settings - Fork 24
arunityX on Android
artoolkitX for Unity for Android supports the same platforms as artoolkitX for Android, which includes all versions of Android from Android 7.0 (API level 24) onwards.
artoolkitX for Unity for Android uses the native Camera2 capture module introduced in artoolkitX version 1.1.10. With this new module, there is no longer a need for a an application "wrapper" to feed video from Java to native code. The SDK supports auto-configuration of the video feed, using the ARVideoConfig
component:
![ARVideoConfig settings for Android](https://private-user-images.githubusercontent.com/5752887/243222698-26dedc77-85e6-4e95-a558-1c48c270bfd7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxOTkzNjIsIm5iZiI6MTczOTE5OTA2MiwicGF0aCI6Ii81NzUyODg3LzI0MzIyMjY5OC0yNmRlZGM3Ny04NWU2LTRlOTUtYTU1OC0xYzQ4YzI3MGJmZDcucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTBUMTQ1MTAyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MjJjNTkxNzhkZTdkYjYzYmIxZTlmYjYzMzI1NmFjNjFlY2FmZjEzOWNkMmQxNGJkZWQ2Y2UzMjczODAyMmQ2NCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.xxOgD8pzw_hBKjMDmdjSSnNeGQU053_hLndigoBInyI)
Select input by: | Explanation |
---|---|
Any camera | Selects the first available camera on the device, usually the back camera. |
Nth camera | Where the device has more than one camera, this options allow selection of the "n"th camera, e.g. set to 2 to select the second camera on the device, irrespective of position. |
Camera at position | Selects the first available camera at the specified position on the device (back, i.e. facing away from the user, or front, i.e. facing towards the user) |
Nth camera at position | Where more than one camera is available at the specified position, allow selection of the camera by index, e.g. the second back-facing camera. |
Video source info list | Does a live query of the available video options while running in the Unity Editor. Not useful for Android |
Different sizes for the incoming video stream are supported. On Android, the SDK offers a variety of "size preference" strategies, that allow for fixed sizes, or dynamic selection of sizes with contraints, as follows:
Size preference | Explanation |
---|---|
Any size | Select the first available resolution offered by the device |
Exact size | Select the resolution with the width and height specified. If this resolution is not offered by the camera, opening the video stream will fail |
Closest size (same aspect ratio) | Select the resolution closest to the width and height specified, with the same aspect ratio. E.g., if the camera offers resolutions 1280x720 and 1024x768, but the user specifies 960x720 (a 4:3 aspect ratio), 1280x720 will be rejected (wrong aspect ratio of 16:9) and 1024x768 will be selected |
Closest size (pixel count) | This is the default option. Select the resolution closest to the width and height specified, as based on the total pixel count of each resolution. E.g. if the camera offers resolutions 1280x720 and 1024x768, but the user specifies 1000x1000 (i.e. 1M pixel), 1280x720 will be selected (0.9M pixel) and 1024x768 will be rejected (0.7M pixel) |
Size with aspect ratio | The first available resolution with the specified aspect ratio. |
Largest size with maximum | The largest size from the list of available resolutions, but not larger than the specified width OR height. This is a useful setting when you want to cap the resolution. |
Smallest size with minimum | The smallest size from the list of available resolutions, but not smaller than the specified width OR height. This is a useful setting when you ensure at least a certain resolution. |
Largest | The largest size from the list of available resolutions. Note that some devices may offer very large resolutions, and selecting very large sizes has a strong impact on tracking performance. |
Smallest size | The smallest size from the list of available resolutions. Note that some devices may offer very small resolutions, and potentially too small for tracking to succeed. |
Note that selecting high-resolution sizes may have a severe impact on tracking performance, and sizes of around 1 megapixel (i.e. approximately 1000x1000 pixels) have been found to provide reasonable tracking on most devices.
You can manually override the Unity Editor-specified config by checking this box, and then using config options as per the table at https://github.com/artoolkitx/artoolkitx/wiki/artoolkitX-video-module-configuration-reference#ar_video_module_android
Note that on Android, items placed in Unity Resources
folders are embedded in the application package and cannot be read directly from the filesystem without being unpacked first, whereas items placed in Unity StreamingAssets
folders are unpacked by Unity. If you have resources like images or multi-marker config files that must be read by artoolkitX natively, be sure to place them in the StreamingAssets folders, or use your own code to place them in the native filesystem before using them.
Problem | Cause | Solution or workaround |
---|---|---|