Make your UIScrollView scroll automatically when user is looking πŸ‘€ by tracking face using ARKit and AVFoundation

Overview

Baraba

from Korean:

meaning, Look at me

Swift 5.0 Version Platform Carthage Compatible

Make your UIScrollView scroll automatically when user is looking at the screen πŸ‘€

Features

  • Automatic scrolling for your UIScrollView when user is looking at the screen πŸ“± πŸ‘€
  • Pauses scrolling when user turns away πŸ“± πŸ™„ or when starts scrolling πŸ‘†
  • Face Tracking using ARKit or AVFoundation (Your choice!)
  • Adjust scrolling speed appropriate for your content
  • Complete Documentation
  • Supports iOS 11 or above

Demo

Click below image πŸ‘‰ YouTube

Baraba Demo

Installation

CocoaPods

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

pod 'Baraba'

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:

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!

// Probably in your view controller.
let baraba = Baraba(configuration: .automatic) // (1) Initialize Baraba

override 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

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. 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.

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.

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)

Example #1 (This has passed the actual App Store Review.)

You can use this sample 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 for details.

You might also like...
An iOS Framework Capture & record ARKit videos πŸ“Ή, photos πŸŒ„, Live Photos πŸŽ‡, and GIFs πŸŽ†.
An iOS Framework Capture & record ARKit videos πŸ“Ή, photos πŸŒ„, Live Photos πŸŽ‡, and GIFs πŸŽ†.

An iOS Framework that enables developers to capture videos πŸ“Ή , photos πŸŒ„ , Live Photos πŸŽ‡ , and GIFs πŸŽ† with ARKit content.

ARKit + CoreLocation: Combines the high accuracy of AR with the scale of GPS data.
ARKit + CoreLocation: Combines the high accuracy of AR with the scale of GPS data.

ARKit: Uses camera and motion data to map out the local world as you move around. CoreLocation: Uses wifi and GPS data to determine your global locati

ARKit Demo Application
ARKit Demo Application

ARKitNavigationDemo Work in progress. In Progress Region β€” For one, we could render far fewer nodes. In fact, it’s a bit distracting that the entire t

ARKit Base Project. Place virtual objects based on WWDC example project
ARKit Base Project. Place virtual objects based on WWDC example project

ARKit - Placing Virtual Objects in Augmented Reality Learn best practices for visual feedback, gesture interactions, and realistic rendering in AR exp

Power! Unlimited power for ARKit 2.0!
Power! Unlimited power for ARKit 2.0!

A long time ago in a galaxy, far, far away... It is a period when iPhone SE and iPhone X were destroyed from the apple store, the AR market was under

A simple application created for educational purposes for mastering ARKit
A simple application created for educational purposes for mastering ARKit

ARDrawing AR Drawing is a simple application created for educational purposes for mastering ARKit. The basis of the project is copied from the project

Trying TDD with ARKit
Trying TDD with ARKit

ARPlacer BDD Spec As a user I want to place a random object in real world. I also want to see the distance between AR object and my phone. Use Cases

Draw VR content over live camera feed with ARKit

funny-ar Exercise with ARKit: draw VR content over live camera feed: work is in

ARKit: Projecting 3D mesh to 2D coordinate
ARKit: Projecting 3D mesh to 2D coordinate

ARKitDemo ARKit: Projecting 3D mesh to 2D coordinate A simple utility to project 3D face mesh in 2D coordinate on device screen. Sources: https://deve

Owner
Soojin Ro
Swift & iOS & Flutter
Soojin Ro
A library that allows you to generate and update environment maps in real-time using the camera feed and ARKit's tracking capabilities.

ARKitEnvironmentMapper Example To run the example project, clone the repo, and run pod install from the Example directory first. Installation ARKitEnv

SV Hawks 91 Dec 4, 2022
Augmented Reality image tracking with SwiftUI, RealityKit and ARKit 4.

ARImageTracking This is an Augmented Reality Xcode project that uses Apple's newest RealityKit framework and ARKit 4 features, to dynamically track a

Richard Qi 198 Dec 7, 2022
Sample iOS AR app that demonstrates how to capture the texture of a user's face in realtime.

Sample iOS AR app that demonstrates how to capture the texture of a user's face in realtime. This texture can be used to create a simple textured 3D face model.

Matt Bierner 58 Dec 14, 2022
Caffeine tracking for everyone

Cortado Cortado is an iPhone app to help you track your caffeine consumption habits. Besides letting you manually enter caffeine data, it detects when

Emilia 169 Oct 16, 2022
Using ARKit and LiDAR to save depth data and export point cloud, based on WWDC20-10611 sample code

Save iOS ARFrame and Point Cloud This project improves the usability of the sample code from WWDC20 session 10611: Explore ARKit 4. Note that the samp

null 4 Dec 22, 2022
ARDicee - Simple augmented reality app using SceneKit and ARKit

ARDicee Simple augmented reality app using SceneKit and ARKit Requirements Xcode

donggyu 3 Feb 4, 2022
AR Ruler - A simple iOS app made using ARKit and SceneKit

A simple iOS app made using ARKit and SceneKit.Which can try to simplify little things in your life such as measuring stuff.

Dishant Nagpal 5 Aug 31, 2022
IOS example app to generate point clouds in ARKit using scenedepth

Visualizing a Point Cloud Using Scene Depth Place points in the real-world using the scene's depth data to visualize the shape of the physical environ

Isak Diaz 20 Oct 31, 2022
PlacenoteSDK Sample app in native iOS using ARKit, written primarily in Swift

Placenote SDK for iOS Placenote SDK lets you easily build cloud-based Augmented Reality (AR) apps that pin digital content to locations in the real wo

Placenote 93 Nov 15, 2022
ARID - Augmented Reality app using Apple’s ARKit framework which can recognise faces of famous scientists

ARID Augmented Reality app using Apple’s ARKit framework which can recognise fac

Hemanth 0 Jan 12, 2022