Make the timestamp the second argument in all xForVideo() methods
PiperOrigin-RevId: 529814792
This commit is contained in:
parent
13187208ac
commit
f6d0a5e03a
|
@ -261,16 +261,17 @@ export class FaceStylizer extends VisionTaskRunner {
|
||||||
* monotonically increasing.
|
* monotonically increasing.
|
||||||
*
|
*
|
||||||
* @param videoFrame A video frame to process.
|
* @param videoFrame A video frame to process.
|
||||||
|
* @param timestamp The timestamp of the current frame, in ms.
|
||||||
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
||||||
* to process the input image before running inference.
|
* to process the input image before running inference.
|
||||||
* @param timestamp The timestamp of the current frame, in ms.
|
|
||||||
* @param callback The callback that is invoked with the stylized image or
|
* @param callback The callback that is invoked with the stylized image or
|
||||||
* `null` if no face was detected. The lifetime of the returned data is only
|
* `null` if no face was detected. The lifetime of the returned data is only
|
||||||
* guaranteed for the duration of the callback.
|
* guaranteed for the duration of the callback.
|
||||||
*/
|
*/
|
||||||
stylizeForVideo(
|
stylizeForVideo(
|
||||||
videoFrame: ImageSource, imageProcessingOptions: ImageProcessingOptions,
|
videoFrame: ImageSource, timestamp: number,
|
||||||
timestamp: number, callback: FaceStylizerCallback): void;
|
imageProcessingOptions: ImageProcessingOptions,
|
||||||
|
callback: FaceStylizerCallback): void;
|
||||||
/**
|
/**
|
||||||
* Performs face stylization on the provided video frame. This method creates
|
* Performs face stylization on the provided video frame. This method creates
|
||||||
* a copy of the resulting image and should not be used in high-throughput
|
* a copy of the resulting image and should not be used in high-throughput
|
||||||
|
@ -307,30 +308,29 @@ export class FaceStylizer extends VisionTaskRunner {
|
||||||
* monotonically increasing.
|
* monotonically increasing.
|
||||||
*
|
*
|
||||||
* @param videoFrame A video frame to process.
|
* @param videoFrame A video frame to process.
|
||||||
|
* @param timestamp The timestamp of the current frame, in ms.
|
||||||
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
||||||
* to process the input image before running inference.
|
* to process the input image before running inference.
|
||||||
* @param timestamp The timestamp of the current frame, in ms.
|
|
||||||
* @return A stylized face or `null` if no face was detected. The result is
|
* @return A stylized face or `null` if no face was detected. The result is
|
||||||
* copied to avoid lifetime issues.
|
* copied to avoid lifetime issues.
|
||||||
*/
|
*/
|
||||||
stylizeForVideo(
|
|
||||||
videoFrame: ImageSource, imageProcessingOptions: ImageProcessingOptions,
|
|
||||||
timestamp: number): MPImage|null;
|
|
||||||
stylizeForVideo(
|
stylizeForVideo(
|
||||||
videoFrame: ImageSource,
|
videoFrame: ImageSource,
|
||||||
timestampOrImageProcessingOptions: number|ImageProcessingOptions,
|
timestamp: number,
|
||||||
timestampOrCallback?: number|FaceStylizerCallback,
|
imageProcessingOptions: ImageProcessingOptions,
|
||||||
|
): MPImage|null;
|
||||||
|
stylizeForVideo(
|
||||||
|
videoFrame: ImageSource, timestamp: number,
|
||||||
|
imageProcessingOptionsOrCallback?: ImageProcessingOptions|
|
||||||
|
FaceStylizerCallback,
|
||||||
callback?: FaceStylizerCallback): MPImage|null|void {
|
callback?: FaceStylizerCallback): MPImage|null|void {
|
||||||
const imageProcessingOptions =
|
const imageProcessingOptions =
|
||||||
typeof timestampOrImageProcessingOptions !== 'number' ?
|
typeof imageProcessingOptionsOrCallback !== 'function' ?
|
||||||
timestampOrImageProcessingOptions :
|
imageProcessingOptionsOrCallback :
|
||||||
{};
|
{};
|
||||||
const timestamp = typeof timestampOrImageProcessingOptions === 'number' ?
|
|
||||||
timestampOrImageProcessingOptions :
|
|
||||||
timestampOrCallback as number;
|
|
||||||
|
|
||||||
this.userCallback = typeof timestampOrCallback === 'function' ?
|
this.userCallback = typeof imageProcessingOptionsOrCallback === 'function' ?
|
||||||
timestampOrCallback :
|
imageProcessingOptionsOrCallback :
|
||||||
callback;
|
callback;
|
||||||
this.processVideoData(videoFrame, imageProcessingOptions, timestamp);
|
this.processVideoData(videoFrame, imageProcessingOptions, timestamp);
|
||||||
this.userCallback = undefined;
|
this.userCallback = undefined;
|
||||||
|
|
|
@ -293,16 +293,17 @@ export class ImageSegmenter extends VisionTaskRunner {
|
||||||
* created with running mode `video`.
|
* created with running mode `video`.
|
||||||
*
|
*
|
||||||
* @param videoFrame A video frame to process.
|
* @param videoFrame A video frame to process.
|
||||||
|
* @param timestamp The timestamp of the current frame, in ms.
|
||||||
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
||||||
* to process the input frame before running inference.
|
* to process the input frame before running inference.
|
||||||
* @param timestamp The timestamp of the current frame, in ms.
|
|
||||||
* @param callback The callback that is invoked with the segmented masks. The
|
* @param callback The callback that is invoked with the segmented masks. The
|
||||||
* lifetime of the returned data is only guaranteed for the duration of the
|
* lifetime of the returned data is only guaranteed for the duration of the
|
||||||
* callback.
|
* callback.
|
||||||
*/
|
*/
|
||||||
segmentForVideo(
|
segmentForVideo(
|
||||||
videoFrame: ImageSource, imageProcessingOptions: ImageProcessingOptions,
|
videoFrame: ImageSource, timestamp: number,
|
||||||
timestamp: number, callback: ImageSegmenterCallback): void;
|
imageProcessingOptions: ImageProcessingOptions,
|
||||||
|
callback: ImageSegmenterCallback): void;
|
||||||
/**
|
/**
|
||||||
* Performs image segmentation on the provided video frame and returns the
|
* Performs image segmentation on the provided video frame and returns the
|
||||||
* segmentation result. This method creates a copy of the resulting masks and
|
* segmentation result. This method creates a copy of the resulting masks and
|
||||||
|
@ -322,31 +323,26 @@ export class ImageSegmenter extends VisionTaskRunner {
|
||||||
* the ImageSegmenter is created with running mode `video`.
|
* the ImageSegmenter is created with running mode `video`.
|
||||||
*
|
*
|
||||||
* @param videoFrame A video frame to process.
|
* @param videoFrame A video frame to process.
|
||||||
|
* @param timestamp The timestamp of the current frame, in ms.
|
||||||
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
||||||
* to process the input frame before running inference.
|
* to process the input frame before running inference.
|
||||||
* @param timestamp The timestamp of the current frame, in ms.
|
|
||||||
* @return The segmentation result. The data is copied to avoid lifetime
|
* @return The segmentation result. The data is copied to avoid lifetime
|
||||||
* issues.
|
* issues.
|
||||||
*/
|
*/
|
||||||
segmentForVideo(
|
segmentForVideo(
|
||||||
videoFrame: ImageSource,
|
videoFrame: ImageSource, timestamp: number,
|
||||||
imageProcessingOptions: ImageProcessingOptions,
|
imageProcessingOptions: ImageProcessingOptions): ImageSegmenterResult;
|
||||||
timestamp: number,
|
|
||||||
): ImageSegmenterResult;
|
|
||||||
segmentForVideo(
|
segmentForVideo(
|
||||||
videoFrame: ImageSource,
|
videoFrame: ImageSource, timestamp: number,
|
||||||
timestampOrImageProcessingOptions: number|ImageProcessingOptions,
|
imageProcessingOptionsOrCallback?: ImageProcessingOptions|
|
||||||
timestampOrCallback?: number|ImageSegmenterCallback,
|
ImageSegmenterCallback,
|
||||||
callback?: ImageSegmenterCallback): ImageSegmenterResult|void {
|
callback?: ImageSegmenterCallback): ImageSegmenterResult|void {
|
||||||
const imageProcessingOptions =
|
const imageProcessingOptions =
|
||||||
typeof timestampOrImageProcessingOptions !== 'number' ?
|
typeof imageProcessingOptionsOrCallback !== 'function' ?
|
||||||
timestampOrImageProcessingOptions :
|
imageProcessingOptionsOrCallback :
|
||||||
{};
|
{};
|
||||||
const timestamp = typeof timestampOrImageProcessingOptions === 'number' ?
|
this.userCallback = typeof imageProcessingOptionsOrCallback === 'function' ?
|
||||||
timestampOrImageProcessingOptions :
|
imageProcessingOptionsOrCallback :
|
||||||
timestampOrCallback as number;
|
|
||||||
this.userCallback = typeof timestampOrCallback === 'function' ?
|
|
||||||
timestampOrCallback :
|
|
||||||
callback;
|
callback;
|
||||||
|
|
||||||
this.reset();
|
this.reset();
|
||||||
|
|
|
@ -297,16 +297,17 @@ export class PoseLandmarker extends VisionTaskRunner {
|
||||||
* with running mode `video`.
|
* with running mode `video`.
|
||||||
*
|
*
|
||||||
* @param videoFrame A video frame to process.
|
* @param videoFrame A video frame to process.
|
||||||
|
* @param timestamp The timestamp of the current frame, in ms.
|
||||||
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
||||||
* to process the input image before running inference.
|
* to process the input image before running inference.
|
||||||
* @param timestamp The timestamp of the current frame, in ms.
|
|
||||||
* @param callback The callback that is invoked with the result. The
|
* @param callback The callback that is invoked with the result. The
|
||||||
* lifetime of the returned masks is only guaranteed for the duration of
|
* lifetime of the returned masks is only guaranteed for the duration of
|
||||||
* the callback.
|
* the callback.
|
||||||
*/
|
*/
|
||||||
detectForVideo(
|
detectForVideo(
|
||||||
videoFrame: ImageSource, imageProcessingOptions: ImageProcessingOptions,
|
videoFrame: ImageSource, timestamp: number,
|
||||||
timestamp: number, callback: PoseLandmarkerCallback): void;
|
imageProcessingOptions: ImageProcessingOptions,
|
||||||
|
callback: PoseLandmarkerCallback): void;
|
||||||
/**
|
/**
|
||||||
* Performs pose detection on the provided video frame and returns the result.
|
* Performs pose detection on the provided video frame and returns the result.
|
||||||
* This method creates a copy of the resulting masks and should not be used
|
* This method creates a copy of the resulting masks and should not be used
|
||||||
|
@ -328,29 +329,26 @@ export class PoseLandmarker extends VisionTaskRunner {
|
||||||
* with running mode `video`.
|
* with running mode `video`.
|
||||||
*
|
*
|
||||||
* @param videoFrame A video frame to process.
|
* @param videoFrame A video frame to process.
|
||||||
|
* @param timestamp The timestamp of the current frame, in ms.
|
||||||
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
||||||
* to process the input image before running inference.
|
* to process the input image before running inference.
|
||||||
* @param timestamp The timestamp of the current frame, in ms.
|
|
||||||
* @return The landmarker result. Any masks are copied to extend the lifetime
|
* @return The landmarker result. Any masks are copied to extend the lifetime
|
||||||
* of the returned data.
|
* of the returned data.
|
||||||
*/
|
*/
|
||||||
detectForVideo(
|
detectForVideo(
|
||||||
videoFrame: ImageSource, imageProcessingOptions: ImageProcessingOptions,
|
videoFrame: ImageSource, timestamp: number,
|
||||||
timestamp: number): PoseLandmarkerResult;
|
imageProcessingOptions: ImageProcessingOptions): PoseLandmarkerResult;
|
||||||
detectForVideo(
|
detectForVideo(
|
||||||
videoFrame: ImageSource,
|
videoFrame: ImageSource, timestamp: number,
|
||||||
timestampOrImageProcessingOptions: number|ImageProcessingOptions,
|
imageProcessingOptionsOrCallback?: ImageProcessingOptions|
|
||||||
timestampOrCallback?: number|PoseLandmarkerCallback,
|
PoseLandmarkerCallback,
|
||||||
callback?: PoseLandmarkerCallback): PoseLandmarkerResult|void {
|
callback?: PoseLandmarkerCallback): PoseLandmarkerResult|void {
|
||||||
const imageProcessingOptions =
|
const imageProcessingOptions =
|
||||||
typeof timestampOrImageProcessingOptions !== 'number' ?
|
typeof imageProcessingOptionsOrCallback !== 'function' ?
|
||||||
timestampOrImageProcessingOptions :
|
imageProcessingOptionsOrCallback :
|
||||||
{};
|
{};
|
||||||
const timestamp = typeof timestampOrImageProcessingOptions === 'number' ?
|
this.userCallback = typeof imageProcessingOptionsOrCallback === 'function' ?
|
||||||
timestampOrImageProcessingOptions :
|
imageProcessingOptionsOrCallback :
|
||||||
timestampOrCallback as number;
|
|
||||||
this.userCallback = typeof timestampOrCallback === 'function' ?
|
|
||||||
timestampOrCallback :
|
|
||||||
callback;
|
callback;
|
||||||
|
|
||||||
this.resetResults();
|
this.resetResults();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user