Skip to content

A simple library for providing Eye Position and Eye Gaze callbacks

License

Notifications You must be signed in to change notification settings

MrEdigital/YouEyeTracker

Repository files navigation

YouEyeTracker

language Version CI Status Coverage Status Platform License Twitter

A library to which an object can subscribe and receive 3D real-world-space eye-tracking position callbacks relative to the position of the front-facing camera.

Installation

TextFetcher is available through CocoaPods. To install, simply add the following line to your Podfile:

pod "YouEyeTracker"

Run:

$ pod install

And remember to add a "Camera Usage Description" to your project's info.plist, so that iOS can prompt the user for access, eg:

<key>NSCameraUsageDescription</key>
<string>Your Description Goes Here</key>

Usage

Initialization

The library's primary class is not intended for public initialization, instead providing a singleton accessor:

Interface(s):

public static let shared: YouEyeTracker = .init()

Example(s):

YouEyeTracker.shared.doSomething(...)

Configuration

YouEyeTracker is configured with a struct containing two potential parameters. The first, pointOfView, specifies the point in which the user's perspective calculations should be relative to. Possible values include [.leftEye, .rightEye, .eyeAverage]. The second, showTrackingInSceneView, (which is primarily intended for debug and demonstration purposes) populates the underlying SceneKit view with Geometry, so that tracking can be visualized should the view be presented.

Interface(s):

public struct Config {
    public init(pointOfView: Config.PointOfView? = nil, showTrackingInSceneView: Bool = false)
}

Example(s)

YouEyeTracker.shared.configure(with: Config(pointOfView: .rightEye))

Starting and Stopping

To start and stop the eye tracking processes of YouEyeTracker, you simply call its start() and stop() methods.

Interface(s)

public func start()
public func stop()

Example(s)

YouEyeTracker.shared.start() // when you're ready for it to start
YouEyeTracker.shared.stop()  // when you're ready for it to stop

Subscribing

To get any benefit from YouEyeTracker you need objects which can subscribe to its callbacks. You do this by conforming any designated class to the EyePositionSubscriber protocol.

Interface(s):

@objc public protocol EyePositionSubscriber: class {
    func eyePositionMovedTo(xPosition: Float, yPosition: Float, zPosition: Float)
    func eyeTrackingInterrupted()
}

Example(s):

extension MyClass: EyePositionSubscriber {

    func eyePositionMovedTo(position: float3?) {
        // do stuff
    }

    func eyeTrackingInterrupted() {
        // do other stuff
    }
}

Once conformed, you can pass them into its subscribe(...) method.

Interface(s)

public func subscribe(_ subscriber: EyePositionSubscriber)

Example(s)

YouEyeTracker.shared.subscribe(self)

And so long as YouEyeTracker is running the class will receive a steady stream of broadcasts.

Support

This library should work on any iOS / iPad OS device which supports ARKit Face Tracking. See ARKit documentation for a comprehensive list of such devices. (I'm assuming that such a list actually exists somewhere.)

License

This project is available under The MPL-2.0 License, with an additional Data Collection and Social Responsibility clause (3.4).
Copyright © 2020, Eric Reedy. See LICENSE file.

About

A simple library for providing Eye Position and Eye Gaze callbacks

Topics

Resources

License

Stars

Watchers

Forks