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.
IOS device - iPhone or iPadVersion of IOS >= 12.User access to cameraUser access to location (if you use speed)
First of all
import PreventLookingManagerYou can use only one manager for all the app. Just subscribe objects for notifications. Manager can be reconfigured at any time.
- Configure manager in
AppDelegate
let plmConfig = PreventLookingManagerConfig(timeout: 10,
camera: .front)
PreventLookingAppManager.configure(with: plmConfig)- 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")
}User PreventLookingManager class to create local manager. Use delegate to interract with it
- Create and configure manager in
Object
let preventLookingManager = PreventLookingManager()
let plmConfig = PreventLookingManagerConfig(timeout: 10,
camera: .front)
preventLookingManager.configure(with: plmConfig)- Set delegate for
PreventLookingManager
preventLookingManager.delegate = <some Object>- Delegate should implement
PreventLookingManagerDelegateprotocol
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)
}
}PreventLookingManager is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'PreventLookingManager'IlyasNN, ilyasolovyovr52@yandex.ru
PreventLookingManager is available under the MIT license. See the LICENSE file for more info.
