Skip to content

Commit 93730b2

Browse files
author
joeyklee
committed
refactor: updates jsdoc types
1 parent bdc0a94 commit 93730b2

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/BodyPix/index.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* Ported and integrated from all the hard work by: https://github.com/tensorflow/tfjs-models/tree/master/body-pix
1212
*/
1313

14+
// @ts-check
1415
import * as tf from '@tensorflow/tfjs';
1516
import * as bp from '@tensorflow-models/body-pix';
1617
import callCallback from '../utils/callcallback';
@@ -50,7 +51,7 @@ class BodyPix {
5051

5152
/**
5253
* Load the model and set it to this.model
53-
* @return {this} the BodyPix model.
54+
* @return {Promise<Object>} the BodyPix model.
5455
*/
5556
async loadModel() {
5657
this.model = await bp.load(this.config.multiplier);
@@ -60,7 +61,7 @@ class BodyPix {
6061

6162
/**
6263
* Returns an rgb array
63-
* @param {Object} a p5.Color obj
64+
* @param {Object} p5ColorObj - a p5.Color obj
6465
* @return {Array} an [r,g,b] array
6566
*/
6667
/* eslint class-methods-use-this: "off" */
@@ -83,7 +84,7 @@ class BodyPix {
8384

8485
/**
8586
* Returns a bodyPartsSpec object
86-
* @param {Array} an array of [r,g,b] colors
87+
* @param {Array} colorOptions - an array of [r,g,b] colors
8788
* @return {object} an object with the bodyParts by color and id
8889
*/
8990
/* eslint class-methods-use-this: "off" */
@@ -107,11 +108,11 @@ class BodyPix {
107108

108109
/**
109110
* Segments the image with partSegmentation, return result object
110-
* @param {HTMLImageElement | HTMLCanvasElement | object | function | number} imageToSegment -
111+
* @param {HTMLImageElement | HTMLCanvasElement | object | function | number} imgToSegment -
111112
* takes any of the following params
112113
* @param {object} segmentationOptions - config params for the segmentation
113114
* includes outputStride, segmentationThreshold
114-
* @return {Object} a result object with image, raw, bodyParts
115+
* @return {Promise<Object>} a result object with image, raw, bodyParts
115116
*/
116117
async segmentWithPartsInternal(imgToSegment, segmentationOptions) {
117118
// estimatePartSegmentation
@@ -220,7 +221,7 @@ class BodyPix {
220221
* @param {object} configOrCallback - config params for the segmentation
221222
* includes palette, outputStride, segmentationThreshold
222223
* @param {function} cb - a callback function that handles the results of the function.
223-
* @return {function} a promise or the results of a given callback, cb.
224+
* @return {Promise<Object>} a promise or the results of a given callback, cb.
224225
*/
225226
async segmentWithParts(optionsOrCallback, configOrCallback, cb) {
226227
let imgToSegment = this.video;
@@ -268,11 +269,11 @@ class BodyPix {
268269

269270
/**
270271
* Segments the image with personSegmentation, return result object
271-
* @param {HTMLImageElement | HTMLCanvasElement | object | function | number} imageToSegment -
272+
* @param {HTMLImageElement | HTMLCanvasElement | object | function | number} imgToSegment -
272273
* takes any of the following params
273274
* @param {object} segmentationOptions - config params for the segmentation
274275
* includes outputStride, segmentationThreshold
275-
* @return {Object} a result object with maskBackground, maskPerson, raw
276+
* @return {Promise<Object>} a result object with maskBackground, maskPerson, raw
276277
*/
277278
async segmentInternal(imgToSegment, segmentationOptions) {
278279

@@ -372,12 +373,12 @@ class BodyPix {
372373

373374
/**
374375
* Segments the image with personSegmentation
375-
* @param {HTMLImageElement | HTMLCanvasElement | object | function | number} optionsOrCallback -
376+
* @param {HTMLVideoElement | HTMLImageElement | HTMLCanvasElement | object | function | number} optionsOrCallback -
376377
* takes any of the following params
377378
* @param {object} configOrCallback - config params for the segmentation
378379
* includes outputStride, segmentationThreshold
379380
* @param {function} cb - a callback function that handles the results of the function.
380-
* @return {function} a promise or the results of a given callback, cb.
381+
* @return {Promise<Object>} a promise or the results of a given callback, cb.
381382
*/
382383
async segment(optionsOrCallback, configOrCallback, cb) {
383384
let imgToSegment = this.video;
@@ -424,6 +425,13 @@ class BodyPix {
424425

425426
}
426427

428+
/**
429+
*
430+
* @param {Object | Function} videoOrOptionsOrCallback
431+
* @param {Object | Function} optionsOrCallback
432+
* @param {Function} cb
433+
* @returns {Promise<Object> | Function}
434+
*/
427435
const bodyPix = (videoOrOptionsOrCallback, optionsOrCallback, cb) => {
428436
let video;
429437
let options = {};

0 commit comments

Comments
 (0)