ocr 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +16 -6
- data/lib/ocr/ocr.rb +12 -2
- data/lib/ocr/version.rb +1 -1
- metadata +8 -8
data/README.md
CHANGED
@@ -6,6 +6,11 @@
|
|
6
6
|
|
7
7
|
##Web services supported
|
8
8
|
- [WeOCR project](http://weocr.ocrgrid.org/)
|
9
|
+
* update WeOCR servers list
|
10
|
+
* autoselect server
|
11
|
+
* no identify
|
12
|
+
* languages: that's supported by server. TODO: select server by languaje requested.
|
13
|
+
* output formats: :txt
|
9
14
|
- [OCR Web Service](http://www.ocrwebservice.com/)([Online OCR](http://www.onlineocr.net/))
|
10
15
|
* identify: Username and license code as password
|
11
16
|
* languages: :brazilian, :byelorussian, :bulgarian, :catalan, :croatian, :czech, :danish, :dutch, :english, :estonian, :finnish, :french, :german, :greek, :hungarian, :indonesian, :italian, :latin, :latvian, :lithuanian, :moldavian, :polish, :portuguese, :romanian, :russian, :serbian, :slovakian, :slovenian, :spanish, :swedish, :turkish, :ukrainian
|
@@ -37,15 +42,16 @@ gem 'ocr'
|
|
37
42
|
```
|
38
43
|
|
39
44
|
## Using
|
40
|
-
- Get a OCR: ocr = OCR.use
|
41
|
-
- Set the login Credentials: ocr.login
|
45
|
+
- Get a OCR: ocr = OCR.use OCR_NAME
|
46
|
+
- Set the login Credentials: ocr.login YOUR_USER, YOUR_PASSWORD, [EXTRA_LOGIN_DATA]
|
42
47
|
- Set proxy configuration: ocr.proxy p_addr, p_port = nil, p_user = nil, p_pass = nil
|
43
|
-
- Set image to work: ocr.file=
|
44
|
-
- Set languaje: ocr.file=
|
45
|
-
- Set output format: ocr.format=
|
46
|
-
- Set output file: ocr.outputfile=
|
48
|
+
- Set image to work: ocr.file= FILE_NAME_AND_PATH
|
49
|
+
- Set languaje: ocr.file= FILE_NAME_AND_PATH
|
50
|
+
- Set output format: ocr.format= FORMAT_NAME
|
51
|
+
- Set output file: ocr.outputfile= FILE_NAME_AND_PATH
|
47
52
|
- Test error: error = ocr.error if ocr.error?
|
48
53
|
- Results: text = ocr.text unless ocr.error?
|
54
|
+
- Disable auto rescue exceptions: ocr.rescue_exceptions= false
|
49
55
|
|
50
56
|
### WeOCR project
|
51
57
|
More info at [WeOCR project](http://weocr.ocrgrid.org/).
|
@@ -96,5 +102,9 @@ gem 'ocr'
|
|
96
102
|
puts "RESULT: #{ocr.text}" unless ocr.error?
|
97
103
|
```
|
98
104
|
|
105
|
+
## Credits
|
106
|
+
|
107
|
+
* Thanks to @ylluminate for request auto rescue exception feature
|
108
|
+
|
99
109
|
# License
|
100
110
|
Released under the MIT license: [http://www.opensource.org/licenses/MIT](http://www.opensource.org/licenses/MIT)
|
data/lib/ocr/ocr.rb
CHANGED
@@ -8,7 +8,7 @@ module OCR
|
|
8
8
|
attr_accessor :username, :password, :extra_login_data
|
9
9
|
attr_accessor :proxy_addr, :proxy_port, :proxy_user, :proxy_pass
|
10
10
|
attr_accessor :file, :outputfile, :language, :format
|
11
|
-
attr_accessor :debug
|
11
|
+
attr_accessor :debug, :rescue_exceptions
|
12
12
|
|
13
13
|
def initialize(*args)
|
14
14
|
init
|
@@ -24,6 +24,11 @@ module OCR
|
|
24
24
|
format= false
|
25
25
|
outputfile= false
|
26
26
|
debug= false
|
27
|
+
rescue_exceptions= true
|
28
|
+
end
|
29
|
+
|
30
|
+
def rescue_exceptions?
|
31
|
+
@rescue_exceptions != false
|
27
32
|
end
|
28
33
|
|
29
34
|
def login username, password, extra_login_data = false
|
@@ -52,7 +57,12 @@ module OCR
|
|
52
57
|
clear_text
|
53
58
|
return false && set_error("No file") if @file.nil?
|
54
59
|
return false && set_error("File not exists '#{@file}'") unless File.exist?(@file)
|
55
|
-
|
60
|
+
begin
|
61
|
+
ocr_recognize
|
62
|
+
rescue Exception => msg
|
63
|
+
set_error msg
|
64
|
+
raise unless rescue_exceptions?
|
65
|
+
end
|
56
66
|
end
|
57
67
|
|
58
68
|
private
|
data/lib/ocr/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ocr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-19 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: savon
|
16
|
-
requirement: &
|
16
|
+
requirement: &5718620 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.9.9
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *5718620
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: nokogiri
|
27
|
-
requirement: &
|
27
|
+
requirement: &5696060 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.5.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *5696060
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &5690680 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 2.7.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *5690680
|
47
47
|
description: Recognize text and characters from image files using web services.
|
48
48
|
email:
|
49
49
|
- mabarroso@mabarroso.com
|