AR Camera
This document explains how to use the AR camera from a contract in an Android application using the Truvideo SDK. It provides instructions on how to launch both the standard camera and the AR camera from an activity using the TruvideoSdkArCameraContract
.
Prerequisites
Ensure you have included the necessary Truvideo SDK dependencies in your project.
Steps to Implement AR Camera Call
Initial Project Setup
Ensure that your project is correctly configured with the following libraries:
Activity Result API
to handle camera interaction.Truvideo SDK libs, to enable camera functionalities.
Declare Camera Launchers
In your
Activity
where you want to launch the camera, define the launchers for both the regular camera and the AR camera.
class YourActivity: AppCompatActivity() {
var cameraARScreenLauncher : ActivityResultLauncher<TruvideoSdkCameraConfiguration>?=null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
cameraARScreenLauncher = registerForActivityResult(TruvideoSdkArCameraContract()) { result: List<TruvideoSdkCameraMedia> ->
// Handle result
}
//...rest of your code
}
}
Camera Configuration
Define the camera configuration using
TruvideoSdkCameraConfiguration
. In this example, we set a video and picture capture mode with specific constraints (max videos, photos, and duration limits).
var configuration: TruvideoSdkCameraConfiguration = TruvideoSdkCameraConfiguration(
outputPath = outputPath,
mode = TruvideoSdkCameraMode.videoAndPicture(
videoMaxCount = 10,
pictureMaxCount = 2,
durationLimit = 3 * 1000
)
)
Calling the Camera
Inside the UI, you can add buttons that launch both the regular camera and the AR camera. Here’s how you can open the AR camera when the user taps the corresponding button.
button.setOnClickListener {
cameraARScreenLauncher.launch(configuration)
}
This button will trigger the AR camera using the previously defined configuration.
AR Mode states
Inside the ARCamera module, we have 3 AR Mode States: Object (arrow), Ruler and Record. By default we will have an AR Cursor and the AR Mode RULER.
OBJECT: Allows the user to add a 3D Object on the AR Cursor, in this case an arrow.
RULER: Allows the user to meter with our AR Ruler a determined 3D space.
RECORD: Hiddens the AR Cursor so we can focus on the media recording.

AR Camera Validations
Inside the ARCamera module, we validate whether the device supports or has ARCore installed, in those case scenarios, we have 2 values that can return that information:
isAugmentedRealitySupported
: This property determines whether the device's hardware supports ARCore. It is essential to validate this before attempting any augmented reality operations, as trying to use ARCore on an unsupported device will result in runtime errors or unexpected behavior.isAugmentedRealityInstalled
: This property checks whether the ARCore services are installed on the device. Even if the device supports ARCore, it may not have the required services installed. By verifying this property, developers can avoid runtime issues by prompting users to install ARCore if necessary.
import com.truvideo.sdk.camera.TruvideoSdkCamera
...
val ARCoreSupported = TruvideoSdkCamera.isAugmentedRealitySupported
val ARCoreInstalled = TTruvideoSdkCamera.isAugmentedRealityInstalled
Final Result

AR Camera Limitations
During the development of AR experiences using ARCore, it's common to require control over the camera resolution — for high-quality recordings, image processing, or performance (low resolution videos with 720p). However, ARCore restricts direct control over the camera resolution during an AR session, which can lead to confusion or misaligned expectations among developers. ARCore internally does not allow the user to change the camera session if it's too low for ARCore (minimum currently on our tests was 1080p) or if the device itself does not allow it.
📚 Official References and Sources about limitations
ARCore CameraConfig Documentation Describes camera configuration options and limitations:
GitHub Issues in ARCore SDK The ARCore team has clarified that resolution control is not supported due to architectural constraints:
AR Camera Recommendations
Do not assume Camera2-like behavior when working with ARCore’s camera stream.
Avoid restarting the AR session solely to apply a different resolution — this often leads to crashes or resource leaks.
Always validate the selected
CameraConfig
, but understand that ARCore may internally override it to ensure tracking quality.
Last updated
Was this helpful?