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:
Truvideo SDK libs, to enable camera functionalities.
Declare Camera Launchers
In your
View Class
where you want to launch the camera, first get camera information for arCamera
let cameraInfo: TruvideoSdkCameraInformation = TruvideoSdkCamera.camera.getTruvideoSdkCameraInformation()
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).
let configuration = TruvideoSdkARCameraConfiguration(
flashMode: .on,
mode: .videoAndPicture(mediaCount: 50),
orientation: .portrait
)
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.
// on button click
viewController.presentTruvideoSdkARCameraView(
preset: configuration,
onComplete: { result in
completion(result)
})
Finalize code -
func initiateARCamera(viewController: UIViewController, _ completion: @escaping (_ cameraResult: TruvideoSdkCameraResult) -> Void) {
DispatchQueue.main.async {
// Retrieving information about the device's camera functionality.
let cameraInfo: TruvideoSdkCameraInformation = TruvideoSdkCamera.camera.getTruvideoSdkCameraInformation()
print("Camera Info:", cameraInfo)
let configuration = TruvideoSdkARCameraConfiguration(flashMode: .on,mode: .videoAndPicture(mediaCount: 50),orientation: .portrait)
DispatchQueue.main.async {
viewController.presentTruvideoSdkARCameraView(preset: configuration, onComplete: { result in
self.handle(result: result, viewController: viewController)
completion(result)
})
}
}
}
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.

Final Result

Last updated
Was this helpful?