Code Monkey home page Code Monkey logo

swiftytesseractrte's Introduction

SwiftyTesseractRTE

pod-version platforms swift-version Build Status

SwiftyTesseractRTE can only currently be used in portrait mode.

SwiftyTesseractRTE-example

About SwiftyTesseractRTE

SwiftyTesseractRTE (SwiftyTesseract Real-Time Engine) is a real-time optical character recognition library built on top of SwiftyTesseract.

Using SwiftyTesseractRTE in Your Project

Import the neccessary modules

import SwiftyTesseract
import SwiftyTesseractRTE

Create an instance of SwiftyTesseractRTE and assign it's regionOfInterest property.

var realTimeEngine: SwiftyTesseractRTE!

@IBOutlet weak var previewView: UIView!
@IBOutlet weak var regionOfInterest: UIView! // A subview of previewView

override func viewDidLoad() {
  let swiftyTesseract = SwiftyTesseract(language: .english)
  realTimeEngine = SwiftyTesseractRTE(swiftyTesseract: swiftyTesseract, desiredReliability: .verifiable)
  realTimeEngine.delegate = self
}

override func viewDidLayoutSubviews() {
  // Must occur during viewDidLayoutSubviews() - Autolayout constraints are not set in viewDidLoad()
  realTimeEngine.bindPreviewLayer(to: previewView)
  realTimeEngine.regionOfInterest = regionOfInterest.frame

  // Only neccessary if providing a visual cue where the regionOfInterest is to your end user
  previewView.addSublayer(regionOfInterest.layer)
}

Conform to the SwiftyTesseractRTEDelegate protocol

extension YourViewController: SwiftyTesseractRTEDelegate {

  func onRecognitionComplete(_ recognizedString: String) {
      // Do something with the recognized string
  }

}

Starting and Stopping Recognition

// Starts optical character recognition
realTimeEngine.recognitionIsActive = true

// Stops optical character recognition
realTimeEngine.recognitionIsActive = false

Starting and Stopping Camera Preview

// Starts camera preview
realTimeEngine.startPreview()

// Stops camera preview
realTimeEngine.stopPreview()

Camera Permissions

For camera permissions, you will need to add the Privacy - Camera Usage Description permission to your Info.plist file. SwiftyTesseractRTE will handle requesting permission if it is not already granted.

A Note about Portrait-Only

SwiftyTesseractRTE is currently only able to utilized in portrait mode, but that does not mean your entire app also has to be portrait mode only. See the example project's AppDelegate (specifically the addition of a shouldRotate boolean member variable and the implementation of application(_:supportedInterfaceOrientationsFor:)) and ViewController files (specifically the viewWillAppear() and viewWillDisappear() methods) for an example on how to make a single view controller portrait mode only.

Installation

Tested with pod --version: 1.3.1

# Podfile
use_frameworks!

target 'YOUR_TARGET_NAME' do
    pod 'SwiftyTesseractRTE',    '~> 1.0'
end

Replace YOUR_TARGET_NAME and then, in the Podfile directory, type:

$ pod install

Setting Up SwiftyTesseract for Use in SwiftyTesseractRTE

See SwiftyTesseract's Additional Configuration section on properly setting up SwiftyTesseract to be utilized in your project.

Documentation

Official documentation for SwiftyTesseractRTE can be found here

Contributions Welcome

Contributions are always welcome! Please refer to Contributing to SwiftyTesseractRTE for the full guidelines on creating issues and opening pull requests to the project.

swiftytesseractrte's People

Contributors

steven0351 avatar

Watchers

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