This commit is contained in:
franklin
2024-07-12 22:00:06 +01:00
commit a222d266bd
823 changed files with 108626 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
# MediaPipe JavaScript Solutions
MediaPipe offers out of the box solutions to use our ML technology with live and streaming media.
Visit us as [mediapipe.dev]()
See live demos of our JavaScript solutions at [code.mediapipe.dev/codepen]()
For more information on each of the solutions and how to use them, visit https://google.github.io/mediapipe/getting_started/javascript.
+111
View File
@@ -0,0 +1,111 @@
/**
* @fileoverview Declarations for the face tracking API.
*/
/**
* Version number of this package.
*/
export const VERSION: string;
/**
* We support several ways to get image inputs.
*/
export type InputImage = HTMLVideoElement | HTMLImageElement | HTMLCanvasElement;
/**
* Legal inputs.
*/
export interface InputMap {
image: InputImage;
}
/**
* GpuBuffers should all be compatible with Canvas' `drawImage`
*/
type GpuBuffer = HTMLCanvasElement | HTMLImageElement | ImageBitmap;
/**
* Possible results from SelfieSegmentation.
*/
export interface Results {
image: GpuBuffer;
segmentationMask: GpuBuffer;
}
/**
* Configurable options for SelfieSegmentation.
*/
export interface Options {
selfieMode?: boolean;
modelSelection?: number;
}
/**
* Listener for any results from SelfieSegmentation.
*/
export type ResultsListener = (results: Results) => (Promise<void>|void);
/**
* Contains all of the setup options to drive the face solution.
*/
export interface SelfieSegmentationConfig {
locateFile?: (path: string, prefix?: string) => string;
}
/**
* Declares the interface of SelfieSegmentation.
*/
declare interface SelfieSegmentationInterface {
close(): Promise<void>;
onResults(listener: ResultsListener): void;
initialize(): Promise<void>;
reset(): void;
send(inputs: InputMap): Promise<void>;
setOptions(options: Options): void;
}
/**
* Encapsulates the entire SelfieSegmentation solution. All that is needed from the
* developer is the source of the image data. The user will call `send`
* repeatedly and if a face is detected, then the user can receive callbacks
* with this metadata.
*/
export declare class SelfieSegmentation implements SelfieSegmentationInterface {
constructor(config?: SelfieSegmentationConfig);
/**
* Shuts down the object. Call before creating a new instance.
*/
close(): Promise<void>;
/**
* Registers a single callback that will carry any results that occur
* after calling Send().
*/
onResults(listener: ResultsListener): void;
/**
* Initializes the solution. This includes loading ML models and mediapipe
* configurations, as well as setting up potential listeners for metadata. If
* `initialize` is not called manually, then it will be called the first time
* the developer calls `send`.
*/
initialize(): Promise<void>;
/**
* Tells the graph to restart before the next frame is sent.
*/
reset(): void;
/**
* Processes a single frame of data, which depends on the options sent to the
* constructor.
*/
send(inputs: InputMap): Promise<void>;
/**
* Adjusts options in the solution. This may trigger a graph reload the next
* time the graph tries to run.
*/
setOptions(options: Options): void;
}
@@ -0,0 +1,27 @@
{
"name": "@mediapipe/selfie_segmentation",
"version": "0.1.1675465747",
"description": "Mediapipe Selfie Segmentation Solution",
"main": "selfie_segmentation.js",
"module": "selfie_segmentation.js",
"jsdelivr": "selfie_segmentation.js",
"unpkg": "selfie_segmentation.js",
"types": "index.d.ts",
"author": "mhays@google.com",
"license": "Apache-2.0",
"homepage": "https://google.github.io/mediapipe/solutions/selfie_segmentation",
"keywords": [ "AR", "ML", "Augmented" ],
"devDependencies": {
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
},
"browser": {
"node-fetch": false,
"util": false,
"crypto": false
},
"sideEffects" : []
}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long