BcmCameraConfig

The SDK camera configuration class (BcmCameraConfig) is an optional interface. It allows you to configure camera specific parameters. The interface is for an object to be assigned to BcmScanConfig's cameraConfig property.

Interface

Swift:

public class BcmCameraConfig {

    /**
     * Set the preferred frame resolution of the Camera.
     */
    public enum CameraResolution {
        case FULL_HD
        // case WQ_HD // not supported
        case _4K

        func get() -> AVCaptureSession.Preset {
            switch self {
            case .FULL_HD:
                return AVCaptureSession.Preset.hd1920x1080
            case ._4K:
                return AVCaptureSession.Preset.hd4K3840x2160
            }
        }
    }

    /**
     * Using the camera that matches the configured device type.
     * It may be possible that the configured capture device type is not supported.
     * The fallback is builtInWideAngleCamera
     */
    public var preferredCaptureDeviceType: AVCaptureDevice.DeviceType

    /**
     * this factor is used for the fixed focus distance.
     * By default (0.0), the nearest point will used 
     * for the fixed focus distance.
     * this can be changed to a value in the range [0.0, 1.0].
     */
    let focusLensPositionFactor: Float?

    /**
     * danger, W.R.! Attempting to use a too large frame resolution 
     * could exceed the camera
     * bus' bandwidth limitation, result in gorgeous previews 
     * but the storage of garbage capture data.
     */
    let frameResolution: CameraResolution

    /**
     * the camera dpi value is mandatory for the correct image scaling.
     * the dpi value is different for each device and depends 
     * on the device camera.
     * there are pre-calculated dpi values for the most used devices in the SDK.
     * the device can be manually calibrated 
     * with the calibration API (BcmSdkScanController)
     */
    let dpi: Float?

    /**
     * set input image rotation. This parameter effects the finger detection.
     * 180.0, indicates the right side and 0 the left side of the phone.
     * Default value is 180.0
     */
    let imageInputRotation: Float

    /**
     * set to 1.0 to use the default software zoom. Valid range is in [1.0, 5.0]
     */
    let softwareZoomFactor: CGFloat

    /**
     * whether to turn on the torch/flash automatically
     * for making finger easily readable.
     */
    let isTorchInitiallyOn: Bool

    /**
     * Flag to enable or disable second person scan mode for the landscape mode.
     * In Portrait mode only first user mode is useful. When enabled, the
     * image input rotation is automatically set to `0` for the helper.
     */
    let isLandscape2ndPersonScanEnabled: Bool

    /**
     * Internal
     */
    /**
     * set to false to use continuous auto focus
     * the configuration cannot be overwritten
     */
    let focusLensPositionOn: Bool = true

    public init(
        frameResolution: CameraResolution = CameraResolution.FULL_HD,
        preferredCaptureDeviceType: AVCaptureDevice.DeviceType = .builtInUltraWideCamera,
        focusLensPositionFactor: Float? = nil,
        dpi: Float? = nil,
        imageInputRotation: Float = 0,
        softwareZoomFactor: CGFloat = 1.0,
        isTorchInitiallyOn: Bool = true,
        isLandscape2ndPersonScanEnabled: Bool = false
    ) {
        self.frameResolution = frameResolution
        self.preferredCaptureDeviceType = preferredCaptureDeviceType
        self.focusLensPositionFactor = focusLensPositionFactor
        self.dpi = dpi
        self.isLandscape2ndPersonScanEnabled = isLandscape2ndPersonScanEnabled
        self.imageInputRotation = isLandscape2ndPersonScanEnabled ? 180 : imageInputRotation
        self.softwareZoomFactor = softwareZoomFactor
        self.isTorchInitiallyOn = isTorchInitiallyOn
    }
}

Example

Swift:

let bcmCameraConfig = BcmCameraConfig(
    frameResolution: BcmCameraConfig.CameraResolution._4K,
    isTorchInitiallyOn: true,
    isLandscape2ndPersonScanEnabled: true
)

Initialize the camera config in the BcmScanConfig struct

Swift:

let bcmScanConfig = BcmScanConfig(
    cameraConfig: bcmCameraConfig
)

See Also

results matching ""

    No results matching ""