-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d45a914
commit ddee366
Showing
5 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Region / bounding box. Region points are percentages from the edge. | ||
* E.g. top of 0.2 means the cropped input will start 20% down from the original edge. | ||
* @class | ||
*/ | ||
class Region { | ||
constructor(_config, data) { | ||
this.id = data.id; | ||
this.top = data.region_info.bounding_box.top_row; | ||
this.left = data.region_info.bounding_box.left_col; | ||
this.bottom = data.region_info.bounding_box.bottom_row; | ||
this.right = data.region_info.bounding_box.right_col; | ||
} | ||
} | ||
|
||
module.exports = Region; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
let Region = require('./Region'); | ||
|
||
/** | ||
* A collection of regions. | ||
* @class | ||
*/ | ||
class Regions { | ||
constructor(_config, rawData = []) { | ||
this._config = _config; | ||
this.rawData = rawData; | ||
rawData.forEach((regionData, index) => { | ||
this[index] = new Region(this._config, regionData); | ||
}); | ||
this.length = rawData.length; | ||
} | ||
|
||
[Symbol.iterator]() { | ||
let index = -1; | ||
return { | ||
next: () => ({ value: this[++index], done: index >= this.length }) | ||
}; | ||
}; | ||
} | ||
|
||
module.exports = Regions; |