Swift API¶
Classes¶
FaceCapture¶
Library object that manages all other Face Capture API classes.
Dispose¶
Description: Dispose the FaceCapture object. This will free the memory used by the native library. Calling dispose will invalidate this object and all objects created by it. Attempting to use any functions with this or any other invalidated object will result in the NULL_FACE_CAPTURE_OBJ error being thrown.
Function Definition:
func dispose() -> Void
Returns: None
Throws: None
Workflow Create¶
Description: Create a Workflow object using a workflow name. The Workflow object will become invalid if the FaceCapture used to create it is disposed.
Function Definition:
func workflowCreate(workflowName: String) throws -> Workflow
Parameter Name | Parameter Type | Description |
---|---|---|
workflowName | String | Name of the workflow to create |
Returns: A new Workflow object.
- Throws:
- NULL_FACE_CAPTURE_OBJ - The FaceCapture object has been invalidated by dispose() and cannot be used.
- UNKNOWN_WORKFLOW - The workflowName specified did not match any of the valid workflow names. Please see the Constants section for the list of valid names.
Get Camera List¶
Description: Get a list of available Camera objects. Use CameraPosition.FRONT to get all “selfie”/front facing cameras. Use CameraPosition.BACK to get all cameras on the back of the device.
Function Definition:
func getCameraList(position: CameraPosition) throws -> [Camera]
Parameter Name | Parameter Type | Description |
---|---|---|
position | CameraPosition | Position of the cameras on the device |
Returns: An array of Cameras for the camera position specified.
- Throws:
- NULL_FACE_CAPTURE_OBJ - The FaceCapture object has been invalidated by dispose() and cannot be used.
- INVALID_CAMERA_POSITION - The position value specified was not a valid CameraPosition.
Start Capture Session¶
Description: Start a capture session using the specified Workflow and Camera objects. While capturing, you cannot modify either object until the capture session ends. A capture session can end via a stopCaptureSession() call, if the capture session timeout expires, if there is a hardware issue, or if it captures successfully.
Function Definition:
func startCaptureSession(workflowHandle: Workflow, cameraHandle: Camera) throws -> Void
Parameter Name | Parameter Type | Description |
---|---|---|
workflowHandle | Workflow | Workflow containing settings for the capture session |
cameraHandle | Camera | Camera to be used in the capture session |
Returns: None
- Throws:
- NULL_FACE_CAPTURE_OBJ - The FaceCapture object has been invalidated by dispose() and cannot be used.
- INVALID_WORKFLOW - The Workflow object has been invalidated by dispose() and cannot be used.
- INVALID_CAMERA - The Camera object has been invalidated by dispose() and cannot be used.
- NO_CAPTURE_PROFILE - The CAPTURE_PROFILE WorkflowProperty was not specified. A valid CAPTURE_PROFILE must be set.
- INVALID_CAPTURE_PROFILE - The CAPTURE_PROFILE WorkflowProperty specified was not profile valid XML.
Stop Capture Session¶
Description: Stop the current capture session. If there is no capture session running, this is a no-op. The next CaptureState will contain the STOPPED CaptureSessionStatus indicating that the session has successfully stopped. The Frame will not be retrievable and the Feedback may be safely ignored from this CaptureState.
Function Definition:
func stopCaptureSession() throws -> Void
Returns: None
- Throws:
- NULL_FACE_CAPTURE_OBJ - The FaceCapture object has been invalidated by dispose() and cannot be used.
Get Capture Session State¶
Description: Blocking function that retrieves the capture session state object.
Function Definition:
func getCaptureSessionState() throws -> CaptureState
Returns: A new CaptureState object.
- Throws:
- NULL_FACE_CAPTURE_OBJ - The FaceCapture object has been invalidated by dispose() and cannot be used.
- INVALID_CAPTURE_STATE - The capture state is invalid.
Get Server Package¶
Description: Get the JSON server package as a string value.
Function Definition:
func getServerPackage(workflowHandle: Workflow, packageType: PackageType) throws -> String
Parameter Name | Parameter Type | Description |
---|---|---|
workflowHandle | Workflow | Workflow containing settings for the capture session |
packageType | PackageType | The requested package type. |
Returns: The string representation of the JSON server package.
- Throws:
- NULL_FACE_CAPTURE_OBJ - The FaceCapture object has been invalidated by dispose() and cannot be used.
- CAPTURE_SESSION_UNAVAILABLE - There are no capture sessions currently running
Get Encrypted Server Package¶
Description: Get the encrypted JSON server package as a string value.
Function Definition:
func getEncryptedServerPackage(encryptionType: EncryptionType, encryptionKey: String, workflowHandle: Workflow, packageType: PackageType) throws -> String
Parameter Name | Parameter Type | Description |
---|---|---|
encryptionType | EncryptionType | Type of encryption |
encryptionKey | String | String containing encryption key |
workflowHandle | Workflow | Workflow object containing settings for the capture session |
packageType | PackageType | Type of JSON request package |
Returns: The string representation of the encrypted JSON server package.
- Throws:
- NULL_FACE_CAPTURE_OBJ - The FaceCapture object has been invalidated by destroy() and cannot be used.
- INVALID_WORKFLOW - The Workflow object has been invalidated by destroy() and cannot be used.
- INVALID_ENCRYPTION_TYPE - The EncryptionType enumeration is not a valid type and cannot be used.
- INVALID_ENCRYPTION_PUBLIC_KEY - The String containing the encryption key is not a valid key and cannot be used.
- CAPTURE_SESSION_UNAVAILABLE - There has not been a successfully completed capture session. No data available.
Get Captured Image¶
Description: Retrieves the stored capture image from the given Workflow.
Function Definition:
func getCapturedImage( workflow: Workflow ) throws -> [UInt8]
Parameter Name | Parameter Type | Description |
---|---|---|
workflow | Workflow | Specified workflow to retrieve a capture image from. |
Returns: The capture image that was retrieved from the Workflow. The image is returned as a JPG.
- Throws:
- NULL_FACE_CAPTURE_OBJ - The FaceCapture object has been invalidated by destroy() and cannot be used.
- INVALID_WORKFLOW - The Workflow object has been invalidated by destroy() and cannot be used.
- CAPTURE_SESSION_UNAVAILABLE - There has not been a successfully completed capture session. No data available.
Get Capture Session Region of Interest¶
Description: Get the area where the user’s face is expected for a capture to occur for the current capture session.
Function Definition:
func captureSessionGetCaptureRegion() throws -> CGRect
Returns: A rectangle defining the region where the face will be captured. The region is a rectangle is defined by a point (x,y) at the upper left corner along with a width and height.
- Throws:
- NULL_FACE_CAPTURE_OBJ - The FaceCapture object has been invalidated by dispose() and cannot be used.
- CAPTURE_SESSION_UNAVAILABLE - There are no capture sessions currently running
Capture Session Enable Autocapture¶
Description: Enable or disable the autocapture for the capture session. If there is no capture session running, this is a no-op.
Function Definition:
func captureSessionEnableAutocapture(enableAutocapture: Bool) throws -> Void
Parameter Name | Parameter Type | Description |
---|---|---|
enableAutocapture | Boolean | Boolean value on whether to enable autocapture |
Returns: None
- Throws:
- NULL_FACE_CAPTURE_OBJ - The FaceCapture object has been invalidated by dispose() and cannot be used.
Get Version¶
Description: Get the Face Capture SDK version as an integer value.
Function Definition:
static func getVersion() throws -> Int32
Returns: The integer representation of the Face Capture SDK version in AABBCCDD format.
- AA is the major version
- BB is the minor version
- CC is the bug fix version
- DD is the build version
Throws: None
Get Version String¶
Description: Get the Face Capture SDK version as a string value.
Function Definition:
static func getVersionString() throws -> String
Returns: The string representation of the Face Capture SDK version.
Throws: None
CaptureState¶
Library object that abstracts the Face Capture Capture State.
Dispose¶
Description: Dispose the CaptureState object. This will free the memory used by the native library. Calling dispose will invalidate this object. Attempting to use any functions with this invalidated CaptureState will result in the NULL_FACE_CAPTURE_OBJ or INVALID_CAPTURE_STATE error being thrown.
Function Definition:
func dispose() -> Void
Returns: None
- Throws:
- NULL_FACE_CAPTURE_OBJ - The FaceCapture object has been invalidated by dispose() and cannot be used.
- INVALID_CAPTURE_STATE - The CaptureState object has been invalidated by dispose() and cannot be used.
Get Capture Session Status¶
Description: Retrieves the most recent status update from the capture session.
Function Definition:
func getCaptureSessionStatus() throws -> CaptureSessionStatus
Returns: The most recent status update from the capture session. See the CaptureSessionStatus enumeration descriptions for details.
- Throws:
- NULL_FACE_CAPTURE_OBJ - The FaceCapture object has been invalidated by dispose() and cannot be used.
Get Capture Session Frame¶
Description: Blocking function that retrieves the most recent preview frame from the capture session. If there is no capture session in progress, this function will throw the CAPTURE_SESSION_UNAVAILABLE error.
Function Definition:
func getCaptureSessionFrame() throws -> [UInt8]
Returns: A byte array containing a preview frame from the capture session. The frame is in JPG format. The frame is either 480x640 in portrait mode or 640x480 in landscape mode.
- Throws:
- NULL_FACE_CAPTURE_OBJ - The FaceCapture object has been invalidated by dispose() and cannot be used.
- CAPTURE_SESSION_UNAVAILABLE - There are no capture sessions currently running.
Get Capture Session Feedback¶
Description: Retrieves the most recent preview feedback from the capture session. If there is no capture session in progress, this function will throw the CAPTURE_SESSION_UNAVAILABLE error.
Function Definition:
func getCaptureSessionFeedback() throws -> AutoCaptureFeedback
Returns: The most recent AutoCaptureFeedback update from the capture session. See the AutoCaptureFeedback enumeration descriptions for more details.
- Throws:
- NULL_FACE_CAPTURE_OBJ - The FaceCapture object has been invalidated by dispose() and cannot be used.
- CAPTURE_SESSION_UNAVAILABLE - There are no capture sessions currently running.
Workflow¶
Workflow object used to store capture session configurations.
Dispose¶
Description: Dispose the Workflow object. This will free the memory used by the native library. Calling dispose will invalidate this object. Attempting to use any functions with this invalidated Workflow will result in the NULL_FACE_CAPTURE_OBJ or INVALID_WORKFLOW error being thrown.
Function Definition:
func dispose() -> Void
Returns: None
Throws: None
Set Property Double¶
Description: Set a double property value for the specified workflow property. Attempting to set a non-double property will result in a WORKFLOW_PROPERTY_TYPE_MISMATCH error being thrown. See the WorkflowProperty enumeration descriptions for more details.
Function Definition:
func setPropertyDouble(property: WorkflowProperty, value: Double) throws -> Void
Parameter Name | Parameter Type | Description |
---|---|---|
property | WorkflowProperty | Workflow property having its value set |
value | double | New value for the specified workflow property |
Returns: None
- Throws:
- NULL_FACE_CAPTURE_OBJ - The FaceCapture object has been invalidated by dispose() and cannot be used.
- INVALID_WORKFLOW - The Workflow object has been invalidated by dispose() and cannot be used.
- INVALID_WORKFLOW_PROPERTY - The property value was not a valid WorkflowProperty.
- WORKFLOW_PROPERTY_TYPE_MISMATCH - The property value specified does not accept a double value.
Set Property String¶
Description: Set a string property vlaue for the specified workflow property. Attempting to set a non-string property will result in a WORKFLOW_PROPERTY_TYPE_MISMATCH error being thrown. See the WorkflowProperty enumeration descriptions for more details.
Function Definition:
func setPropertyString(property: WorkflowProperty, value: String) throws -> Void
Parameter Name | Parameter Type | Description |
---|---|---|
property | WorkflowProperty | Workflow property having its value set |
value | String | New value for the specified workflow property |
Returns: None
- Throws:
- NULL_FACE_CAPTURE_OBJ - The FaceCapture object has been invalidated by dispose() and cannot be used.
- INVALID_WORKFLOW - The Workflow object has been invalidated by dispose() and cannot be used.
- INVALID_WORKFLOW_PROPERTY - The property value was not a valid WorkflowProperty.
- WORKFLOW_PROPERTY_TYPE_MISMATCH - The property value specified does not accept a String value.
Camera¶
Camera object used to store capture session configurations.
Dispose¶
Description: Dispose the Camera object. This will free the memory used by the native library. Calling dispose will invalidate this object. Attempting to use any functions with an invalidated Camera will result in the NULL_FACE_CAPTURE_OBJ or INVALID_CAMERA error being thrown.
Function Definition:
func dispose() -> Void
Returns: None
Throws: None
Get Name¶
Description: Get the name of the Camera.
Function Definition:
func getName() throws -> String
Returns: String containing the name of the Camera.
- Throws:
- NULL_FACE_CAPTURE_OBJ - The FaceCapture object has been invalidated by dispose() and cannot be used.
- INVALID_CAMERA - The Camera object has been invalidated by dispose() and cannot be used.
Set Orientation¶
Description: Set the orientation of the camera. This will affect how the capture session expects the camera to be oriented. See the CameraOrientation enumeration descriptions for more details.
Function Definition:
func setOrientation(orientation: CameraOrientation) throws -> Void
Parameter Name | Parameter Type | Description |
---|---|---|
orientation | CameraOrientation | New camera orientation for this camera to be used in capture sessions |
Returns: None
- Throws:
- NULL_FACE_CAPTURE_OBJ - The FaceCapture object has been invalidated by dispose() and cannot be used.
- INVALID_CAMERA - The Camera object has been invalidated by dispose() and cannot be used.
- INVALID_CAMERA_ORIENTATION - The orientation specified was not a valid CameraOrientation.
- CAMERA_IN_USE - The Camera is currently in use in a capture session and cannot be modified.