alpr 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.circleci/config.yml +101 -0
- data/.rubocop.yml +51 -0
- data/.travis.yml +1 -1
- data/Dockerfile +10 -0
- data/Gemfile +2 -0
- data/README.md +23 -3
- data/Rakefile +6 -2
- data/alpr.gemspec +18 -12
- data/docker-compose.yml +6 -0
- data/lib/alpr.rb +20 -14
- data/lib/alpr/version.rb +3 -1
- metadata +53 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ac803bf984fae234c3fb83e57b29108fa2ba781fdf43fd8f75c2de5b49c195e8
|
4
|
+
data.tar.gz: 40deada9c770b0611369f6e2095a164d653b5ec0d65f54e8d383ed61735c644a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab28f0ddf8d416a5244640072e68a887d6c3601c34677e0e7ec83a645dfa1cd1a0997a7a01bab42443d749de5ca5c3dd2df3126640c7541c3b1e6c80cfec92f6
|
7
|
+
data.tar.gz: 316d6b9045191e773cf732f4665035686ff8e5fa0c94d240ddf061208d24846b05c2aa66b1f391ade61003eeda9b3f666d5f6b60766058a42c8847d2c7507be3
|
@@ -0,0 +1,101 @@
|
|
1
|
+
version: 2
|
2
|
+
|
3
|
+
workspace_root: &workspace_root
|
4
|
+
~/alpr
|
5
|
+
|
6
|
+
main_container: &main_container
|
7
|
+
image: circleci/ruby:2.3.8
|
8
|
+
|
9
|
+
attach_workspace: &attach_workspace
|
10
|
+
attach_workspace:
|
11
|
+
at: *workspace_root
|
12
|
+
|
13
|
+
restore_repo: &restore_repo
|
14
|
+
restore_cache:
|
15
|
+
name: Restore repository
|
16
|
+
keys:
|
17
|
+
- repo-{{ .Branch }}-{{ .Revision }}
|
18
|
+
|
19
|
+
restore_gems: &restore_gems
|
20
|
+
restore_cache:
|
21
|
+
name: Restore gems
|
22
|
+
keys:
|
23
|
+
- alpr-{{ checksum "alpr.gemspec" }}
|
24
|
+
|
25
|
+
jobs:
|
26
|
+
# Since a workspace can't persist the root of the working directory we are using the caching mechanism to save
|
27
|
+
# the repository.
|
28
|
+
checkout-code:
|
29
|
+
working_directory: *workspace_root
|
30
|
+
docker:
|
31
|
+
- *main_container
|
32
|
+
steps:
|
33
|
+
- *restore_repo
|
34
|
+
- checkout
|
35
|
+
- save_cache:
|
36
|
+
key: repo-{{ .Branch }}-{{ .Revision }}
|
37
|
+
paths:
|
38
|
+
- *workspace_root
|
39
|
+
|
40
|
+
bundle-dependencies:
|
41
|
+
working_directory: *workspace_root
|
42
|
+
docker:
|
43
|
+
- *main_container
|
44
|
+
steps:
|
45
|
+
- *restore_repo
|
46
|
+
- *restore_gems
|
47
|
+
- run:
|
48
|
+
name: Install Bundler dependencies
|
49
|
+
command: |
|
50
|
+
bundle install --path=vendor/bundle \
|
51
|
+
--retry=3
|
52
|
+
- save_cache:
|
53
|
+
key: alpr-{{ checksum "alpr.gemspec" }}
|
54
|
+
paths:
|
55
|
+
- vendor/bundle
|
56
|
+
- persist_to_workspace:
|
57
|
+
root: *workspace_root
|
58
|
+
paths:
|
59
|
+
- vendor/bundle
|
60
|
+
|
61
|
+
run-specs:
|
62
|
+
working_directory: *workspace_root
|
63
|
+
docker:
|
64
|
+
- *main_container
|
65
|
+
parallelism: 1
|
66
|
+
steps:
|
67
|
+
- *restore_repo
|
68
|
+
- *attach_workspace
|
69
|
+
- run:
|
70
|
+
name: Set bundler path
|
71
|
+
command: bundle --path vendor/bundle
|
72
|
+
- run:
|
73
|
+
name: Install OpenALPR
|
74
|
+
command: sudo apt-get update && sudo apt-get install -y openalpr openalpr-daemon openalpr-utils libopenalpr-dev
|
75
|
+
- run:
|
76
|
+
name: Run tests
|
77
|
+
command: bundle exec rake test
|
78
|
+
when: always
|
79
|
+
- store_test_results:
|
80
|
+
path: test/reports
|
81
|
+
|
82
|
+
workflows:
|
83
|
+
version: 2
|
84
|
+
build-test-deploy:
|
85
|
+
jobs:
|
86
|
+
- checkout-code:
|
87
|
+
filters:
|
88
|
+
tags:
|
89
|
+
only: /.*/
|
90
|
+
- bundle-dependencies:
|
91
|
+
requires:
|
92
|
+
- checkout-code
|
93
|
+
filters:
|
94
|
+
tags:
|
95
|
+
only: /.*/
|
96
|
+
- run-specs:
|
97
|
+
requires:
|
98
|
+
- bundle-dependencies
|
99
|
+
filters:
|
100
|
+
tags:
|
101
|
+
only: /.*/
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.3
|
5
|
+
|
6
|
+
Documentation:
|
7
|
+
# Skips checking to make sure top level modules / classes have a comment.
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Style/ClassAndModuleChildren:
|
11
|
+
# Skips checking the style of children definitions at classes and modules.
|
12
|
+
#
|
13
|
+
# Basically there are two different styles:
|
14
|
+
#
|
15
|
+
# `nested` - have each child on a separate line
|
16
|
+
# class Foo
|
17
|
+
# class Bar
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# `compact` - combine definitions as much as possible
|
22
|
+
# class Foo::Bar
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# With it disabled, either or is valid.
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
Metrics/LineLength:
|
29
|
+
# Commonly used screens these days easily fit more than 80 characters.
|
30
|
+
Max: 120
|
31
|
+
|
32
|
+
Metrics/MethodLength:
|
33
|
+
# Too short methods lead to extraction of single-use methods, which can make
|
34
|
+
# the code easier to read (by naming things), but can also clutter the class
|
35
|
+
Max: 20
|
36
|
+
|
37
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
38
|
+
# No space makes the method definition shorter and differentiates
|
39
|
+
# from a regular assignment.
|
40
|
+
EnforcedStyle: no_space
|
41
|
+
|
42
|
+
Style/SymbolArray:
|
43
|
+
# We do not need to support Ruby 1.9, so this is good to use.
|
44
|
+
Enabled: true
|
45
|
+
|
46
|
+
Style/PercentLiteralDelimiters:
|
47
|
+
# Because percent literals are closer to method calls, use parenthesis.
|
48
|
+
PreferredDelimiters:
|
49
|
+
default: ()
|
50
|
+
'%i': '()'
|
51
|
+
'%w': '()'
|
data/.travis.yml
CHANGED
data/Dockerfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
FROM circleci/ruby:2.3.8
|
2
|
+
USER root
|
3
|
+
RUN apt-get update && sudo apt-get install -y openalpr openalpr-daemon openalpr-utils libopenalpr-dev
|
4
|
+
RUN mkdir /alpr
|
5
|
+
RUN chown -R circleci:circleci /alpr
|
6
|
+
USER circleci
|
7
|
+
WORKDIR /alpr
|
8
|
+
COPY . /alpr
|
9
|
+
RUN bundle install
|
10
|
+
COPY . /alpr
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,16 @@
|
|
1
|
-
# Alpr
|
1
|
+
# Alpr [](https://rubygems.org/gems/alpr) [](https://app.fossa.io/projects/git%2Bgithub.com%2Fzjwhitehead%2Falpr?ref=badge_shield)
|
2
|
+
[](https://circleci.com/gh/zjwhitehead/alpr/tree/master)
|
3
|
+
|
4
|
+
Tiny rubygem wrapping [openALPR](https://github.com/openalpr/openalpr).
|
5
|
+
|
6
|
+
You'll need to install openALPR. I used `brew tap brewsci/science && brew install openalpr`, on macOS.
|
7
|
+
|
8
|
+
For Linux see the [official wiki](https://github.com/openalpr/openalpr/wiki/Compilation-instructions-(Ubuntu-Linux))
|
2
9
|
|
3
10
|
## Installation
|
4
11
|
|
12
|
+
Requires Ruby version 2.3 or higher
|
13
|
+
|
5
14
|
Add this line to your application's Gemfile:
|
6
15
|
|
7
16
|
```ruby
|
@@ -18,11 +27,22 @@ Or install it yourself as:
|
|
18
27
|
|
19
28
|
## Usage
|
20
29
|
|
21
|
-
|
30
|
+
```ruby
|
31
|
+
search = Alpr.new("lc.jpg")
|
32
|
+
puts search.output
|
33
|
+
```
|
34
|
+
|
35
|
+
For USA license plates
|
36
|
+
specify an optional state pattern (eg. Ohio = "oh" )
|
37
|
+
```ruby
|
38
|
+
search = Alpr.new("lc.jpg", :us, "oh")
|
39
|
+
puts search.output
|
40
|
+
```
|
41
|
+
|
22
42
|
|
23
43
|
## Contributing
|
24
44
|
|
25
|
-
1. Fork it ( https://github.com/
|
45
|
+
1. Fork it ( https://github.com/zjwhitehead/alpr/fork )
|
26
46
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
47
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
48
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/Rakefile
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
2
4
|
|
3
5
|
require 'rake/testtask'
|
4
6
|
|
5
7
|
Rake::TestTask.new do |t|
|
6
8
|
t.libs << 'test'
|
7
|
-
t.pattern =
|
9
|
+
t.pattern = 'test/test_*.rb'
|
8
10
|
end
|
11
|
+
|
12
|
+
task :default => :test
|
data/alpr.gemspec
CHANGED
@@ -1,23 +1,29 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'alpr/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'alpr'
|
8
9
|
spec.version = Alpr::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
10
|
+
spec.authors = ['Andrew Monks', 'Zach Whitehead']
|
11
|
+
spec.email = ['zjwhitehead@users.noreply.github.com']
|
11
12
|
|
12
|
-
spec.summary =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
13
|
+
spec.summary = 'Ruby wrapper for openalpr'
|
14
|
+
spec.homepage = 'http://github.com/zjwhitehead/alpr'
|
15
|
+
spec.license = 'MIT'
|
15
16
|
|
16
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
-
spec.bindir =
|
18
|
+
spec.bindir = 'exe'
|
18
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
-
spec.require_paths = [
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.required_ruby_version = '>= 2.3'
|
20
23
|
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.9'
|
25
|
+
spec.add_development_dependency 'json'
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
27
|
+
spec.add_development_dependency 'minitest'
|
28
|
+
spec.add_development_dependency 'minitest-ci'
|
23
29
|
end
|
data/docker-compose.yml
ADDED
data/lib/alpr.rb
CHANGED
@@ -1,15 +1,17 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'JSON'
|
3
|
+
require 'alpr/version'
|
5
4
|
|
5
|
+
require 'shellwords'
|
6
|
+
require 'json'
|
6
7
|
|
7
8
|
class Alpr
|
8
|
-
attr_reader :region, :max, :glob, :output, :command
|
9
|
+
attr_reader :region, :max, :glob, :output, :command, :pattern
|
9
10
|
|
10
|
-
def initialize(file, region =
|
11
|
+
def initialize(file, region=:detect, pattern=nil, max=10, glob=false)
|
11
12
|
@file = file
|
12
13
|
@region = region
|
14
|
+
@pattern = pattern
|
13
15
|
@max = max
|
14
16
|
@glob = glob
|
15
17
|
|
@@ -17,10 +19,10 @@ class Alpr
|
|
17
19
|
begin
|
18
20
|
if @glob
|
19
21
|
Dir.glob(glob).each do |picture|
|
20
|
-
@output.push
|
22
|
+
@output.push JSON.parse(check_file(picture))
|
21
23
|
end
|
22
24
|
else
|
23
|
-
@output = JSON.parse(
|
25
|
+
@output = JSON.parse(check_file(file))
|
24
26
|
end
|
25
27
|
rescue JSON::ParserError
|
26
28
|
@output = nil
|
@@ -29,21 +31,25 @@ class Alpr
|
|
29
31
|
|
30
32
|
private
|
31
33
|
|
32
|
-
def
|
33
|
-
@command = "alpr -j -n #{@max} #{
|
34
|
+
def check_file(file)
|
35
|
+
@command = "alpr -j -n #{@max} #{region_string} #{pattern_string} #{Shellwords.shellescape file}"
|
34
36
|
`#{@command}`
|
35
37
|
end
|
36
38
|
|
37
|
-
def
|
39
|
+
def region_string
|
38
40
|
case @region
|
39
41
|
when :us
|
40
|
-
|
42
|
+
'-c us'
|
41
43
|
when :eu
|
42
|
-
|
44
|
+
'-c eu'
|
43
45
|
when :detect
|
44
|
-
|
46
|
+
'--detect_region'
|
45
47
|
else
|
46
|
-
|
48
|
+
''
|
47
49
|
end
|
48
50
|
end
|
51
|
+
|
52
|
+
def pattern_string
|
53
|
+
return "-p #{@pattern.downcase}" if @pattern
|
54
|
+
end
|
49
55
|
end
|
data/lib/alpr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alpr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Monks
|
8
|
+
- Zach Whitehead
|
8
9
|
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2018-12-15 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
@@ -24,6 +25,20 @@ dependencies:
|
|
24
25
|
- - "~>"
|
25
26
|
- !ruby/object:Gem::Version
|
26
27
|
version: '1.9'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: json
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
27
42
|
- !ruby/object:Gem::Dependency
|
28
43
|
name: rake
|
29
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,24 +53,56 @@ dependencies:
|
|
38
53
|
- - "~>"
|
39
54
|
- !ruby/object:Gem::Version
|
40
55
|
version: '10.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: minitest
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: minitest-ci
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
41
84
|
description:
|
42
85
|
email:
|
43
|
-
-
|
86
|
+
- zjwhitehead@users.noreply.github.com
|
44
87
|
executables: []
|
45
88
|
extensions: []
|
46
89
|
extra_rdoc_files: []
|
47
90
|
files:
|
91
|
+
- ".circleci/config.yml"
|
48
92
|
- ".gitignore"
|
93
|
+
- ".rubocop.yml"
|
49
94
|
- ".travis.yml"
|
50
95
|
- CODE_OF_CONDUCT.md
|
96
|
+
- Dockerfile
|
51
97
|
- Gemfile
|
52
98
|
- LICENSE.txt
|
53
99
|
- README.md
|
54
100
|
- Rakefile
|
55
101
|
- alpr.gemspec
|
102
|
+
- docker-compose.yml
|
56
103
|
- lib/alpr.rb
|
57
104
|
- lib/alpr/version.rb
|
58
|
-
homepage: http://github.com/
|
105
|
+
homepage: http://github.com/zjwhitehead/alpr
|
59
106
|
licenses:
|
60
107
|
- MIT
|
61
108
|
metadata: {}
|
@@ -67,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
67
114
|
requirements:
|
68
115
|
- - ">="
|
69
116
|
- !ruby/object:Gem::Version
|
70
|
-
version: '
|
117
|
+
version: '2.3'
|
71
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
119
|
requirements:
|
73
120
|
- - ">="
|
@@ -75,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
122
|
version: '0'
|
76
123
|
requirements: []
|
77
124
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.
|
125
|
+
rubygems_version: 2.7.7
|
79
126
|
signing_key:
|
80
127
|
specification_version: 4
|
81
128
|
summary: Ruby wrapper for openalpr
|