10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/Ocr/extractor.rb', line 10
def (*args)
case args.size
when 2
image_file_name,folder = *args
begin
str_uri = ''
if(folder=='' || folder==nil)
str_uri += $product_uri + '/ocr/' + image_file_name.to_s + '/recognize'
else
str_uri += $product_uri + '/ocr/' + image_file_name.to_s + '/recognize?folder=' + folder.to_s
end
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
response = RestClient.get(signed_uri, :accept=> 'application/json')
json = JSON.parse(response)
return json
rescue Exception=>e
print e
return nil
end
when 4
image_file_name,folder,language,use_default_dictionaries = *args
begin
str_uri = ''
if(folder=='' || folder==nil)
str_uri += $product_uri + '/ocr/' + image_file_name.to_s + '/recognize?language=' + language.to_s + '&useDefaultDictionaries=' + use_default_dictionaries.to_s
else
str_uri += $product_uri + '/ocr/' + image_file_name.to_s + '/recognize?language=' + language.to_s + '&useDefaultDictionaries=' + use_default_dictionaries.to_s + '&folder=' + folder.to_s
end
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
response = RestClient.get(signed_uri, :accept=> 'application/json')
json = JSON.parse(response)
return json
rescue Exception=>e
print e
return nil
end
when 1
image_file_name = args[0]
begin
str_uri = $product_uri + '/ocr/' + image_file_name + '/recognize?useDefaultDictionaries=true'
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
response = RestClient.get(signed_uri, :accept=> 'application/json')
json = JSON.parse(response)
return json
rescue Exception=>e
print e
return nil
end
when 8
image_file_name, language , use_default_dictionaries, x , y, height, width, folder = *args
begin
str_uri = $product_uri
str_uri += '/ocr/'
str_uri += image_file_name
str_uri += '/recognize?language='
str_uri += language
str_uri += ((x >= 0 && y >= 0 && width > 0 && height > 0) ? '&rectX=' + x.to_s + '&rectY=' + y.to_s + '&rectWidth=' + width.to_s + '&rectHeight=' + height.to_s : '')
str_uri += '&useDefaultDictionaries='
str_uri += ((use_default_dictionaries) ? 'true' : 'false')
str_uri +=((folder=='') ? '' : '&folder=' + folder)
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
response = RestClient.get(signed_uri, :accept=> 'application/json')
json = JSON.parse(response)
return json
rescue Exception=>e
print e
return nil
end
when 3
stream,language,use_default_dictionaries = *args
begin
str_uri = $product_uri + '/ocr/recognize?language=' + language.to_s + '&useDefaultDictionaries=' + use_default_dictionaries.to_s
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
response = RestClient.post(signed_uri,stream, :accept=> 'application/json')
json = JSON.parse(response)
return json
rescue Exception=>e
print e
return nil
end
end
end
|