Coder Social home page Coder Social logo

documentdetection's Introduction

DocumentDetection

IMPORTANT: Download OpenCV framework from: https://github.com/opencv/opencv/releases and copy opencv2.framework to DocumentDetection/DocumentDetectionSDK/DocumentDetectionSDK/libs

Framework files

  • VideoPreviewViewController: Parent class of DocumentDetectionViewController. This view controller only displays a layer with the video preview, and constantly updates a snapshot.
  • DocumentDetectionViewController: subclass of VideoPreviewViewController. Displays another layer with the detection box over the video preview layer, and interacts with the DocumentDetectionModel to obtain the corners.
  • DocumentDetectionModel: Model class that interacts with the OpenCV wrapper, detects the corners, crops and transforms the snapshot, and stores the result.
  • CGPoint+Helper: Helper class with some point operations like transforming a point from one coordinate system to another, sort detected points, etc.
  • CIImage+Helper: Helper class with cropping and perspective correction methods.
  • OpenCVWrapper: C++ wrapper class.
  • DocumentDetection: Entry point of the framework. Only has one static method that returns the transformed image.
  • Tests with a Host Application target.

The workspace includes a barebone sample project, with a button that calls the framework entry point method (DocumentDetection class) and an imageView to display the result:

DocumentDetection.scanDocument { image, error in

	// Show image result
	if let image = image {
	    self.image.image = image
	}

	// Show error message
	if let error = error {
	    let message = switch error {
	        case .ImageNotFound:
	            "Image not found"
	        case .CropFailed:
	            "Error cropping the image"
	        case .TransformFailed:
	            "Error applying perspective correction to the image"
	        default:
	            "Unknown error"
	    }
	    print(message)
	}

}

documentdetection's People

Contributors

amaldona avatar

Watchers

 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.