From 1d9148e09f101bd74dc49392fbef0b589e1ebcff Mon Sep 17 00:00:00 2001 From: Cristobal Valenzuela Date: Sat, 2 Jun 2018 21:10:07 -0400 Subject: [PATCH] remake posenet results so they are now grouped into one single array --- src/ImageAndVideo.js | 4 +++- src/PoseNet/index.js | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ImageAndVideo.js b/src/ImageAndVideo.js index 31a636dc3..57635fe84 100644 --- a/src/ImageAndVideo.js +++ b/src/ImageAndVideo.js @@ -15,7 +15,9 @@ class ImageAndVideo { this.videoReady = false; this.onVideoReady = () => { this.videoReady = true; - this.waitingPredictions.forEach(i => this.predict(i.imgToPredict, i.num, i.callback)); + if (this.waitingPredictions) { + this.waitingPredictions.forEach(i => this.predict(i.imgToPredict, i.num, i.callback)); + } }; if (video instanceof HTMLVideoElement) { diff --git a/src/PoseNet/index.js b/src/PoseNet/index.js index 302de465b..bf47f1a1f 100644 --- a/src/PoseNet/index.js +++ b/src/PoseNet/index.js @@ -80,7 +80,7 @@ class PoseNet extends ImageAndVideo { this.net.estimateSinglePose(input, this.imageScaleFactor, this.flipHorizontal, this.outputStride) .then((pose) => { - callback([pose]); + callback([{ pose, skeleton: this.skeleton(pose.keypoints) }]); tf.nextFrame().then(() => { this.singlePose(callback); }); }); } @@ -99,7 +99,8 @@ class PoseNet extends ImageAndVideo { this.net.estimateMultiplePoses(input, this.imageScaleFactor, this.flipHorizontal, this.outputStride) .then((poses) => { - callback(poses); + const result = poses.map(pose => ({ pose, skeleton: this.skeleton(pose.keypoints) })); + callback(result); tf.nextFrame().then(() => { this.multiPose(callback); }); }); }