cloudmersive-image-recognition-api-client 1.2.9 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,199 @@
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
+ # Point location within a face
17
+ class FacePoint
18
+ # X location, where 0 is the left-most pixel
19
+ attr_accessor :x
20
+
21
+ # Y location, where 0 is the top-most pixel
22
+ attr_accessor :y
23
+
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'x' => :'X',
29
+ :'y' => :'Y'
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.swagger_types
35
+ {
36
+ :'x' => :'Integer',
37
+ :'y' => :'Integer'
38
+ }
39
+ end
40
+
41
+ # Initializes the object
42
+ # @param [Hash] attributes Model attributes in the form of hash
43
+ def initialize(attributes = {})
44
+ return unless attributes.is_a?(Hash)
45
+
46
+ # convert string to symbol for hash key
47
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
48
+
49
+ if attributes.has_key?(:'X')
50
+ self.x = attributes[:'X']
51
+ end
52
+
53
+ if attributes.has_key?(:'Y')
54
+ self.y = attributes[:'Y']
55
+ end
56
+
57
+ end
58
+
59
+ # Show invalid properties with the reasons. Usually used together with valid?
60
+ # @return Array for valid properties with the reasons
61
+ def list_invalid_properties
62
+ invalid_properties = Array.new
63
+ return invalid_properties
64
+ end
65
+
66
+ # Check to see if the all the properties in the model are valid
67
+ # @return true if the model is valid
68
+ def valid?
69
+ return true
70
+ end
71
+
72
+ # Checks equality by comparing each attribute.
73
+ # @param [Object] Object to be compared
74
+ def ==(o)
75
+ return true if self.equal?(o)
76
+ self.class == o.class &&
77
+ x == o.x &&
78
+ y == o.y
79
+ end
80
+
81
+ # @see the `==` method
82
+ # @param [Object] Object to be compared
83
+ def eql?(o)
84
+ self == o
85
+ end
86
+
87
+ # Calculates hash code according to all attributes.
88
+ # @return [Fixnum] Hash code
89
+ def hash
90
+ [x, y].hash
91
+ end
92
+
93
+ # Builds the object from hash
94
+ # @param [Hash] attributes Model attributes in the form of hash
95
+ # @return [Object] Returns the model itself
96
+ def build_from_hash(attributes)
97
+ return nil unless attributes.is_a?(Hash)
98
+ self.class.swagger_types.each_pair do |key, type|
99
+ if type =~ /\AArray<(.*)>/i
100
+ # check to ensure the input is an array given that the the attribute
101
+ # is documented as an array but the input is not
102
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
103
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
104
+ end
105
+ elsif !attributes[self.class.attribute_map[key]].nil?
106
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
107
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
108
+ end
109
+
110
+ self
111
+ end
112
+
113
+ # Deserializes the data based on type
114
+ # @param string type Data type
115
+ # @param string value Value to be deserialized
116
+ # @return [Object] Deserialized data
117
+ def _deserialize(type, value)
118
+ case type.to_sym
119
+ when :DateTime
120
+ DateTime.parse(value)
121
+ when :Date
122
+ Date.parse(value)
123
+ when :String
124
+ value.to_s
125
+ when :Integer
126
+ value.to_i
127
+ when :Float
128
+ value.to_f
129
+ when :BOOLEAN
130
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
131
+ true
132
+ else
133
+ false
134
+ end
135
+ when :Object
136
+ # generic object (usually a Hash), return directly
137
+ value
138
+ when /\AArray<(?<inner_type>.+)>\z/
139
+ inner_type = Regexp.last_match[:inner_type]
140
+ value.map { |v| _deserialize(inner_type, v) }
141
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
142
+ k_type = Regexp.last_match[:k_type]
143
+ v_type = Regexp.last_match[:v_type]
144
+ {}.tap do |hash|
145
+ value.each do |k, v|
146
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
147
+ end
148
+ end
149
+ else # model
150
+ temp_model = CloudmersiveImageRecognitionApiClient.const_get(type).new
151
+ temp_model.build_from_hash(value)
152
+ end
153
+ end
154
+
155
+ # Returns the string representation of the object
156
+ # @return [String] String presentation of the object
157
+ def to_s
158
+ to_hash.to_s
159
+ end
160
+
161
+ # to_body is an alias to to_hash (backward compatibility)
162
+ # @return [Hash] Returns the object in the form of hash
163
+ def to_body
164
+ to_hash
165
+ end
166
+
167
+ # Returns the object in the form of hash
168
+ # @return [Hash] Returns the object in the form of hash
169
+ def to_hash
170
+ hash = {}
171
+ self.class.attribute_map.each_pair do |attr, param|
172
+ value = self.send(attr)
173
+ next if value.nil?
174
+ hash[param] = _to_hash(value)
175
+ end
176
+ hash
177
+ end
178
+
179
+ # Outputs non-array value in the form of hash
180
+ # For object, use to_hash. Otherwise, just return the value
181
+ # @param [Object] value Any valid value
182
+ # @return [Hash] Returns the value in the form of hash
183
+ def _to_hash(value)
184
+ if value.is_a?(Array)
185
+ value.compact.map{ |v| _to_hash(v) }
186
+ elsif value.is_a?(Hash)
187
+ {}.tap do |hash|
188
+ value.each { |k, v| hash[k] = _to_hash(v) }
189
+ end
190
+ elsif value.respond_to? :to_hash
191
+ value.to_hash
192
+ else
193
+ value
194
+ end
195
+ end
196
+
197
+ end
198
+
199
+ end
@@ -0,0 +1,318 @@
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
+ # Location of one face in an image
17
+ class FaceWithLandmarks
18
+ attr_accessor :left_eyebrow
19
+
20
+ attr_accessor :right_eyebrow
21
+
22
+ attr_accessor :left_eye
23
+
24
+ attr_accessor :right_eye
25
+
26
+ attr_accessor :bottom_and_sides_of_face
27
+
28
+ attr_accessor :nose_bridge
29
+
30
+ attr_accessor :nose_bottom
31
+
32
+ attr_accessor :lips_inner_outline
33
+
34
+ attr_accessor :lips_outer_outline
35
+
36
+ # X coordinate of the left side of the face
37
+ attr_accessor :left_x
38
+
39
+ # Y coordinate of the top side of the face
40
+ attr_accessor :top_y
41
+
42
+ # X coordinate of the right side of the face
43
+ attr_accessor :right_x
44
+
45
+ # Y coordinate of the bottom side of the face
46
+ attr_accessor :bottom_y
47
+
48
+
49
+ # Attribute mapping from ruby-style variable name to JSON key.
50
+ def self.attribute_map
51
+ {
52
+ :'left_eyebrow' => :'LeftEyebrow',
53
+ :'right_eyebrow' => :'RightEyebrow',
54
+ :'left_eye' => :'LeftEye',
55
+ :'right_eye' => :'RightEye',
56
+ :'bottom_and_sides_of_face' => :'BottomAndSidesOfFace',
57
+ :'nose_bridge' => :'NoseBridge',
58
+ :'nose_bottom' => :'NoseBottom',
59
+ :'lips_inner_outline' => :'LipsInnerOutline',
60
+ :'lips_outer_outline' => :'LipsOuterOutline',
61
+ :'left_x' => :'LeftX',
62
+ :'top_y' => :'TopY',
63
+ :'right_x' => :'RightX',
64
+ :'bottom_y' => :'BottomY'
65
+ }
66
+ end
67
+
68
+ # Attribute type mapping.
69
+ def self.swagger_types
70
+ {
71
+ :'left_eyebrow' => :'Array<FacePoint>',
72
+ :'right_eyebrow' => :'Array<FacePoint>',
73
+ :'left_eye' => :'Array<FacePoint>',
74
+ :'right_eye' => :'Array<FacePoint>',
75
+ :'bottom_and_sides_of_face' => :'Array<FacePoint>',
76
+ :'nose_bridge' => :'Array<FacePoint>',
77
+ :'nose_bottom' => :'Array<FacePoint>',
78
+ :'lips_inner_outline' => :'Array<FacePoint>',
79
+ :'lips_outer_outline' => :'Array<FacePoint>',
80
+ :'left_x' => :'Integer',
81
+ :'top_y' => :'Integer',
82
+ :'right_x' => :'Integer',
83
+ :'bottom_y' => :'Integer'
84
+ }
85
+ end
86
+
87
+ # Initializes the object
88
+ # @param [Hash] attributes Model attributes in the form of hash
89
+ def initialize(attributes = {})
90
+ return unless attributes.is_a?(Hash)
91
+
92
+ # convert string to symbol for hash key
93
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
94
+
95
+ if attributes.has_key?(:'LeftEyebrow')
96
+ if (value = attributes[:'LeftEyebrow']).is_a?(Array)
97
+ self.left_eyebrow = value
98
+ end
99
+ end
100
+
101
+ if attributes.has_key?(:'RightEyebrow')
102
+ if (value = attributes[:'RightEyebrow']).is_a?(Array)
103
+ self.right_eyebrow = value
104
+ end
105
+ end
106
+
107
+ if attributes.has_key?(:'LeftEye')
108
+ if (value = attributes[:'LeftEye']).is_a?(Array)
109
+ self.left_eye = value
110
+ end
111
+ end
112
+
113
+ if attributes.has_key?(:'RightEye')
114
+ if (value = attributes[:'RightEye']).is_a?(Array)
115
+ self.right_eye = value
116
+ end
117
+ end
118
+
119
+ if attributes.has_key?(:'BottomAndSidesOfFace')
120
+ if (value = attributes[:'BottomAndSidesOfFace']).is_a?(Array)
121
+ self.bottom_and_sides_of_face = value
122
+ end
123
+ end
124
+
125
+ if attributes.has_key?(:'NoseBridge')
126
+ if (value = attributes[:'NoseBridge']).is_a?(Array)
127
+ self.nose_bridge = value
128
+ end
129
+ end
130
+
131
+ if attributes.has_key?(:'NoseBottom')
132
+ if (value = attributes[:'NoseBottom']).is_a?(Array)
133
+ self.nose_bottom = value
134
+ end
135
+ end
136
+
137
+ if attributes.has_key?(:'LipsInnerOutline')
138
+ if (value = attributes[:'LipsInnerOutline']).is_a?(Array)
139
+ self.lips_inner_outline = value
140
+ end
141
+ end
142
+
143
+ if attributes.has_key?(:'LipsOuterOutline')
144
+ if (value = attributes[:'LipsOuterOutline']).is_a?(Array)
145
+ self.lips_outer_outline = value
146
+ end
147
+ end
148
+
149
+ if attributes.has_key?(:'LeftX')
150
+ self.left_x = attributes[:'LeftX']
151
+ end
152
+
153
+ if attributes.has_key?(:'TopY')
154
+ self.top_y = attributes[:'TopY']
155
+ end
156
+
157
+ if attributes.has_key?(:'RightX')
158
+ self.right_x = attributes[:'RightX']
159
+ end
160
+
161
+ if attributes.has_key?(:'BottomY')
162
+ self.bottom_y = attributes[:'BottomY']
163
+ end
164
+
165
+ end
166
+
167
+ # Show invalid properties with the reasons. Usually used together with valid?
168
+ # @return Array for valid properties with the reasons
169
+ def list_invalid_properties
170
+ invalid_properties = Array.new
171
+ return invalid_properties
172
+ end
173
+
174
+ # Check to see if the all the properties in the model are valid
175
+ # @return true if the model is valid
176
+ def valid?
177
+ return true
178
+ end
179
+
180
+ # Checks equality by comparing each attribute.
181
+ # @param [Object] Object to be compared
182
+ def ==(o)
183
+ return true if self.equal?(o)
184
+ self.class == o.class &&
185
+ left_eyebrow == o.left_eyebrow &&
186
+ right_eyebrow == o.right_eyebrow &&
187
+ left_eye == o.left_eye &&
188
+ right_eye == o.right_eye &&
189
+ bottom_and_sides_of_face == o.bottom_and_sides_of_face &&
190
+ nose_bridge == o.nose_bridge &&
191
+ nose_bottom == o.nose_bottom &&
192
+ lips_inner_outline == o.lips_inner_outline &&
193
+ lips_outer_outline == o.lips_outer_outline &&
194
+ left_x == o.left_x &&
195
+ top_y == o.top_y &&
196
+ right_x == o.right_x &&
197
+ bottom_y == o.bottom_y
198
+ end
199
+
200
+ # @see the `==` method
201
+ # @param [Object] Object to be compared
202
+ def eql?(o)
203
+ self == o
204
+ end
205
+
206
+ # Calculates hash code according to all attributes.
207
+ # @return [Fixnum] Hash code
208
+ def hash
209
+ [left_eyebrow, right_eyebrow, left_eye, right_eye, bottom_and_sides_of_face, nose_bridge, nose_bottom, lips_inner_outline, lips_outer_outline, left_x, top_y, right_x, bottom_y].hash
210
+ end
211
+
212
+ # Builds the object from hash
213
+ # @param [Hash] attributes Model attributes in the form of hash
214
+ # @return [Object] Returns the model itself
215
+ def build_from_hash(attributes)
216
+ return nil unless attributes.is_a?(Hash)
217
+ self.class.swagger_types.each_pair do |key, type|
218
+ if type =~ /\AArray<(.*)>/i
219
+ # check to ensure the input is an array given that the the attribute
220
+ # is documented as an array but the input is not
221
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
222
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
223
+ end
224
+ elsif !attributes[self.class.attribute_map[key]].nil?
225
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
226
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
227
+ end
228
+
229
+ self
230
+ end
231
+
232
+ # Deserializes the data based on type
233
+ # @param string type Data type
234
+ # @param string value Value to be deserialized
235
+ # @return [Object] Deserialized data
236
+ def _deserialize(type, value)
237
+ case type.to_sym
238
+ when :DateTime
239
+ DateTime.parse(value)
240
+ when :Date
241
+ Date.parse(value)
242
+ when :String
243
+ value.to_s
244
+ when :Integer
245
+ value.to_i
246
+ when :Float
247
+ value.to_f
248
+ when :BOOLEAN
249
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
250
+ true
251
+ else
252
+ false
253
+ end
254
+ when :Object
255
+ # generic object (usually a Hash), return directly
256
+ value
257
+ when /\AArray<(?<inner_type>.+)>\z/
258
+ inner_type = Regexp.last_match[:inner_type]
259
+ value.map { |v| _deserialize(inner_type, v) }
260
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
261
+ k_type = Regexp.last_match[:k_type]
262
+ v_type = Regexp.last_match[:v_type]
263
+ {}.tap do |hash|
264
+ value.each do |k, v|
265
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
266
+ end
267
+ end
268
+ else # model
269
+ temp_model = CloudmersiveImageRecognitionApiClient.const_get(type).new
270
+ temp_model.build_from_hash(value)
271
+ end
272
+ end
273
+
274
+ # Returns the string representation of the object
275
+ # @return [String] String presentation of the object
276
+ def to_s
277
+ to_hash.to_s
278
+ end
279
+
280
+ # to_body is an alias to to_hash (backward compatibility)
281
+ # @return [Hash] Returns the object in the form of hash
282
+ def to_body
283
+ to_hash
284
+ end
285
+
286
+ # Returns the object in the form of hash
287
+ # @return [Hash] Returns the object in the form of hash
288
+ def to_hash
289
+ hash = {}
290
+ self.class.attribute_map.each_pair do |attr, param|
291
+ value = self.send(attr)
292
+ next if value.nil?
293
+ hash[param] = _to_hash(value)
294
+ end
295
+ hash
296
+ end
297
+
298
+ # Outputs non-array value in the form of hash
299
+ # For object, use to_hash. Otherwise, just return the value
300
+ # @param [Object] value Any valid value
301
+ # @return [Hash] Returns the value in the form of hash
302
+ def _to_hash(value)
303
+ if value.is_a?(Array)
304
+ value.compact.map{ |v| _to_hash(v) }
305
+ elsif value.is_a?(Hash)
306
+ {}.tap do |hash|
307
+ value.each { |k, v| hash[k] = _to_hash(v) }
308
+ end
309
+ elsif value.respond_to? :to_hash
310
+ value.to_hash
311
+ else
312
+ value
313
+ end
314
+ end
315
+
316
+ end
317
+
318
+ end