Inline
This commit is contained in:
parent
b37f67d6ed
commit
0c8549a840
6 changed files with 16 additions and 24 deletions
|
@ -14,7 +14,7 @@ import {
|
|||
scale,
|
||||
translate,
|
||||
} from "transformation-matrix";
|
||||
import { Dimensions } from "types/image";
|
||||
import { Dimensions } from "services/ml/geom";
|
||||
import {
|
||||
clamp,
|
||||
getPixelBilinear,
|
||||
|
|
|
@ -20,6 +20,11 @@ export class Point {
|
|||
}
|
||||
}
|
||||
|
||||
export interface Dimensions {
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
export interface IBoundingBox {
|
||||
left: number;
|
||||
top: number;
|
||||
|
@ -99,10 +104,3 @@ export class Box implements IRect {
|
|||
return new Box({ x, y, width, height });
|
||||
}
|
||||
}
|
||||
|
||||
export function isValidNumber(num: any) {
|
||||
return (
|
||||
(!!num && num !== Infinity && num !== -Infinity && !isNaN(num)) ||
|
||||
num === 0
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { DebugInfo } from "hdbscan";
|
||||
import PQueue from "p-queue";
|
||||
import { EnteFile } from "types/file";
|
||||
import { Dimensions } from "types/image";
|
||||
import { Dimensions } from "services/ml/geom";
|
||||
import { Box, Point } from "./geom";
|
||||
|
||||
export interface MLSyncResult {
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
export interface Dimensions {
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
export interface BlobOptions {
|
||||
type?: string;
|
||||
quality?: number;
|
||||
}
|
|
@ -1,10 +1,9 @@
|
|||
// these utils only work in env where OffscreenCanvas is available
|
||||
|
||||
import { Matrix, inverse } from "ml-matrix";
|
||||
import { Box, Dimensions } from "services/ml/geom";
|
||||
import { FaceAlignment } from "services/ml/types";
|
||||
import { BlobOptions, Dimensions } from "types/image";
|
||||
import { enlargeBox } from "utils/machineLearning";
|
||||
import { Box } from "services/ml/geom";
|
||||
|
||||
export function normalizePixelBetween0And1(pixelValue: number) {
|
||||
return pixelValue / 255.0;
|
||||
|
@ -447,6 +446,11 @@ export function addPadding(image: ImageBitmap, padding: number) {
|
|||
return offscreen.transferToImageBitmap();
|
||||
}
|
||||
|
||||
export interface BlobOptions {
|
||||
type?: string;
|
||||
quality?: number;
|
||||
}
|
||||
|
||||
export async function imageBitmapToBlob(
|
||||
imageBitmap: ImageBitmap,
|
||||
options?: BlobOptions,
|
||||
|
|
|
@ -4,7 +4,7 @@ import log from "@/next/log";
|
|||
import PQueue from "p-queue";
|
||||
import DownloadManager from "services/download";
|
||||
import { getLocalFiles } from "services/fileService";
|
||||
import { Box, Point, boxFromBoundingBox } from "services/ml/geom";
|
||||
import { Box, Dimensions, Point, boxFromBoundingBox } from "services/ml/geom";
|
||||
import {
|
||||
DetectedFace,
|
||||
Face,
|
||||
|
@ -14,7 +14,6 @@ import {
|
|||
Versioned,
|
||||
} from "services/ml/types";
|
||||
import { EnteFile } from "types/file";
|
||||
import { Dimensions } from "types/image";
|
||||
import { getRenderableImage } from "utils/file";
|
||||
import { clamp, warpAffineFloat32List } from "utils/image";
|
||||
import mlIDbStorage from "utils/storage/mlIDbStorage";
|
||||
|
@ -23,11 +22,11 @@ export function newBox(x: number, y: number, width: number, height: number) {
|
|||
return new Box({ x, y, width, height });
|
||||
}
|
||||
|
||||
export function getBoxCenterPt(topLeft: Point, bottomRight: Point): Point {
|
||||
function getBoxCenterPt(topLeft: Point, bottomRight: Point): Point {
|
||||
return topLeft.add(bottomRight.sub(topLeft).div(new Point(2, 2)));
|
||||
}
|
||||
|
||||
export function getBoxCenter(box: Box): Point {
|
||||
function getBoxCenter(box: Box): Point {
|
||||
return getBoxCenterPt(box.topLeft, box.bottomRight);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue