Giter VIP home page Giter VIP logo

openalpr-swift's Introduction

OpenALPRSwift

OpenALPRSwift is an iOS Framework for the open source OpenALPR Automatic License Plate Recognition library http://www.openalpr.com. It can be used in Swift and Objective-C

The library analyzes images and video streams to identify license plates. The output is the text representation of any license plate characters.

Current version is using precompiled Frameworks from cardash:

  • leptonica.framework
  • tesseract.framework

openalpr.framework compiled from v2.3.0 and dependency pod v3.1.0.1 for OpenCV

Requirements

  • iOS 9+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.3.0.beta.2+ is required to build OpenALPRSwift 1.0.0+.

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

platform :ios, '9.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'OpenALPRSwift', '~> 2.0.0'
end

Then, run the following command:

$ pod install

If you get an error complaining about "transitive dependencies" then put this in your Podfile

pre_install do |installer|
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
end

Usage

import OpenALPRSwift in your class and then

    let imagePath = Bundle.main.path(forResource: "dk_vb33742", ofType: "jpg")
    let alprScanner = OAScanner(country: "eu", patternRegion: "dk")
    alprScanner?.scanImage(atPath: imagePath, onSuccess: { (plates) in
        plates?.forEach({ (plate) in
            print("result: \(plate.number)")
        })
    }, onFailure: { (error) in
        print("error: \(error?.localizedDescription)")
    })

or you can pass a UIImage as well

Options

country

Specifies which OpenALPR config file to load, corresponding to the country whose plates you wish to recognize. Currently supported values are: [au, auwide, br, eu, fr, gb, kr, kr2, mx, sg, us, vn2]

region

Specifies which plate pattern to look for e.g. dk for Denmark or al for Alabama. Complete list of patterns is available under runtime_data/postprocess/*.patterns

Documentation

Detailed documentation is available at doc.openalpr.com

License

GPLv3 http://www.gnu.org/licenses/gpl-3.0.html

Credits

openalpr-swift's People

Contributors

yasirmturk 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

Watchers

 avatar  avatar  avatar  avatar  avatar

openalpr-swift's Issues

Cannot build openalpr-swiftTests

Hi there,

After doing a pod install, I tried to run the test, and I get a compile error on the import of the framework:

The line
@testable import openalpr_swift

gives an error:

Could not build Objective-C module 'openalpr_swift'

Does not detect anything

I am testing this library on a iPhone 7 with iOS 12.
Unfortunately the detection always returns an empty array.
I use the camera feed to test (with .480p resolution) but also providing a sample image does not yield any results.
When using OpenALPR in Python on OSX, the same image succeeds.

Am I missing something?

alprScanner = OAScanner(country:"eu")
[..]

alprScanner!.scanImage(image, onSuccess: { (plates) in
                print(plates)
                if let plates = plates, let first = plates.first{
                    DispatchQueue.main.sync {
                        self.carPlateNumber.text = first.number
                    }
                }
                else{
                    DispatchQueue.main.sync {
                        self.carPlateNumber.text = "?"
                    }
                }
            }, onFailure: { (error) in
                DispatchQueue.main.sync {
                    self.carPlateNumber.text = "Error"
                }
            })

No idea why it's not working

I currently try to include the OpenALPR in a Project, where I can take pictures of a plate and the app should recognise the plate. However for some reason it does not work...

This is the capturePhoto-function:

It is the following command:
cameraOutput.capturePhoto(with: settings, delegate: self)

which calls the following function:

func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) { if let photoData = photo.fileDataRepresentation() { capturedImage = UIImage(data: photoData) showLicenseInfoView() } }

And the showLicenseInfoView-function looks like this:

`func showLicenseInfoView() {

    // scanning the image
    if let licenseText = scanLicensePlate(forImage: capturedImage!) {
        print(licenseText)
        licensePlateLabel.text = licenseText
    }
    
    // add the licenseInformationView as a subview to the main view
    self.view.addSubview(licenseInformationView)
    
    // configuring the licenseInformationView
    licenseInformationView.layer.cornerRadius = 10 // slightly rounding the corners of the liceseInformationView
    let height = self.view.frame.height * 0.8 // height of the license info
    let width = self.view.frame.width * 0.9 // width of the license info
    let posX = self.view.center.x - width / 2 // license info's x-position
    let posY = self.view.safeAreaInsets.top + 3 // license info's y-position
    licenseInformationView.frame = CGRect(x: posX, y: posY, width: width, height: height) // setting up the licenseInformationView with size and positions
    licenseInformationView.transform = CGAffineTransform.init(scaleX: 0.7, y: 0.7) // scale it down to get a popUp-effect when appearing
    licenseInformationView.alpha = 0 // making it invisible
    
    // animate the window's popUp
    UIView.animate(withDuration: 0.2) {
        self.blurEffectView.effect = self.blurEffect // adding the blur-effect
        self.licenseInformationView.alpha = 1 // making the licenseInformationView visible
        self.licenseInformationView.transform = CGAffineTransform.identity // resizing the licenseInformationView to its original size
    }
}`

However the licenseText is still nil and the licensePlateLabel doesn't get assigned...
I really need help cause I have no goddamn idea why it doesn't work 😂

Can not recognize image

Hey, I followed your installation instructions and everything seems to be correct so far. But when I try to recognize a basic image (even the official example image http://plates.openalpr.com/h786poj.jpg) I get no results. I followed you example closely and have the following code:

let image = UIImage(named: "testImage")! let alprScanner = OAScanner(country: "eu", patternRegion: "de") print("ALPR version: \(alprScanner?.version())") alprScanner?.scanImage(image, onSuccess: { (plates) in print("found \(plates?.count) plate(s)") plates?.forEach({ (plate) in print("result: \(plate.number) : confidence: \(plate.confidence)") }) }, onFailure: { (error) in print("error: \(error)") })
All I'm getting is
ALPR version: 2.3.0 found Optional(0) plate(s)

Do you have any ideas what I might be doing wrong?

Plates not localized and read when they are rotated

Hello,
This class is also working well on a video stream (with CoreVideo.framework) but the plates are not localized and read when they are slightly rotated (> 15 ° / 20 °) - I know it's not a bug but a feature ... but is it possible to make a change allowing the location of the plates whatever their angle of rotation ? Thanks in advance for your help and reply.
OldNick

License

Hi there,

The code comes under GPL-3 and cannot be used in any iOS app according to AppStore licensing rules.

"alprScanner?.scanImage(image:..." seems not working

Hi,
first of all I want to say that this class working well with static image, but i cannot used it with UIIMAGE.
Another thing that can be useful: plate position (x,y) is not returning in plate object, maybe will be implemented

Regards and congratulation

Rodolfo

here my code

// Convert cropped image ref to UIImage
let imageToSave = UIImage(cgImage: imageRef, scale: 1.0, orientation: .right)

    print("image: \(String(describing: imageToSave.size))") // Your Image
    self.captureImageView.image = imageToSave
    self.captureImageView.isHidden = false
    
    if let data = UIImageJPEGRepresentation(imageToSave, 1) {
        let filename = getDocumentsDirectory().appendingPathComponent("targa.jpg")
        try? data.write(to: filename)
        let imagePath = filename.path
        
        
        // let imagePath = Bundle.main.path(forResource: "targadk", ofType: "jpg")
        let alprScanner = OAScanner(country: "eu", patternRegion: "dk")
        
        //alprScanner?.scanImage(imageToSave, onSuccess: {
        alprScanner?.scanImage(atPath: imagePath , onSuccess: {
            // alprScanner?.scanImage(newPhoto , onSuccess: {
            (plates) in
            plates?.forEach({ (plate) in
                print("result: \(plate.number)")
                
                print(plate)
            })
        }, onFailure: { (error) in
            print("error: \(String(describing: error?.localizedDescription))")
        })

        
        
    }

Failed to run pod install

Got the following error message:

[!] The 'Pods-OCRTest' target has transitive dependencies that include static binaries: (/Users/a635219/Projects/test/OCRTest/Pods/OpenCV/opencv2.framework)

Crashing in simulator

After installing pod, I am trying to run the code and build is successful but unable to open the app in simulator.

dyld: lazy symbol binding failed: can't resolve symbol ___cxa_guard_acquire in /Users/52127608/Library/Developer/CoreSimulator/Devices/FC163F57-3BF9-4CDA-9E24-DAA7C8EADBC1/data/Containers/Bundle/Application/A97B39AF-FC7A-4AC0-9503-C36DF7265780/NJEZPass.app/NJEZPass because dependent dylib #1 could not be loaded
dyld: can't resolve symbol ___cxa_guard_acquire in /Users/52127608/Library/Developer/CoreSimulator/Devices/FC163F57-3BF9-4CDA-9E24-DAA7C8EADBC1/data/Containers/Bundle/Application/A97B39AF-FC7A-4AC0-9503-C36DF7265780/NJEZPass.app/NJEZPass because dependent dylib #1 could not be loaded

Update config file

Is there a way to update the openalpr.conf file without having to create a version of the pod?

Rec often fail.

Some times loss letter.
Some times rec I,O,Z to 1,0,2.

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.