File tree Expand file tree Collapse file tree 5 files changed +47
-2
lines changed Expand file tree Collapse file tree 5 files changed +47
-2
lines changed Original file line number Diff line number Diff line change 2828 "del" : " ^2.0.2" ,
2929 "envify" : " ^3.4.0" ,
3030 "git-branch" : " ^0.3.0" ,
31- "gulp" : " ^3.9.0 " ,
31+ "gulp" : " ^3.9.1 " ,
3232 "gulp-awspublish" : " ^3.0.1" ,
3333 "gulp-babel" : " ^6.1.2" ,
3434 "gulp-browserify" : " ^0.5.1" ,
Original file line number Diff line number Diff line change 11let axios = require ( 'axios' ) ;
22let Concepts = require ( './Concepts' ) ;
3+ let Regions = require ( './Regions' ) ;
34let { API } = require ( './constants' ) ;
45let { INPUTS_PATH } = API ;
56
@@ -13,6 +14,9 @@ class Input {
1314 this . createdAt = data . created_at || data . createdAt ;
1415 this . imageUrl = data . data . image . url ;
1516 this . concepts = new Concepts ( _config , data . data . concepts ) ;
17+ if ( data . data . regions ) {
18+ this . regions = new Regions ( _config , data . data . regions ) ;
19+ }
1620 this . score = data . score ;
1721 this . metadata = data . data . metadata ;
1822 if ( data . data . geo && data . data . geo [ 'geo_point' ] ) {
Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ class Inputs {
195195 }
196196
197197 /**
198- * @param {object[] } inputs List of concepts to update (max of 128 inputs/call; passing > 128 will throw an exception)
198+ * @param {object[] } inputs List of inputs to update (max of 128 inputs/call; passing > 128 will throw an exception)
199199 * @param {object } inputs[].input
200200 * @param {string } inputs[].input.id The id of the input to update
201201 * @param {object } inputs[].input.metadata Object with key values to attach to the input (optional)
Original file line number Diff line number Diff line change 1+ /**
2+ * Region / bounding box. Region points are percentages from the edge.
3+ * E.g. top of 0.2 means the cropped input will start 20% down from the original edge.
4+ * @class
5+ */
6+ class Region {
7+ constructor ( _config , data ) {
8+ this . id = data . id ;
9+ this . top = data . region_info . bounding_box . top_row ;
10+ this . left = data . region_info . bounding_box . left_col ;
11+ this . bottom = data . region_info . bounding_box . bottom_row ;
12+ this . right = data . region_info . bounding_box . right_col ;
13+ }
14+ }
15+
16+ module . exports = Region ;
Original file line number Diff line number Diff line change 1+ let Region = require ( './Region' ) ;
2+
3+ /**
4+ * A collection of regions.
5+ * @class
6+ */
7+ class Regions {
8+ constructor ( _config , rawData = [ ] ) {
9+ this . _config = _config ;
10+ this . rawData = rawData ;
11+ rawData . forEach ( ( regionData , index ) => {
12+ this [ index ] = new Region ( this . _config , regionData ) ;
13+ } ) ;
14+ this . length = rawData . length ;
15+ }
16+
17+ [ Symbol . iterator ] ( ) {
18+ let index = - 1 ;
19+ return {
20+ next : ( ) => ( { value : this [ ++ index ] , done : index >= this . length } )
21+ } ;
22+ } ;
23+ }
24+
25+ module . exports = Regions ;
You can’t perform that action at this time.
0 commit comments