Latest 0.3.0
Homepage https://github.com/coverfy/KirschScanner
License MIT
Platforms ios 9.0
Authors

CI Status
Version
License
Platform

Kirsch is an elegant and simple scanner library to automatically scan documents and crop them.

Features

  • [x] Automatic and manual document capture
  • [x] Color and black and white filter
  • [x] Border cropping

Example

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

Requirements

  • iOS 9.0+
  • Xcode 8.1, 8.2, 8.3, and 9.0
  • Swift 3.0, 3.1, 3.2, and 4.0

Installation

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

pod "Kirsch"

Usage

Initialize and configure the scanner

To initialize the scanner simply call it’s initilaizer with the desired options.

  • videoFrameOption: Indicates the size of the view where the video is displayed (.normal, .square, .fullScreen and .withBottomMargin)
  • applyFilterCallback: Should stay nil
  • ratio: The approximate ratio (height/width) of the document you want to scan
import UIKit
import Kirsch

class ViewController: UIViewController, KirschDelegate {

  lazy var scanner: Kirsch = {
    let scanner = Kirsch(superview: self.view, videoFrameOption: .fullScreen, applyFilterCallback: nil, ratio: 1.5)
    scanner.configure()

    return scanner
  }()

  viewDidLoad() {
    super.viewDidLoad()

    // Create the video filter
    scanner.delegate = self
  }

  override func viewDidAppear(_ animated: Bool) {
    do {
      try scanner.start()
    } catch {
      presentAlertView(title: "Some Error Occurred", message: error.localizedDescription)
    }
  }

}

Options available

scanner.isBlackFilterActivated // Activate the black filter 
scanner.isFlashActive // Activate the flashlight of the phone 

Configuration Functions

scanner.configure() // Configure the scanner
scanner.start() // Start the scanner
scanner.stop() // Stop the scanner

Note: that the configure() should be called before the start() function.

Control Functions

  • Filter: Indicates the type of filter it’s going to be applied (.contrast, .none)
  • Orientation: Helps the detector in which orientation the documents is going to be (.vertical, horizontal)
scanner.captureImage(withFilter: .contrast, andOrientation: .vertical) // Captures vertical image and applying a high contrast filter
scanner.captureImage(withOrientation: .vertical) // Captures a vertical image without applying any filters
scanner.captureImageWithNoCrop(withOrientation: .vertical) // Captures a vertical image without cropping any borders

Delegate

The capturing progress indicates if an image is being well detected and the phone is able to capture it. When this progress arrives at 100%, the scanner has detected an stable image

func getCapturingProgress(_ progress: Float?) {
  guard let progress = progress else { return }

  if progress >= 1 {
    scanner.captureImage(withFilter: .contrast, andOrientation: .vertical)
  }
}

When the an image is captured, it will be returned by this delegate function

func getCapturedImageFiltered(_ image: UIImage?) {
  guard let capturedImage = image else { return }

  self.coverfyScanner.stop()
}

Credits

This project has been developed to use it into the Coverfy App. An app to organize all your insurances, take a look at it https://www.coverfy.com!

image

Base project

Some ideas of this scanner has been taken from the IRLScanner (https://github.com/hartws1/IRLScanner)

Author

josepbordesjove, [email protected]

License

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

Latest podspec

{
    "name": "Kirsch",
    "version": "0.3.0",
    "summary": "Cool scanner developed with swift",
    "description": "This library provides a bunch of functions in order to convert and control the camera into an automatic scanner. This library is named before Russell A. Kirsch, the one who developed the first digital scanner",
    "homepage": "https://github.com/coverfy/KirschScanner",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "josepbordesjove": "[email protected]"
    },
    "source": {
        "git": "https://github.com/coverfy/KirschScanner.git",
        "tag": "0.3.0"
    },
    "social_media_url": "https://twitter.com/coverfy",
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "Kirsch/Classes/**/*",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This