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 landscapeLeft.

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 landscapeLeft:

Swift
do {
    let licenseDetails = LicenseDetails(licenseKey: "<ENTER_YOUR_LICENSE_KEY>")
    let session = try FaceSessionBuilder() 
        .withDeviceOrientation(.landscapeLeft) 
        .withImageListener(self)
        .withVitalSignsListener(self)
        .withSessionInfoListener(self)
        .build(licenseDetails: licenseDetails)
}
catch {
    let e = error as NSError
    print("Received Error. Domain: \(e.domain) Code: \(e.code)")
}
Objective-c
BNHLicenseDetails *licenseDetails = [[BNHLicenseDetails alloc] initWithLicenseKey:@"<ENTER_YOUR_LICENSE_KEY>"];
BNHFaceSessionBuilder *sessionBuilder = [[[[[[BNHFaceSessionBuilder alloc] init] 
                                     withDeviceOrientation:BNHDeviceOrientationLandscapeLeft] 
                                    withImageListener:self]
                                   withVitalSignsListener:self]
                                  withSessionInfoListener:self];


NSError *error = nil;
id<BNHSession> _Nullable session = [sessionBuilder buildWithLicenseDetails:licenseDetails
                                                                     error:&error];
if (error != nil) {
    NSLog(@"Received Error. Domain: %@ Code: %ld", error.domain, (long)error.code);
}

The SDK defines the possible device orientations as an enum:

Swift
public enum DeviceOrientation: Int {
    case portrait               //The power charging port is facing down
    case portraitUpsideDown     //The power charging port is facing up
    case landscapeLeft          //The power charging port is facing left
    case landscapeRight         //The power charging port is facing right
}
Objective-c
typedef NS_ENUM(NSInteger, BNHDeviceOrientation) {
    BNHDeviceOrientationPortrait,           //The power charging port is facing down
    BNHDeviceOrientationPortraitUpsideDown, //The power charging port is facing up
    BNHDeviceOrientationLandscapeLeft,      //The power charging port is facing left
    BNHDeviceOrientationLandscapeRight      //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.