face-api/build/ops/minBbox.js

11 lines
496 B
JavaScript
Raw Normal View History

2020-08-20 02:10:42 +02:00
import { BoundingBox } from '../classes';
export function minBbox(pts) {
2020-08-18 14:04:33 +02:00
const xs = pts.map(pt => pt.x);
const ys = pts.map(pt => pt.y);
const minX = xs.reduce((min, x) => x < min ? x : min, Infinity);
const minY = ys.reduce((min, y) => y < min ? y : min, Infinity);
const maxX = xs.reduce((max, x) => max < x ? x : max, 0);
const maxY = ys.reduce((max, y) => max < y ? y : max, 0);
2020-08-20 02:10:42 +02:00
return new BoundingBox(minX, minY, maxX, maxY);
2020-08-18 14:04:33 +02:00
}
//# sourceMappingURL=minBbox.js.map