Skip to content

IlyasNN/PreventLookingManager

Repository files navigation

Icon

PreventLookingManager

Version License platform iOS

Image alt

Desription

Prevent looking manager is designed to prevent driver distraction while driving. Machine learning was used to achieve this goal. The camera tracks the driver's eyes and if he looks at the screen for a long time, a warning is triggered. Moreover, you can set the timeout and minimum speed, upon reaching which warnings will be triggered so as not to bother the user. Camera position also can be configured.

Requirements

  1. IOS device - iPhone or iPad
  2. Version of IOS >= 12.
  3. User access to camera
  4. User access to location (if you use speed)

Usage scenarios

First of all

    import PreventLookingManager
  • PreventLookingAppManager - Singletone

You can use only one manager for all the app. Just subscribe objects for notifications. Manager can be reconfigured at any time.

  1. Configure manager in AppDelegate
    let plmConfig = PreventLookingManagerConfig(timeout: 10,
                                                camera: .front)
    PreventLookingAppManager.configure(with: plmConfig)
  1. Subscribe object for notifications
        PreventLookingAppManager.shared.didGetWarning.
                                    addListener(skipCurrent: true) { [weak self] _ in
            self?.showAlert(title: "App manager notification",
                            message: "This notification is recieved from 
                            the main PreventLookingAppManager (sigleton) 
                            to which this controller is subscribed")
        }
  • PreventLookingManager - Local

User PreventLookingManager class to create local manager. Use delegate to interract with it

  1. Create and configure manager in Object
    let preventLookingManager = PreventLookingManager()
    let plmConfig = PreventLookingManagerConfig(timeout: 10,
                                                camera: .front)
    preventLookingManager.configure(with: plmConfig)
  1. Set delegate for PreventLookingManager
    preventLookingManager.delegate = <some Object>
  1. Delegate should implement PreventLookingManagerDelegate protocol
    extension <Object>: PreventLookingManagerDelegate {
    
    func gotWarning() {
        // example
        self.showAlert(title: "Local manager notification",
                       message: "This notification is recieved from local PreventLookingManager via delegate methods")
    }
    
    func gotError(_ error: Error) {
        // example
        self.showAlert(title: "Error", message: error.localizedDescription)
    }
    
}

Installation

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

pod 'PreventLookingManager'

Author

IlyasNN, ilyasolovyovr52@yandex.ru

License

PreventLookingManager is available under the MIT license. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published