https://github.com/nsoojin/baraba
Make your UIScrollView scroll automatically when user is looking π by tracking face using ARKit and AVFoundation
https://github.com/nsoojin/baraba
arkit auto-scroll auto-scrolling avfoundation face-tracker ios ios-auto-scroll ios-face-detection ios-library swift uicollectionview uiscrollview uitableview
Last synced: about 1 month ago
JSON representation
Make your UIScrollView scroll automatically when user is looking π by tracking face using ARKit and AVFoundation
- Host: GitHub
- URL: https://github.com/nsoojin/baraba
- Owner: nsoojin
- License: mit
- Created: 2020-02-14T23:07:40.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-21T16:44:30.000Z (about 5 years ago)
- Last Synced: 2025-04-02T12:12:33.840Z (about 2 months ago)
- Topics: arkit, auto-scroll, auto-scrolling, avfoundation, face-tracker, ios, ios-auto-scroll, ios-face-detection, ios-library, swift, uicollectionview, uiscrollview, uitableview
- Language: Swift
- Homepage:
- Size: 75.5 MB
- Stars: 317
- Watchers: 10
- Forks: 27
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Baraba
>from Korean:
>
>*meaning, **Look at me***Make your UIScrollView scroll automatically when user is looking at the screen π
## Features
- [x] Automatic scrolling for your UIScrollView when user is looking at the screenπ±π
- [x] Pauses scrolling when user turns awayπ±π or when starts scrolling π
- [x] Face Tracking using ARKit or AVFoundation (Your choice!)
- [x] Adjust scrolling speed appropriate for your content
- [x] Complete [Documentation](https://soojin.ro/baraba/)
- [x] Supports iOS 11 or above## Demo
### Click below image π YouTube
[](https://www.youtube.com/watch?v=Hiojxdy_QtM)
## Installation
### CocoaPods
Baraba is available through [CocoaPods](http://cocoapods.org). To install it, simply add the following line to your Podfile:
```bash
pod 'Baraba'
```### Carthage
[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate Baraba into your Xcode project using Carthage, specify it in your `Cartfile`:
```ogdl
github "nsoojin/baraba"
```Run `carthage update` to build the framework and drag the built `Baraba.framework` into your Xcode project.
## Example
The example application is the best way to see `Baraba` in action. Simply open the `Baraba.xcodeproj` and run the `Example` scheme.
## Basic Usage
### Just three simple lines of code to get it running!
```Swift
// Probably in your view controller.
let baraba = Baraba(configuration: .automatic) // (1) Initialize Barabaoverride func viewDidLoad() {
super.viewDidLoad()
baraba.scrollView = tableView // (2) Set the scroll view for the auto-scroll target
baraba.delegate = self
}override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
baraba.resume() // (3) Resume to activate camera and start tracking user's face
}override func viewWillDisppear(_ animated: Bool) {
super.viewWillDisppear(animated)
baraba.pause() // Pause to stop accessing camera
}
```## Configuration
```Swift
let baraba = Baraba(configuration: .automatic) // Uses ARKit if supported. If not, uses AVFoundation
let baraba = Baraba(configuration: .ar)
let baraba = Baraba(configuration: .av)Baraba.isConfigurationSupported(.ar) // Check the device availability
```### What's the difference?
ARKit uses TrueDepth front camera. Not all iOS devices supports this, so refer to [device compatibility](https://developer.apple.com/library/archive/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/Cameras/Cameras.html#//apple_ref/doc/uid/TP40013599-CH107-SW1). Generally, ARKit has faster face tracking capability so reacts faster to user movement. However, it consumes more energy and may increase the device temperature when used for a long time. The best way to see the difference is to run it for youself. Try the Example app.
### Scroll Speed
You can adjust scroll speed with `preferredScrollSpeed` property, which represents speed in 'points per second'. However, the actual scroll speed will be the nearest multiple of 60. The reason is for smooth scrolling, as the device's maximum refresh rate of the display is 60 frames per second. You can check the actual speed with `actualScrollSpeed` property if you want. Default is 180.
```Swift
baraba.preferredScrollSpeed = 240 // baraba.actualScrollSpeed == 240
baraba.preferredScrollSpeed = 100 // baraba.actualScrollSpeed == 120
```### Pause Duration
When user starts dragging the scroll view, auto-scrolling pauses. After the dragging finishes, auto-scrolling resumes after this duration.
```Swift
baraba.pauseDuration = 4
```## β οΈ Important
If you want to use `BarabaConfiguration.ar` which uses ARFaceTrackingConfiguration, your app must include a privacy policy describing to users how you intend to use face tracking and face data. (See [Apple's Note](https://developer.apple.com/documentation/arkit/arfacetrackingconfiguration))
[Example #1](https://soojin.ro/notableme-privacypolicy) (This has passed the actual App Store Review.)
You can use this [sample](https://github.com/nsoojin/baraba/blob/master/etc/PRIVACY-POLICY-SAMPLE.md) at your own discretion.
Don't forget to add `Privacy - Camera Usage Description` in your app's `info.plist` file.
## FAQ
### What's the origin of the name Baraba?
Baraba(λ°λΌλ΄) is a Korean term which means "Look at me".
## Contributing
Contributions are very welcome π## License
Baraba is released under the MIT license. See [LICENCE](https://github.com/nsoojin/baraba/blob/master/LICENSE) for details.