Skip to content

Commit

Permalink
remake posenet results so they are now grouped into one single array
Browse files Browse the repository at this point in the history
  • Loading branch information
cvalenzuela committed Jun 3, 2018
1 parent 9c44ab8 commit 1d9148e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/ImageAndVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 comment has been minimized.

Copy link
@oveddan

oveddan Jun 5, 2018

Contributor

This shouldn't really be a responsibility of this class...This class should just be loading a video and calling back when its done. Executing of waiting predictions should be done by whoever is consuming this and needs to wait for the callback.

This comment has been minimized.

Copy link
@cvalenzuela

cvalenzuela Jun 6, 2018

Author Member

Yes, I agree. We should keep this class as general as possible avoiding this kind of specific functionality. thanks for pointing this out!

this.waitingPredictions.forEach(i => this.predict(i.imgToPredict, i.num, i.callback));
}
};

if (video instanceof HTMLVideoElement) {
Expand Down
5 changes: 3 additions & 2 deletions src/PoseNet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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); });
});
}
Expand All @@ -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); });
});
}
Expand Down

0 comments on commit 1d9148e

Please sign in to comment.