Skip to content
On this page

Device Orientation

The SDK supports the setting of the device orientation in face measurement sessions. The orientation is determined by the application during the session creation and can be set according to the current device orientation at the time the session is created, or according to the preferred UI orientation.

The orientation is defined as the position of the native base of the device (also commonly known as the charging port location), relative to the device's current rotation. For example, if the device is rotated so its base is to the left of the user, then the orientation is defined as LANDSCAPE_LEFT.

The default device orientation is PORTRAIT. If any other orientation is requested, then it must be provided when creating a new measurement session.

In the following example, the device orientation is LANDSCAPE_LEFT:

Kotlin
try {
    val licenseDetails = LicenseDetails("<ENTER_YOUR_LICENSE_KEY>")
    val session = FaceSessionBuilder(applicationContext) 
                    .withDeviceOrientation(DeviceOrientation.LANDSCAPE_LEFT) 
                    .withImageListener(this)
                    .withVitalSignsListener(this)
                    .withSessionInfoListener(this)
                    .build(licenseDetails);
} catch (e: HealthMonitorException) {
    Log.i("ERROR", "Received Error. Domain: ${e.domain} Code: ${e.errorCode}")
}
Java
try {
    LicenseDetails licenseDetails = new LicenseDetails("<ENTER_YOUR_LICENSE_KEY>");
    Session session = new FaceSessionBuilder(getApplicationContext()) 
                    .withDeviceOrientation(DeviceOrientation.LANDSCAPE_LEFT) 
                    .withImageListener(this)
                    .withVitalSignsListener(this)
                    .withSessionInfoListener(this)
                    .build(licenseDetails);
} catch (HealthMonitorException e) {
    Log.i("ERROR", "Received Error. Domain: "+ e.getDomain() +" Code: "+ e.getErrorCode());
}

The SDK defines the possible device orientations as an enum:

Java
public enum DeviceOrientation {
    PORTRAIT,               //The power charging port is facing down
    PORTRAIT_UPSIDE_DOWN,   //The power charging port is facing up
    LANDSCAPE_LEFT,         //The power charging port is facing left
    LANDSCAPE_RIGHT         //The power charging port is facing right
}

When the device orientation differs from the requested orientation during a measurement, then:

  • The SDK will indicate that the image orientation is incorrect as part of ImageListener.
  • Images with an incorrect orientation will not be processed by the SDK.