Code Monkey home page Code Monkey logo

mbdoccapture's Introduction

MBDocCapture

Version License Platform

MBDocCapture makes it easy to add document scanning functionalities to your iOS app but also image editing (Cropping and contrast enhacement).

Features

  • Doc scanning
  • Photo cropping and enhancement
  • Auto scan

Demo

Requirements

  • Swift 4.2
  • iOS 10.0+

Installation

Cocoapods

CocoaPods is a dependency manager for Cocoa projects.

To integrate MBDocCapture into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target '<Your Target Name>' do
pod 'MBDocCapture'
end

Then, run the following command:

$ pod install

Usage

Swift

  1. Make sure that your view controller conforms to the ImageScannerControllerDelegate protocol:
class YourViewController: UIViewController, ImageScannerControllerDelegate {
// YourViewController code here
}
  1. Implement the delegate functions inside your view controller:
/// Tells the delegate that the user scanned a document.
///
/// - Parameters:
///   - scanner: The scanner controller object managing the scanning interface.
///   - results: The results of the user scanning with the camera.
/// - Discussion: Your delegate's implementation of this method should dismiss the image scanner controller.
func imageScannerController(_ scanner: ImageScannerController, didFinishScanningWithResults results: ImageScannerResults) {
    scanner.dismiss()
}

/// Tells the delegate that the user scanned a document.
///
/// - Parameters:
///   - scanner: The scanner controller object managing the scanning interface.
///   - page1Results: The results of the user scanning page 1.
///   - page2Results: The results of the user scanning page 2.
/// - Discussion: Your delegate's implementation of this method should dismiss the image scanner controller.
func imageScannerController(_ scanner: ImageScannerController, didFinishScanningWithPage1Results page1Results: ImageScannerResults, andPage2Results page2Results: ImageScannerResults) {
    scanner.dismiss()
}

/// Tells the delegate that the user cancelled the scan operation.
///
/// - Parameters:
///   - scanner: The scanner controller object managing the scanning interface.
/// - Discussion: Your delegate's implementation of this method should dismiss the image scanner controller.
func imageScannerControllerDidCancel(_ scanner: ImageScannerController) {
    scanner.dismiss()
}

/// Tells the delegate that an error occured during the user's scanning experience.
///
/// - Parameters:
///   - scanner: The scanner controller object managing the scanning interface.
///   - error: The error that occured.
func imageScannerController(_ scanner: ImageScannerController, didFailWithError error: Error) {
    scanner.dismiss()
}
  1. Finally, create and present a ImageScannerController instance somewhere within your view controller:
    let scannerViewController = ImageScannerController(delegate: self)
    //scannerViewController.shouldScanTwoFaces = false // Use this to scan the front and the back of a document 
    present(scannerViewController, animated: true)

License

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

Support

If this project helped you, buy me coffee โ˜•

paypal

mbdoccapture's People

Contributors

hbajji avatar imhdi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

mbdoccapture's Issues

Landscape support

I'm developing an iPad app that is landscape-only. Is it possible to present the ImageScannerController in landscape?

Carthage support?

Hey, was wondering whether you considered distributing the library through Carthage.

Memory leaks

when we try batch scan app terminate due to memory issue. I tested via leaks instrument when we assign delegate like @IBAction func didSelectType1Button(_ sender: Any) { let scanner = ImageScannerController(delegate: self) // this Line show memory leak scanner.shouldScanTwoFaces = false scanner.modalPresentationStyle = .fullScreen present(scanner, animated: true) }
it show 14 memory leaks. I'm new to swift I did tried to solve this but couldn't. is there anyone who can help me with this

Tab bar buttons missing

I've followed the readme and implemented the ImageScannerController like this:

let scannerViewController = ImageScannerController(delegate: self)
present(scannerViewController, animated: true)

Now, when trying it out on my device, it all works fine, but the tab bar buttons are missing:

IMG_2DB9E9784EB6-1

I've noticed, that I can still press the buttons when pressing at the very edge of the screen.
Have I overlooked any setting or what's wrong here?

Can't install through CocoaPods

Recently discovered this repo and wanted to check it out but was unable to install the MBDocCapture using CocoaPods:

[!] Unable to find a specification for MBDocCapture

I tried the following:

  • pod 'MBDocCapture', '>= 0.9' (from readme.md)
  • pod 'MBDocCapture', '>= 0.1.1' (b/c that's the version in the .podspec)
  • pod 'MBDocCapture'

Neither of those work, unfortunately.

View Controller not conforming to protocol, even though all methods are implemented

As the readme suggests, I made my view controller conform to ImageScannerControllerDelegate and added all 4 protocol methods to my code:

extension DocumentUploaderViewController: ImageScannerControllerDelegate {
    func imageScannerController(_ scanner: ImageScannerController, didFinishScanningWithResults results: ImageScannerResults) {
        scanner.dismiss(animated: true)
    }
    
    func imageScannerController(_ scanner: ImageScannerController, didFinishScanningWithPage1Results page1Results: ImageScannerResults, andPage2Results page2Results: ImageScannerResults) {
        scanner.dismiss(animated: true)
    }
    
    func imageScannerControllerDidCancel(_ scanner: ImageScannerController) {
        scanner.dismiss(animated: true)
    }
    
    func imageScannerController(_ scanner: ImageScannerController, didFailWithError error: Error) {
        scanner.dismiss(animated: true)
    }
}

Now, Xcode (10.2.1) complains that I'm still missing some protocol stubs:

Type 'DocumentUploaderViewController' does not conform to protocol 'ImageScannerControllerDelegate'
Do you want to add protocol stubs?

When I press Fix, Xcode adds the didFailWithError method:

func imageScannerController(_ scanner: ImageScannerController, didFailWithError error: Error) {
}

...and then complains that I have added an invalid redeclaration of the method (because it was already there!):

Invalid redeclaration of 'imageScannerController(_:didFailWithError:)'

I have already tried:

  • build
  • clean derived data
  • clean & build
  • quit Xcode, clean, build
  • reboot my Mac (10.14.3), open Xcode, clean, build

None of these tries helped.
Any ideas?

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.