Version: 1.7.0

VayListener

The VayListener protocol contains event driven callback methods. Implementing the listener protocol allows you to receive the event data containing important information. These callbacks are called on different occasions and allow you to structure your application' logic accordingly. Usually the listener will pass a custom event object, containing the current analyser instance, as well as useful data corresponding to the occurred event. It is important to note here that there is no fixed sequence of callbacks meaning there is no guarantee that for example a VayPoseEvent is always received before a VayMetricValuesEvent. A detailed documentation about the VayListener can be found in the Swiftdocs reference.

onReady

Event: VayReadyEvent

This event is called when the analyser has successfully established a connection with the server and the exercise has been successfully configured. In order for this to happen you must first create a VayAnalyser instance, during which the client will attempt to set up a connection.

onPose

Event: VayPoseEvent

The VayPoseEvent is called when the human pose estimation analysed an image and returns the results. The event includes a VayPose, that contains the VayPoint for each VayBodyPointType.

VayPose

The key point VayPoint containing a Double for the X-coordinate, Y-coordinate and confidence score for each VayBodyPointType.

/// Body points for which a Point is received.
public enum VayBodyPointType: CaseIterable {
    case nose
    case neck
    case leftEar
    case rightEar
    case leftEye
    case rightEye
    case leftShoulder
    case rightShoulder
    case leftElbow
    case rightElbow
    case leftWrist
    case rightWrist
    case leftHip
    case rightHip
    case leftKnee
    case rightKnee
    case leftAnkle
    case rightAnkle
    case midHip
}

onMetricValues

Event: VayMetricValuesEvent

This event is called when metric values are received from the movement analysis. The event includes a list of VayMetricValues. A VayMetricValue is described by a value that belongs to a VayMetric and its confidence score.

onFeedback

Event: VayFeedbackEvent

The VayFeedbackEvent is received when a movement violation has been detected. The event contains a list of all VayFeedback, where each VayFeedback is linked to a VayMetric and includes a Key, Name, a list of possible feedback messages and an Importance categorization. Following VayFeedbackImportance categories are possible:

  • high: Mainly feedback regarding injury prevention and primary movement mechanics.
  • mediumHigh: Mainly feedback regarding secondary movement mechanics.
  • medium: Mainly feedback regarding range of motion.
  • low: Mainly feedback regarding general performance improvements which are not related to the upper categories.
  • undefined: No importance is yet defined for this feedback.

Furthermore, the enum VayFeedbackImportance implements Int which can be used to find out which case is more important, where the higher number is more important.

let first = VayFeedbackImportance.high
let other = VayFeedbackImportance.medium

let first.rawValue > other.rawValue /// true

onActivity

Event: VayActivityEvent

After every recognized activity, a VayActivityEvent provides the VayActivity and a list of all VayFeedback that were received during the activity.

The VayActivity can be one of the following:

  • VayRepetition: The exercise was completed once with a full range. The repetition summary furthermore contains the repetition TimeInterval.
  • VayAttempt: The exercise was performed but the range of motion or form deviated too much from the target exercise that it is not considered a repetition but only an attempt.

onRepetition

Event: VayRepetitionEvent

After every recognized repetition, a VayRepetitionEvent providing the TimeInterval of the repetition and a list of all VayFeedback that were duration. This event holds the same information as the onActivity event if a repetition is detected.

onError

Event: VayErrorEvent

If an error occurs, the VayErrorEvent is described by an error text. The error is further grouped into one of the following error types.

/// Errors
enum VayErrorType {
    case serverError
    case invalidInput
    case connectionError
    case timeout
    case other
}

onStop

No Event

onStop is called when the analyser has been stopped and no further images can be submitted to the server for analysis.

onSessionQualityChanged

Event: VaySessionQualityChangedEvent

The session quality quantifies the latency and the environment. If one of these subjects changes, the VaySessionQualityChangedEvent is called where the new ratings for both subjects are provided. More details how to interpret the session quality can be found on a separate page. Possible qualities are:

  • none: No quality information available yet.
  • bad: The quality may impair the movement analysis. We cannot guarantee a good performance.
  • ok: The quality is good enough to perform the movement analysis, but the accuracy can be affected.
  • good: The quality is optimal and enables the movement analysis.

onSessionStateChanged

Event: VaySessionStateChangedEvent

When the session state changes, the VaySessionStateChangedEvent is received with the new VaySessionState. The VaySessionState can be in one of the following states:

  • noHuman: No human can be recognized in the provided image.
  • positioning: The starting position has not been reached by the user.
  • exercising: The starting position was reached by the user and the exercise is running.

results matching ""

    No results matching ""