cloudmersive-image-recognition-api-client 1.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/README.md +132 -0
  4. data/Rakefile +8 -0
  5. data/cloudmersive-image-recognition-api-client.gemspec +45 -0
  6. data/docs/AgeDetectionResult.md +10 -0
  7. data/docs/ArtisticApi.md +66 -0
  8. data/docs/DetectedLicensePlate.md +14 -0
  9. data/docs/DetectedObject.md +13 -0
  10. data/docs/DrawRectangleInstance.md +14 -0
  11. data/docs/DrawRectangleRequest.md +10 -0
  12. data/docs/DrawTextInstance.md +15 -0
  13. data/docs/DrawTextRequest.md +10 -0
  14. data/docs/EditApi.md +179 -0
  15. data/docs/Face.md +11 -0
  16. data/docs/FaceApi.md +228 -0
  17. data/docs/FaceLocateResponse.md +11 -0
  18. data/docs/ImageDescriptionResponse.md +11 -0
  19. data/docs/NsfwApi.md +63 -0
  20. data/docs/NsfwResult.md +10 -0
  21. data/docs/ObjectDetectionResult.md +10 -0
  22. data/docs/PersonWithAge.md +10 -0
  23. data/docs/RecognitionOutcome.md +9 -0
  24. data/docs/RecognizeApi.md +287 -0
  25. data/docs/ResizeApi.md +69 -0
  26. data/docs/VehicleLicensePlateDetectionResult.md +10 -0
  27. data/git_push.sh +55 -0
  28. data/lib/cloudmersive-image-recognition-api-client.rb +60 -0
  29. data/lib/cloudmersive-image-recognition-api-client/api/artistic_api.rb +85 -0
  30. data/lib/cloudmersive-image-recognition-api-client/api/edit_api.rb +202 -0
  31. data/lib/cloudmersive-image-recognition-api-client/api/face_api.rb +247 -0
  32. data/lib/cloudmersive-image-recognition-api-client/api/nsfw_api.rb +79 -0
  33. data/lib/cloudmersive-image-recognition-api-client/api/recognize_api.rb +306 -0
  34. data/lib/cloudmersive-image-recognition-api-client/api/resize_api.rb +91 -0
  35. data/lib/cloudmersive-image-recognition-api-client/api_client.rb +389 -0
  36. data/lib/cloudmersive-image-recognition-api-client/api_error.rb +38 -0
  37. data/lib/cloudmersive-image-recognition-api-client/configuration.rb +209 -0
  38. data/lib/cloudmersive-image-recognition-api-client/models/age_detection_result.rb +211 -0
  39. data/lib/cloudmersive-image-recognition-api-client/models/detected_license_plate.rb +245 -0
  40. data/lib/cloudmersive-image-recognition-api-client/models/detected_object.rb +239 -0
  41. data/lib/cloudmersive-image-recognition-api-client/models/draw_rectangle_instance.rb +249 -0
  42. data/lib/cloudmersive-image-recognition-api-client/models/draw_rectangle_request.rb +227 -0
  43. data/lib/cloudmersive-image-recognition-api-client/models/draw_text_instance.rb +259 -0
  44. data/lib/cloudmersive-image-recognition-api-client/models/draw_text_request.rb +227 -0
  45. data/lib/cloudmersive-image-recognition-api-client/models/face.rb +219 -0
  46. data/lib/cloudmersive-image-recognition-api-client/models/face_locate_response.rb +220 -0
  47. data/lib/cloudmersive-image-recognition-api-client/models/image_description_response.rb +219 -0
  48. data/lib/cloudmersive-image-recognition-api-client/models/nsfw_result.rb +209 -0
  49. data/lib/cloudmersive-image-recognition-api-client/models/object_detection_result.rb +211 -0
  50. data/lib/cloudmersive-image-recognition-api-client/models/person_with_age.rb +209 -0
  51. data/lib/cloudmersive-image-recognition-api-client/models/recognition_outcome.rb +199 -0
  52. data/lib/cloudmersive-image-recognition-api-client/models/vehicle_license_plate_detection_result.rb +211 -0
  53. data/lib/cloudmersive-image-recognition-api-client/version.rb +15 -0
  54. data/spec/api/artistic_api_spec.rb +48 -0
  55. data/spec/api/edit_api_spec.rb +73 -0
  56. data/spec/api/face_api_spec.rb +83 -0
  57. data/spec/api/nsfw_api_spec.rb +47 -0
  58. data/spec/api/recognize_api_spec.rb +96 -0
  59. data/spec/api/resize_api_spec.rb +49 -0
  60. data/spec/api_client_spec.rb +226 -0
  61. data/spec/configuration_spec.rb +42 -0
  62. data/spec/models/age_detection_result_spec.rb +54 -0
  63. data/spec/models/detected_license_plate_spec.rb +78 -0
  64. data/spec/models/detected_object_spec.rb +72 -0
  65. data/spec/models/draw_rectangle_instance_spec.rb +78 -0
  66. data/spec/models/draw_rectangle_request_spec.rb +54 -0
  67. data/spec/models/draw_text_instance_spec.rb +84 -0
  68. data/spec/models/draw_text_request_spec.rb +54 -0
  69. data/spec/models/face_locate_response_spec.rb +60 -0
  70. data/spec/models/face_spec.rb +60 -0
  71. data/spec/models/image_description_response_spec.rb +60 -0
  72. data/spec/models/nsfw_result_spec.rb +54 -0
  73. data/spec/models/object_detection_result_spec.rb +54 -0
  74. data/spec/models/person_with_age_spec.rb +54 -0
  75. data/spec/models/recognition_outcome_spec.rb +48 -0
  76. data/spec/models/vehicle_license_plate_detection_result_spec.rb +54 -0
  77. data/spec/spec_helper.rb +111 -0
  78. metadata +302 -0
@@ -0,0 +1,259 @@
1
+ =begin
2
+ #imageapi
3
+
4
+ #Image Recognition and Processing APIs let you use Machine Learning to recognize and process images, and also perform useful image modification operations.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: unset
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module CloudmersiveImageRecognitionApiClient
16
+ # Text instance to draw on an image
17
+ class DrawTextInstance
18
+ # Text string to draw
19
+ attr_accessor :text
20
+
21
+ # Font Family to use. Leave blank to default to \"Arial\".
22
+ attr_accessor :font_family_name
23
+
24
+ # Font size to use.
25
+ attr_accessor :font_size
26
+
27
+ # Color to use - can be a hex value (with #) or HTML common color name
28
+ attr_accessor :color
29
+
30
+ # Pixel location of the left edge of the text location
31
+ attr_accessor :x
32
+
33
+ # Pixel location of the top edge of the text location
34
+ attr_accessor :y
35
+
36
+ # Width in pixels of the text box to draw the text in; text will wrap inside this box
37
+ attr_accessor :width
38
+
39
+ # Height in pixels of the text box to draw the text in; text will wrap inside this box
40
+ attr_accessor :height
41
+
42
+
43
+ # Attribute mapping from ruby-style variable name to JSON key.
44
+ def self.attribute_map
45
+ {
46
+ :'text' => :'Text',
47
+ :'font_family_name' => :'FontFamilyName',
48
+ :'font_size' => :'FontSize',
49
+ :'color' => :'Color',
50
+ :'x' => :'X',
51
+ :'y' => :'Y',
52
+ :'width' => :'Width',
53
+ :'height' => :'Height'
54
+ }
55
+ end
56
+
57
+ # Attribute type mapping.
58
+ def self.swagger_types
59
+ {
60
+ :'text' => :'String',
61
+ :'font_family_name' => :'String',
62
+ :'font_size' => :'Float',
63
+ :'color' => :'String',
64
+ :'x' => :'Float',
65
+ :'y' => :'Float',
66
+ :'width' => :'Float',
67
+ :'height' => :'Float'
68
+ }
69
+ end
70
+
71
+ # Initializes the object
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ def initialize(attributes = {})
74
+ return unless attributes.is_a?(Hash)
75
+
76
+ # convert string to symbol for hash key
77
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
78
+
79
+ if attributes.has_key?(:'Text')
80
+ self.text = attributes[:'Text']
81
+ end
82
+
83
+ if attributes.has_key?(:'FontFamilyName')
84
+ self.font_family_name = attributes[:'FontFamilyName']
85
+ end
86
+
87
+ if attributes.has_key?(:'FontSize')
88
+ self.font_size = attributes[:'FontSize']
89
+ end
90
+
91
+ if attributes.has_key?(:'Color')
92
+ self.color = attributes[:'Color']
93
+ end
94
+
95
+ if attributes.has_key?(:'X')
96
+ self.x = attributes[:'X']
97
+ end
98
+
99
+ if attributes.has_key?(:'Y')
100
+ self.y = attributes[:'Y']
101
+ end
102
+
103
+ if attributes.has_key?(:'Width')
104
+ self.width = attributes[:'Width']
105
+ end
106
+
107
+ if attributes.has_key?(:'Height')
108
+ self.height = attributes[:'Height']
109
+ end
110
+
111
+ end
112
+
113
+ # Show invalid properties with the reasons. Usually used together with valid?
114
+ # @return Array for valid properties with the reasons
115
+ def list_invalid_properties
116
+ invalid_properties = Array.new
117
+ return invalid_properties
118
+ end
119
+
120
+ # Check to see if the all the properties in the model are valid
121
+ # @return true if the model is valid
122
+ def valid?
123
+ return true
124
+ end
125
+
126
+ # Checks equality by comparing each attribute.
127
+ # @param [Object] Object to be compared
128
+ def ==(o)
129
+ return true if self.equal?(o)
130
+ self.class == o.class &&
131
+ text == o.text &&
132
+ font_family_name == o.font_family_name &&
133
+ font_size == o.font_size &&
134
+ color == o.color &&
135
+ x == o.x &&
136
+ y == o.y &&
137
+ width == o.width &&
138
+ height == o.height
139
+ end
140
+
141
+ # @see the `==` method
142
+ # @param [Object] Object to be compared
143
+ def eql?(o)
144
+ self == o
145
+ end
146
+
147
+ # Calculates hash code according to all attributes.
148
+ # @return [Fixnum] Hash code
149
+ def hash
150
+ [text, font_family_name, font_size, color, x, y, width, height].hash
151
+ end
152
+
153
+ # Builds the object from hash
154
+ # @param [Hash] attributes Model attributes in the form of hash
155
+ # @return [Object] Returns the model itself
156
+ def build_from_hash(attributes)
157
+ return nil unless attributes.is_a?(Hash)
158
+ self.class.swagger_types.each_pair do |key, type|
159
+ if type =~ /\AArray<(.*)>/i
160
+ # check to ensure the input is an array given that the the attribute
161
+ # is documented as an array but the input is not
162
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
163
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
164
+ end
165
+ elsif !attributes[self.class.attribute_map[key]].nil?
166
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
167
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
168
+ end
169
+
170
+ self
171
+ end
172
+
173
+ # Deserializes the data based on type
174
+ # @param string type Data type
175
+ # @param string value Value to be deserialized
176
+ # @return [Object] Deserialized data
177
+ def _deserialize(type, value)
178
+ case type.to_sym
179
+ when :DateTime
180
+ DateTime.parse(value)
181
+ when :Date
182
+ Date.parse(value)
183
+ when :String
184
+ value.to_s
185
+ when :Integer
186
+ value.to_i
187
+ when :Float
188
+ value.to_f
189
+ when :BOOLEAN
190
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
191
+ true
192
+ else
193
+ false
194
+ end
195
+ when :Object
196
+ # generic object (usually a Hash), return directly
197
+ value
198
+ when /\AArray<(?<inner_type>.+)>\z/
199
+ inner_type = Regexp.last_match[:inner_type]
200
+ value.map { |v| _deserialize(inner_type, v) }
201
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
202
+ k_type = Regexp.last_match[:k_type]
203
+ v_type = Regexp.last_match[:v_type]
204
+ {}.tap do |hash|
205
+ value.each do |k, v|
206
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
207
+ end
208
+ end
209
+ else # model
210
+ temp_model = CloudmersiveImageRecognitionApiClient.const_get(type).new
211
+ temp_model.build_from_hash(value)
212
+ end
213
+ end
214
+
215
+ # Returns the string representation of the object
216
+ # @return [String] String presentation of the object
217
+ def to_s
218
+ to_hash.to_s
219
+ end
220
+
221
+ # to_body is an alias to to_hash (backward compatibility)
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_body
224
+ to_hash
225
+ end
226
+
227
+ # Returns the object in the form of hash
228
+ # @return [Hash] Returns the object in the form of hash
229
+ def to_hash
230
+ hash = {}
231
+ self.class.attribute_map.each_pair do |attr, param|
232
+ value = self.send(attr)
233
+ next if value.nil?
234
+ hash[param] = _to_hash(value)
235
+ end
236
+ hash
237
+ end
238
+
239
+ # Outputs non-array value in the form of hash
240
+ # For object, use to_hash. Otherwise, just return the value
241
+ # @param [Object] value Any valid value
242
+ # @return [Hash] Returns the value in the form of hash
243
+ def _to_hash(value)
244
+ if value.is_a?(Array)
245
+ value.compact.map{ |v| _to_hash(v) }
246
+ elsif value.is_a?(Hash)
247
+ {}.tap do |hash|
248
+ value.each { |k, v| hash[k] = _to_hash(v) }
249
+ end
250
+ elsif value.respond_to? :to_hash
251
+ value.to_hash
252
+ else
253
+ value
254
+ end
255
+ end
256
+
257
+ end
258
+
259
+ end
@@ -0,0 +1,227 @@
1
+ =begin
2
+ #imageapi
3
+
4
+ #Image Recognition and Processing APIs let you use Machine Learning to recognize and process images, and also perform useful image modification operations.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: unset
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module CloudmersiveImageRecognitionApiClient
16
+ # Request to draw one or more pieces of text onto an image
17
+ class DrawTextRequest
18
+ # Image to draw text on, in bytes. You can also use the BaseImageUrl instead to supply image input as a URL
19
+ attr_accessor :base_image_bytes
20
+
21
+ # Image to draw text on, as an HTTP or HTTPS fully-qualified URL
22
+ attr_accessor :base_image_url
23
+
24
+ # One or more pieces of text to draw onto the image
25
+ attr_accessor :text_to_draw
26
+
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'base_image_bytes' => :'BaseImageBytes',
32
+ :'base_image_url' => :'BaseImageUrl',
33
+ :'text_to_draw' => :'TextToDraw'
34
+ }
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.swagger_types
39
+ {
40
+ :'base_image_bytes' => :'String',
41
+ :'base_image_url' => :'String',
42
+ :'text_to_draw' => :'Array<DrawTextInstance>'
43
+ }
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ return unless attributes.is_a?(Hash)
50
+
51
+ # convert string to symbol for hash key
52
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
53
+
54
+ if attributes.has_key?(:'BaseImageBytes')
55
+ self.base_image_bytes = attributes[:'BaseImageBytes']
56
+ end
57
+
58
+ if attributes.has_key?(:'BaseImageUrl')
59
+ self.base_image_url = attributes[:'BaseImageUrl']
60
+ end
61
+
62
+ if attributes.has_key?(:'TextToDraw')
63
+ if (value = attributes[:'TextToDraw']).is_a?(Array)
64
+ self.text_to_draw = value
65
+ end
66
+ end
67
+
68
+ end
69
+
70
+ # Show invalid properties with the reasons. Usually used together with valid?
71
+ # @return Array for valid properties with the reasons
72
+ def list_invalid_properties
73
+ invalid_properties = Array.new
74
+ if !@base_image_bytes.nil? && @base_image_bytes !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
75
+ invalid_properties.push("invalid value for 'base_image_bytes', must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.")
76
+ end
77
+
78
+ return invalid_properties
79
+ end
80
+
81
+ # Check to see if the all the properties in the model are valid
82
+ # @return true if the model is valid
83
+ def valid?
84
+ return false if !@base_image_bytes.nil? && @base_image_bytes !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
85
+ return true
86
+ end
87
+
88
+ # Custom attribute writer method with validation
89
+ # @param [Object] base_image_bytes Value to be assigned
90
+ def base_image_bytes=(base_image_bytes)
91
+
92
+ if !base_image_bytes.nil? && base_image_bytes !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
93
+ fail ArgumentError, "invalid value for 'base_image_bytes', must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/."
94
+ end
95
+
96
+ @base_image_bytes = base_image_bytes
97
+ end
98
+
99
+ # Checks equality by comparing each attribute.
100
+ # @param [Object] Object to be compared
101
+ def ==(o)
102
+ return true if self.equal?(o)
103
+ self.class == o.class &&
104
+ base_image_bytes == o.base_image_bytes &&
105
+ base_image_url == o.base_image_url &&
106
+ text_to_draw == o.text_to_draw
107
+ end
108
+
109
+ # @see the `==` method
110
+ # @param [Object] Object to be compared
111
+ def eql?(o)
112
+ self == o
113
+ end
114
+
115
+ # Calculates hash code according to all attributes.
116
+ # @return [Fixnum] Hash code
117
+ def hash
118
+ [base_image_bytes, base_image_url, text_to_draw].hash
119
+ end
120
+
121
+ # Builds the object from hash
122
+ # @param [Hash] attributes Model attributes in the form of hash
123
+ # @return [Object] Returns the model itself
124
+ def build_from_hash(attributes)
125
+ return nil unless attributes.is_a?(Hash)
126
+ self.class.swagger_types.each_pair do |key, type|
127
+ if type =~ /\AArray<(.*)>/i
128
+ # check to ensure the input is an array given that the the attribute
129
+ # is documented as an array but the input is not
130
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
131
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
132
+ end
133
+ elsif !attributes[self.class.attribute_map[key]].nil?
134
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
135
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
136
+ end
137
+
138
+ self
139
+ end
140
+
141
+ # Deserializes the data based on type
142
+ # @param string type Data type
143
+ # @param string value Value to be deserialized
144
+ # @return [Object] Deserialized data
145
+ def _deserialize(type, value)
146
+ case type.to_sym
147
+ when :DateTime
148
+ DateTime.parse(value)
149
+ when :Date
150
+ Date.parse(value)
151
+ when :String
152
+ value.to_s
153
+ when :Integer
154
+ value.to_i
155
+ when :Float
156
+ value.to_f
157
+ when :BOOLEAN
158
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
159
+ true
160
+ else
161
+ false
162
+ end
163
+ when :Object
164
+ # generic object (usually a Hash), return directly
165
+ value
166
+ when /\AArray<(?<inner_type>.+)>\z/
167
+ inner_type = Regexp.last_match[:inner_type]
168
+ value.map { |v| _deserialize(inner_type, v) }
169
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
170
+ k_type = Regexp.last_match[:k_type]
171
+ v_type = Regexp.last_match[:v_type]
172
+ {}.tap do |hash|
173
+ value.each do |k, v|
174
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
175
+ end
176
+ end
177
+ else # model
178
+ temp_model = CloudmersiveImageRecognitionApiClient.const_get(type).new
179
+ temp_model.build_from_hash(value)
180
+ end
181
+ end
182
+
183
+ # Returns the string representation of the object
184
+ # @return [String] String presentation of the object
185
+ def to_s
186
+ to_hash.to_s
187
+ end
188
+
189
+ # to_body is an alias to to_hash (backward compatibility)
190
+ # @return [Hash] Returns the object in the form of hash
191
+ def to_body
192
+ to_hash
193
+ end
194
+
195
+ # Returns the object in the form of hash
196
+ # @return [Hash] Returns the object in the form of hash
197
+ def to_hash
198
+ hash = {}
199
+ self.class.attribute_map.each_pair do |attr, param|
200
+ value = self.send(attr)
201
+ next if value.nil?
202
+ hash[param] = _to_hash(value)
203
+ end
204
+ hash
205
+ end
206
+
207
+ # Outputs non-array value in the form of hash
208
+ # For object, use to_hash. Otherwise, just return the value
209
+ # @param [Object] value Any valid value
210
+ # @return [Hash] Returns the value in the form of hash
211
+ def _to_hash(value)
212
+ if value.is_a?(Array)
213
+ value.compact.map{ |v| _to_hash(v) }
214
+ elsif value.is_a?(Hash)
215
+ {}.tap do |hash|
216
+ value.each { |k, v| hash[k] = _to_hash(v) }
217
+ end
218
+ elsif value.respond_to? :to_hash
219
+ value.to_hash
220
+ else
221
+ value
222
+ end
223
+ end
224
+
225
+ end
226
+
227
+ end