Published
Edited
Jul 21, 2018
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
webcam = {
if (enableWebcam) {
const stream = navigator.mediaDevices
? navigator.mediaDevices.getUserMedia({video: true})
: new Promise((y, n) => navigator.getUserMedia({video: true}, y, n));
const video = html`<video width=227 height=227 autoplay=true playsinline=true></video>`;
video.style.maxWidth = "100%";
const vid = await stream.then(stream => {
if ("srcObject" in video) video.srcObject = stream;
else video.src = URL.createObjectURL(stream);
invalidation.then(() => {
stream.getTracks().forEach(t => t.stop());
URL.revokeObjectURL(video.src);
});
return video;
});
return vid;
}
}
Insert cell
output = {
while(true) {
let imageScaleFactor = 0.5;
let outputStride = 16;
let flipHorizontal = false;

let imageElement = webcam

yield pn.load().then(function(net){
return net.estimateSinglePose(imageElement, imageScaleFactor, flipHorizontal, outputStride)
}).then(function(pose){
return pose["keypoints"]
})
}
}
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more