Giter Club home page Giter Club logo

lumina's Introduction

Lumina

version-badge license-badge standard-readme compliant

A camera designed in Swift that helps take still images, detect QR/bar codes, and stream video frames for post processing.

Cameras are used frequently in iOS applications, and the creation of CoreML has precipitated a rash of applications that will want to do live object detection on a camera feed.

Writing AVFoundation code can be fun, if not sometimes interesting. Lumina gives you an opportunity to skip having to write AVFoundation code, and gives you the tools you need to do anything you need with AV capture, streaming, etc.

Lumina can:

  • capture still images
  • stream video frames to a delegate
  • scan any QR or barcode and output its metadata
  • detect the presence of a face and its location

Table of Contents

Background

David Okun has experience working with image processing, and he thought it would be a nice thing to have a camera module that allows you to stream images, capture photos and videos, and (eventually) have a module that lets you plug in a CoreML model, and it streams the object predictions back to you alongside the video frames.

Install

CocoaPods

You can use CocoaPods to install Lumina by adding it to your Podfile:

platform :ios, '10.0'
use_frameworks!

target 'MyApp' do
    pod 'Lumina'
end

Carthage

You can use Carthage to install Lumina by adding it to your Cartfile:

github "dokun1/Lumina"

Swift Package Manager

You can use Swift Package Manager to install Lumina by adding the proper description to your Package.swift file:

import PackageDescription

let package = Package(
    name: "YOUR_PROJECT_NAME",
    targets: [],
    dependencies: [
        .Package(url: "https://github.com/dokun1/Lumina.git", majorVersion: 0)
    ]
)

NB: As the Swift Package Manager continues to grow, please view its documentation here.

Manually

Clone or download this repository, and use the provided workspace to build a version of the library for your own use in any application.

Usage

NB: This repository contains a sample application. This application is designed to demonstrate the entire feature set of the library. We recommend trying this application out.

Initialization

Consider that the main use of Lumina is to present a ViewController. Here is an example of what to add inside a boilerplate ViewController:

import Lumina

We recommend creating a single instance of the camera in your ViewController as early in your lifecycle as possible with:

let camera = LuminaViewController()

Presenting Lumina goes like so:

present(camera, animated: true, completion:nil)

Remember to add a description for Privacy - Camera Usage Description in your Info.plist file, so that system permissions are handled properly.

Functionality

There are a number of properties you can set before presenting Lumina. You can set them before presentation, or during use, like so:

camera.position = .front // could also be .back
camera.streamFrames = true // could also be false
camera.textPrompt = "This is how to test the text prompt view" // assigning an empty string will make the view fade away
camera.trackMetadata = true // could also be false

Handling output

To handle any output, such as still images, video frames, or scanned metadata, you will need to make your controller adhere to LuminaDelegate and assign it like so:

camera.delegate = self

Because the functionality of the camera can be updated at runtime, all delegate functions are required.

To handle the Cancel button being pushed, which is likely used to dismiss the camera in most use cases, implement:

func cancelled(controller: LuminaViewController) {
    // here you can call controller.dismiss(animated: true, completion:nil)
}

To handle a still image being captured with the photo shutter button, implement:

func detected(controller: LuminaViewController, stillImage: UIImage) {
    // here you can take the image called stillImage and handle it however you'd like
}

To handle a video frame being streamed from the camera, implement:

func detected(controller: LuminaViewController, videoFrame: UIImage) {
    // here you can take the image called videoFrame and handle it however you'd like
}

To handle metadata being detected and streamed from the camera, implement:

func detected(controller: LuminaViewController, metadata: [Any]) {
    // here you can take the metadata and handle it however you'd like
    // you must find the right kind of data to downcast from, whether it is of a barcode, qr code, or face detection
}

Maintainers

David Okun Twitter Follow GitHub followers

Contribute

See the contribute file!

PRs accepted.

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT © 2017 David Okun

lumina's People

Contributors

dokun1 avatar

Watchers

James Cloos avatar Richard Littauer avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.