CLASS
ArdkObjectDetectionSession
public final class ArdkObjectDetectionSession: ArdkSession.IDisposable, ArdkFeatureSession
Properties
classNames
public var classNames: ObjectDetectionClassNamesBuffer?
Returns the list of possible object detection classifications, if available. Reads from the currently loaded native model and returns its data.
- Returns: The list of possible object detection classifications, or
nilif not available.
Methods
modelToImageTransform(forPhysicalOrientation:)
public func modelToImageTransform(forPhysicalOrientation orientation: UIInterfaceOrientation) -> CGAffineTransform?
Returns an affine transform that maps coordinates from the model's frame to the image frame, accounting for the model image being rotated to align with gravity, while the source image is always oriented in landscape.
- Parameter orientation: The gravity aligned interface orientation.
- Returns: A
CGAffineTransformto convert model coordinates to image coordinates, ornilif the model frame size, source frame size, or orientation is unavailable.
Parameters
| Name | Description |
|---|---|
| orientation | The gravity aligned interface orientation. |
featureStatus()
public func featureStatus() -> ArdkFeatureStatus
Reports the current status of the object detection feature.
This method can be used to detect errors that have occurred within the feature’s internal processes. Once an error is flagged, it will remain flagged until the relevant process has been rerun and completed successfully.
Typical usage is to call this at the beginning of a session to check whether object detection is still initializing or if a previous failure has occurred.
- Returns: An
ArdkFeatureStatusvalue
configure(with:)
public func configure(with config: Configuration) throws
Configures the session with the specified settings.
- Attention: This method must be called while the session is stopped,
or else configuration will fail. In that case, while this function returns without
throwing, configuration will still fail asynchronously. Use
featureStatus()to check that configuration has not failed. - Parameter config: An object that defines this session's behavior. Only settings that differ from the defaults will be applied.
- Throws:
ArdkError.invalidArgumentif the configuration is invalid. Check ARDK's C logs for more information.
Parameters
| Name | Description |
|---|---|
| config | An object that defines this session’s behavior. Only settings that differ from the defaults will be applied. |
start()
public func start()
Starts the object detection session.
stop()
public func stop()
Stops the object detection session. After stopping, the session can be reconfigured and restarted.
latestDetections()
public func latestDetections() -> ArdkAsyncState<ObjectDetectionResult, AwarenessError>
Retrieves the latest object detection results from the object detection session.
- Returns: An
ArdkAsyncStatecontaining either the latestObjectDetectionResult, or anAwarenessError.
metadata()
public func metadata() -> ArdkAsyncState<ObjectDetectionMetadata, AwarenessError>
Retrieves the metadata for object detection.
- Returns: An
ArdkAsyncStatecontaining either the latestObjectDetectionMetadata, or anAwarenessError.