How to use pose method in wpt

Best JavaScript code snippet using wpt

result.js

Source:result.js Github

copy

Full Screen

1var started = false;2var replaynose = false;3var replaynosewithleg = false;4var replaynosewithhip = false;5var video;6var videofile;7let img;8let poseNet;9let poses = [];10let history;11let p = 0;12let v = 0;13let posetimes = 0;14// set some options15let options = {16 architecture: 'ResNet50',17 imageScaleFactor: 0.50,18 outputStride: 32,19 flipHorizontal: false,20 minConfidence: 0,21 maxPoseDetections: 1,22 scoreThreshold: 0,23 nmsRadius: 20,24 detectionType: 'single',25 inputResolution: 640,26 //multiplier: 1,27 quantBytes: 4,28};29var username;30var counter = 0;31var runvideo;32//json33var txt = '{"pose":[]}';34var obj = JSON.parse(txt);35var objnose = JSON.parse(txt);36var objleftleg = JSON.parse(txt);37var objrightleg = JSON.parse(txt);38var objleftElbow = JSON.parse(txt);39var objrightElbow = JSON.parse(txt);40var objleftWrist = JSON.parse(txt);41var objrightWrist = JSON.parse(txt);42var objleftHip = JSON.parse(txt);43var objrightHip = JSON.parse(txt);44var objleftShoulder = JSON.parse(txt);45var objrightShoulder = JSON.parse(txt);46var leftlegmin = JSON.parse(txt);47var leftlegmin2 = JSON.parse(txt);48var leftlegmin3 = JSON.parse(txt);49var rightlegmin = JSON.parse(txt);50var rightlegmin2 = JSON.parse(txt);51var rightlegmin3 = JSON.parse(txt);52function setup() {53 canvas = createCanvas(1280, 720);54 canvas.parent("canvasplacement");55 var button = createButton("Show head movement");56 button.mousePressed(drawheadwithvideo);57 button.parent("btnplacement");58 var button = createButton("Show head with hip movement");59 button.mousePressed(drawheadwithhipvideo);60 button.parent("btnplacement");61 var button = createButton("Show head with feet land movement");62 button.mousePressed(drawheadwithlegvideo);63 button.parent("btnplacement");64}65function startSketch() {66 canvas.background(204);67 68 video = createVideo(videofile);69 video.id("test");70 video.size(1280, 720);71 video.speed(0.1);72 video.volume(0);73 video.onended(sayDone);74 video.hide();75 poseNet = ml5.poseNet(video, options, modelReady);76 started = true;77}78// put the pose event callback in a variable79callback = function (results) {80 poses = results;81 console.log(poses);82}83function sayDone() {84 var videotest = document.getElementById("test");85 videoduration = videotest.duration;86 started = false;87 videotest.remove();88 // stop listening to pose detection events by removing the event listener89 poseNet.removeListener('pose', callback);90 console.log("ended");91 console.log(obj);92 put();93 getrightleg();94 getleftleg();95 analysis();96 poses = 0;97}98function modelReady() {99 console.log('model ready');100 started = true;101 video.play();102 // start listening to pose detection events103 poseNet.on('pose', callback);104}105function draw() {106 if (started) {107 image(video, 0, 0, 1280, 720);108 if (poses.length > 0) {109 drawSkeleton();110 drawKeypoints();111 }112 if (replaynose == true) {113 nose();114 } else if (replaynosewithleg == true) {115 nosewithleg();116 } else if (replaynosewithhip == true) {117 nosewithhip();118 }119 }120}121var leftlegperx = 0;122var leftlegpery = 0;123var rightlegperx = 0;124var rightlegpery = 0;125var leftElbowx = 0;126var leftElbowy = 0;127var rightElbowx = 0;128var rightElbowy = 0;129var leftWristx = 0;130var leftWristy = 0;131var rightWristx = 0;132var rightWristy = 0;133var leftHipx = 0;134var leftHipy = 0;135var rightHipx = 0;136var rightHipy = 0;137var leftShoulderx = 0;138var leftShouldery = 0;139var rightShoulderx = 0;140var rightShouldery = 0;141function drawKeypoints() {142 for (let i = 0; i < poses.length; i++) {143 let pose = poses[i].pose;144 for (let j = 0; j < pose.keypoints.length; j++) {145 let keypoint = pose.keypoints[j];146 if (keypoint.position.x < 1280 && keypoint.position.y < 720) {147 fill(255);148 stroke(20);149 strokeWeight(4);150 ellipse(round(keypoint.position.x), round(keypoint.position.y), 16);151 obj['pose'].push({ "part": keypoint.part, "x": keypoint.position.x, "y": keypoint.position.y });152 }153 }154 }155}156function put() {157 for (let j = 0; j < obj.pose.length; j++) {158 switch (obj.pose[j].part) {159 case "nose":160 objnose['pose'].push({ "x": obj.pose[j].x, "y": obj.pose[j].y });161 break;162 case "leftAnkle":163 if (Math.round(leftlegperx) == Math.round(obj.pose[j].x) && Math.round(leftlegpery) == Math.round(obj.pose[j].y)) {164 leftlegperx = Math.round(obj.pose[j].x);165 leftlegpery = Math.round(obj.pose[j].y);166 } else {167 objleftleg['pose'].push({ "x": Math.round(obj.pose[j].x), "y": Math.round(obj.pose[j].y) });168 leftlegperx = Math.round(obj.pose[j].x);169 leftlegpery = Math.round(obj.pose[j].y);170 }171 break;172 case "rightAnkle":173 if (Math.round(rightlegperx) == Math.round(obj.pose[j].x) && Math.round(rightlegpery) == Math.round(obj.pose[j].y)) {174 rightlegperx = Math.round(obj.pose[j].x);175 rightlegpery = Math.round(obj.pose[j].y);176 } else {177 objrightleg['pose'].push({ "x": Math.round(obj.pose[j].x), "y": Math.round(obj.pose[j].y) });178 rightlegperx = Math.round(obj.pose[j].x);179 rightlegpery = Math.round(obj.pose[j].y);180 }181 break;182 case "leftElbow":183 if (Math.round(leftElbowx) == Math.round(obj.pose[j].x) && Math.round(leftElbowy) == Math.round(obj.pose[j].y)) {184 leftElbowx = Math.round(obj.pose[j].x);185 leftElbowy = Math.round(obj.pose[j].y);186 } else {187 objleftElbow['pose'].push({ "x": Math.round(obj.pose[j].x), "y": Math.round(obj.pose[j].y) });188 leftElbowx = Math.round(obj.pose[j].x);189 leftElbowy = Math.round(obj.pose[j].y);190 }191 break;192 case "rightElbow":193 if (Math.round(rightElbowx) == Math.round(obj.pose[j].x) && Math.round(rightElbowy) == Math.round(obj.pose[j].y)) {194 rightElbowx = Math.round(obj.pose[j].x);195 rightElbowy = Math.round(obj.pose[j].y);196 } else {197 objrightElbow['pose'].push({ "x": Math.round(obj.pose[j].x), "y": Math.round(obj.pose[j].y) });198 rightElbowx = Math.round(obj.pose[j].x);199 rightElbowy = Math.round(obj.pose[j].y);200 }201 break;202 case "leftWrist":203 if (Math.round(leftWristx) == Math.round(obj.pose[j].x) && Math.round(leftWristy) == Math.round(obj.pose[j].y)) {204 leftWristx = Math.round(obj.pose[j].x);205 leftWristy = Math.round(obj.pose[j].y);206 } else {207 objleftWrist['pose'].push({ "x": Math.round(obj.pose[j].x), "y": Math.round(obj.pose[j].y) });208 leftWristx = Math.round(obj.pose[j].x);209 leftWristy = Math.round(obj.pose[j].y);210 }211 break;212 case "rightWrist":213 if (Math.round(rightWristx) == Math.round(obj.pose[j].x) && Math.round(rightWristy) == Math.round(obj.pose[j].y)) {214 rightWristx = Math.round(obj.pose[j].x);215 rightWristy = Math.round(obj.pose[j].y);216 } else {217 objrightWrist['pose'].push({ "x": Math.round(obj.pose[j].x), "y": Math.round(obj.pose[j].y) });218 rightWristx = Math.round(obj.pose[j].x);219 rightWristy = Math.round(obj.pose[j].y);220 }221 break;222 case "leftHip":223 if (Math.round(leftHipx) == Math.round(obj.pose[j].x) && Math.round(leftHipy) == Math.round(obj.pose[j].y)) {224 leftHipx = Math.round(obj.pose[j].x);225 leftHipy = Math.round(obj.pose[j].y);226 } else {227 objleftHip['pose'].push({ "x": Math.round(obj.pose[j].x), "y": Math.round(obj.pose[j].y) });228 leftHipx = Math.round(obj.pose[j].x);229 leftHipy = Math.round(obj.pose[j].y);230 }231 break;232 case "rightHip":233 if (Math.round(rightHipx) == Math.round(obj.pose[j].x) && Math.round(rightHipy) == Math.round(obj.pose[j].y)) {234 rightHipx = Math.round(obj.pose[j].x);235 rightHipy = Math.round(obj.pose[j].y);236 } else {237 objrightHip['pose'].push({ "x": Math.round(obj.pose[j].x), "y": Math.round(obj.pose[j].y) });238 rightHipx = Math.round(obj.pose[j].x);239 rightHipy = Math.round(obj.pose[j].y);240 }241 case "leftShoulder":242 if (Math.round(leftShoulderx) == Math.round(obj.pose[j].x) && Math.round(leftShouldery) == Math.round(obj.pose[j].y)) {243 leftShoulderx = Math.round(obj.pose[j].x);244 leftShouldery = Math.round(obj.pose[j].y);245 } else {246 objleftShoulder['pose'].push({ "x": Math.round(obj.pose[j].x), "y": Math.round(obj.pose[j].y) });247 leftShoulderx = Math.round(obj.pose[j].x);248 leftShouldery = Math.round(obj.pose[j].y);249 }250 case "rightShoulder":251 if (Math.round(rightShoulderx) == Math.round(obj.pose[j].x) && Math.round(rightShouldery) == Math.round(obj.pose[j].y)) {252 rightShoulderx = Math.round(obj.pose[j].x);253 rightShouldery = Math.round(obj.pose[j].y);254 } else {255 objrightShoulder['pose'].push({ "x": Math.round(obj.pose[j].x), "y": Math.round(obj.pose[j].y) });256 rightShoulderx = Math.round(obj.pose[j].x);257 rightShouldery = Math.round(obj.pose[j].y);258 }259 break;260 default:261 break;262 }263 }264}265// A function to draw the skeletons266function drawSkeleton() {267 // Loop through all the skeletons detected268 for (let i = 0; i < poses.length; i++) {269 let skeleton = poses[i].skeleton;270 // For every skeleton, loop through all body connections271 for (let j = 0; j < skeleton.length; j++) {272 let partA = skeleton[j][0];273 let partB = skeleton[j][1];274 stroke(255);275 strokeWeight(1);276 line(partA.position.x, partA.position.y, partB.position.x, partB.position.y);277 }278 }279}280var firebaseConfig = {281 apiKey: "AIzaSyC1F1-cFM8sF5UhaXMo9BvyitciNCqEBf8",282 authDomain: "coacheyesweb.firebaseapp.com",283 projectId: "coacheyesweb",284 storageBucket: "coacheyesweb.appspot.com",285 messagingSenderId: "395470429039",286 appId: "1:395470429039:web:89af61796c5166afc8e69a",287 measurementId: "G-PXJ8NPH1E6"288};289// Initialize Firebase290firebase.initializeApp(firebaseConfig);291var firestore = firebase.firestore();292function register() {293 //get input value294 var email = document.getElementById("regemail").value;295 var name = document.getElementById("regname").value;296 var pw = document.getElementById("regpw").value;297 //see account exist298 //get collection299 var docRef = firestore.collection("users").doc(email);300 docRef.get().then(function (doc) {301 if (doc && doc.exists) {302 alert("account already exist")303 } else {304 //get collection305 var docRef = firestore.collection("users").doc(email);306 docRef.set({307 name: name,308 password: pw309 }).then(function () {310 alert("Registered");311 //redirect312 closeRegisterForm();313 }).catch(function (error) {314 alert("NO");315 console.log(error)316 });317 }318 });319}320var username;321//login322function login() {323 //get input value324 var email = document.getElementById("email").value;325 var pw = document.getElementById("pw").value;326 //get collection327 var docRef = firestore.collection("users").doc(email);328 docRef.get().then(function (doc) {329 if (doc && doc.exists) {330 const myData = doc.data();331 if (myData.password == pw) {332 alert("Logined");333 //redirect334 window.name = email;335 window.location.href = "userhome.html";336 } else {337 alert("password wrong");338 }339 } else {340 alert("no")341 }342 }).catch(function (error) {343 alert("no");344 console.log("Got an error", error);345 })346}347function logout() {348 //redirect349 username = "";350 window.location.href = "index.html";351}352window.onload = function () {353 //get elements354 var uploader = document.getElementById("uploader");355 var fileButton = document.getElementById("fileButton");356 fileButton.addEventListener('change', function (e) {357 //get file358 var file = e.target.files[0];359 //create storage reference360 var storageRef = firebase.storage().ref('test/' + file.name);361 //upload file362 var task = storageRef.put(file);363 //update progress bar364 task.on('state_changed',365 function progress(snapshot) {366 var percentage = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;367 uploader.value = percentage;368 },369 function error(err) {370 alert("error");371 },372 function complete() {373 console.log("upload completed");374 task.snapshot.ref.getDownloadURL().then((downloadURL) => {375 console.log('File available at', downloadURL);376 videofile = downloadURL;377 startSketch();378 });379 });380 });381 console.log("loaded firebase");382}383function uploadresult() {384 console.log("username: " + window.name);385 var d = new Date();386 var date = d.getFullYear() + "" + ((d.getMonth() > 9 ? '' : '0') + (d.getMonth() + 1) + "" + (d.getDate() > 9 ? '' : '0') + d.getDate() + "" + d.getHours() + "" + d.getMinutes() + "" + d.getSeconds());387 var docRef = firestore.collection("results").doc(window.name).collection("testresult").doc(date);388 docRef.set({389 videofile: videofile,390 headbounching: headbounching + " (" + headbounchinggrade + ")",391 cadences: cadences + " (" + cadencesgrade + ")",392 hipresult: hipresult,393 headlandfeet: headlandfeet2,394 headjson: objnose,395 leftlegjson: objleftleg,396 rightlegjson: objrightleg,397 rightlegmin2json: rightlegmin2,398 leftlegmin2json: leftlegmin2,399 objleftHipjson: objleftHip,400 totalgrade: totalgrade401 }).then(function () {402 alert("Uploaded result");403 }).catch(function (error) {404 alert("NO");405 console.log(error)406 });407}408function showresult() {409 //get collection410 var docRef = firestore.collection("results").doc("demo2");411 docRef.get().then(function (doc) {412 console.log(doc.data())413 })414}415//Get History416function gethistory() {417 var x = document.createElement("SELECT");418 x.setAttribute("id", "mySelect");419 x.setAttribute("onChange", "loadhistory()");420 document.getElementById("historyselect").appendChild(x);421 firestore.collection("results").doc(window.name).collection("testresult").get().then((querySnapshot) => {422 querySnapshot.forEach((doc) => {423 // doc.data() is never undefined for query doc snapshots424 console.log(doc.id);425 // var table = document.getElementById("historytable");426 // var row = table.insertRow(1);427 // var cell1 = row.insertCell(0);428 // cell1.innerHTML = doc.id;429 // row.setAttribute("type", "button");430 // row.setAttribute("id", doc.id);431 // row.setAttribute("class", "datebutton");432 // row.setAttribute("onclick", "loadhistory(this.id);");433 //row.onclick = function(){ loadhistory(this.id); };434 var z = document.createElement("option");435 z.setAttribute("value", doc.id);436 var t = document.createTextNode(doc.id);437 z.appendChild(t);438 document.getElementById("mySelect").appendChild(z);439 });440 });441}442function loadhistory() {443 var clicked_id = document.getElementById("mySelect").value;444 counter = 0;445 clear();446 background(204);447 //get collection448 var docRef = firestore.collection("results").doc(window.name).collection("testresult").doc(clicked_id);449 docRef.get().then(function (doc) {450 history = doc.data();451 //console.log("thing "+history.cadences);452 document.getElementById("r1").innerHTML = "headbounc: " + history.headbounching +"%";453 document.getElementById("r2").innerHTML = history.hipresult;454 document.getElementById("r3").innerHTML = history.headlandfeet;455 document.getElementById("r4").innerHTML = "cadences: " + history.cadences;456 document.getElementById("totalgrade").innerHTML = "totalgrade: " + history.totalgrade;457 objnose = history.headjson;458 objleftleg = history.leftlegjson;459 objrightleg = history.rightlegjson;460 leftlegmin2 = history.leftlegmin2json;461 rightlegmin2 = history.rightlegmin2json;462 objleftHip = history.objleftHipjson;463 videofile = history.videofile;464 });465}466function leftleg() {467 console.log(objleftleg);468 clear();469 background(205);470 for (i = 0; i < objleftleg.pose.length; i++) {471 fill('yellow');472 noStroke();473 ellipse(round(objleftleg.pose[i].x), round(objleftleg.pose[i].y), 8, 8);474 }475}476function rightleg() {477 history = obj;478 clear();479 background(205);480 for (i = 0; i < history.pose.length; i++) {481 if (history.pose[i].part == "rightAnkle") {482 fill('green');483 noStroke();484 ellipse(round(history.pose[i].x), round(history.pose[i].y), 8, 8);485 }486 }487}488function nose() {489 for (i = 0; i < objnose.pose.length; i++) {490 fill('red');491 noStroke();492 ellipse(round(objnose.pose[i].x), round(objnose.pose[i].y), 8, 8);493 }494}495function nosewithleg() {496 for (i = 0; i < objnose.pose.length; i++) {497 //head498 fill('red');499 noStroke();500 ellipse(round(objnose.pose[i].x), round(objnose.pose[i].y), 8, 8);501 }502 for (i = 0; i < objleftleg.pose.length; i++) {503 fill('yellow');504 noStroke();505 ellipse(round(objleftleg.pose[i].x), round(objleftleg.pose[i].y), 8, 8);506 for (l = 0; l < leftlegmin2.pose.length; l++) {507 if (objleftleg.pose[i].x == leftlegmin2.pose[l].x) {508 fill('yellow');509 stroke(50);510 ellipse(round(leftlegmin2.pose[l].x), round(leftlegmin2.pose[l].y), 8, 8);511 }512 }513 }514 for (i = 0; i < objrightleg.pose.length; i++) {515 fill('purple');516 noStroke();517 ellipse(round(objrightleg.pose[i].x), round(objrightleg.pose[i].y), 8, 8);518 for (m = 0; m < rightlegmin2.pose.length; m++) {519 if (objrightleg.pose[i].x == rightlegmin2.pose[m].x) {520 fill('purple');521 stroke(50);522 ellipse(round(rightlegmin2.pose[m].x), round(rightlegmin2.pose[m].y), 8, 8);523 }524 }525 }526}527function nosewithhip() {528 for (i = 0; i < objnose.pose.length; i++) {529 //head530 fill('red');531 noStroke();532 ellipse(round(objnose.pose[i].x), round(objnose.pose[i].y), 8, 8);533 }534 for (i = 0; i < objleftHip.pose.length; i++) {535 fill('green');536 noStroke();537 ellipse(round(objleftHip.pose[i].x), round(objleftHip.pose[i].y), 8, 8);538 }539}540var countertest;541countertest = 0;542var countertest2;543countertest2 = 0;544// function nosewithhip() {545// setTimeout(function () {546// //head547// fill('red');548// stroke(100);549// ellipse(round(objnose.pose[countertest].x), round(objnose.pose[countertest].y), 8, 8);550// countertest++;551// if (countertest < objnose.pose.length) {552// nosewithhip();553// } else {554// countertest = 0;555// }556// }, 4000)557// }558// function nosewithhip2() {559// setTimeout(function () {560// fill('green');561// stroke(100);562// ellipse(round(objleftHip.pose[countertest2].x), round(objleftHip.pose[countertest2].y), 8, 8);563// countertest2++;564// if (countertest2 < objleftHip.pose.length) {565// nosewithhip();566// } else {567// countertest2 = 0;568// }569// }, 4000)570// }571var headmaxX;572var headmaxY;573var headmax;574var headminX;575var headminY;576var headmin;577var newnum = 0;578var oldnum = 0;579var headbounching = 0;580var vid;581var videoduration;582var cadences = 0;583var cadencesgrade;584var cadencesgradenum;585var headbounchinggrade;586var headbounchinggradenum;587var hipgrade;588var hipgradenum;589var headlandfeetgrade;590var headlandfeetgradenum;591var totalgrade;592var totalgradenum;593function analysis() {594 cadencesgrade = "";595 cadencesgradenum = 0;596 headbounchinggrade = "";597 headbounchinggradenum = 0;598 hipgrade = "";599 hipgradenum = 0;600 headlandfeetgrade = "";601 headlandfeetgradenum = 0;602 totalgrade = "";603 totalgradenum = 0;604 console.log("ANALYSIS START");605 //is head bouncing?606 getheadmax();607 getheadmin();608 newnum = headmaxY;609 oldnum = headminY;610 headbounching = ((newnum - oldnum) / oldnum) * 100;611 console.log("headbounc: " + Math.round(headbounching));612 //headpostion with landing, print nose with rightleg and leftleg613 getfootland();614 //arms615 //console.log();616 //hips617 gethippostion();618 //cadences footstep x time619 cadences = ((rightlegmin3.pose.length + leftlegmin3.pose.length) / Math.round(videoduration)) * 60;620 console.log("cadences: " + cadences);621 //grade622 if (headbounching < 25) {623 headbounchinggrade = "A";624 headbounchinggradenum = 3625 } else if (headbounching > 25 && headbounching < 50) {626 headbounchinggrade = "B"627 headbounchinggradenum = 2628 } else {629 headbounchinggrade = "C"630 headbounchinggradenum = 1631 }632 if (cadences > 180) {633 cadencesgrade = "A";634 cadencesgradenum = 3635 } else if (cadences < 180 && cadences > 160) {636 cadencesgrade = "B"637 cadencesgradenum = 2638 } else {639 cadencesgrade = "C"640 cadencesgradenum = 1641 }642 console.log("ANALYSIS END");643 document.getElementById("r1").innerHTML = "headbounc: " + Math.round(headbounching) + " (" + headbounchinggrade + ")" + "%";644 document.getElementById("r4").innerHTML = "cadences: " + cadences + " (" + cadencesgrade + ")";645 totalgradenum = cadencesgradenum + headbounchinggradenum + headlandfeetgradenum + hipgradenum;646 if (totalgradenum / 4 >= 2.5) { totalgrade = "A" } else if (totalgradenum / 4 > 2 && totalgradenum / 4 < 2.5) { totalgrade = "B" } else { totalgrade = "C" }647 console.log(totalgradenum);648 document.getElementById("totalgrade").innerHTML = "totalgrade: " + totalgrade;649 //uploadresult650 uploadresult();651}652var hipresult;653function gethippostion() {654 var hip = 0;655 for (i = 0; i < objleftHip.pose.length; i++) {656 if (objnose.pose[i].x - objleftHip.pose[i].x < 50 && objnose.pose[i].x - objleftHip.pose[i].x > -50) {657 hip++;658 }659 }660 if (objleftHip.pose.length - hip <= 5) {661 hipgrade = "A";662 hipgradenum = 3663 } else if (objleftHip.pose.length - hip > 5 && objleftHip.pose.length - hip < 100) {664 hipgrade = "B"665 hipgradenum = 2666 } else {667 hipgrade = "C"668 hipgradenum = 1669 }670 console.log("hip in best postion: " + hip + " / " + objleftHip.pose.length);671 document.getElementById("r2").innerHTML = "hip in best postion: " + hip + " / " + objleftHip.pose.length + " (" + hipgrade + ")";672 hipresult = "hip in best postion: " + hip + " / " + objleftHip.pose.length + " / " + objleftHip.pose.length + " (" + hipgrade + ")";673}674var headlandfeet2;675function getfootland() {676 var headlandfeet = 0;677 for (i = 0; i < objleftleg.pose.length; i++) {678 for (l = 0; l < leftlegmin2.pose.length; l++) {679 if (objleftleg.pose[i].x == leftlegmin2.pose[l].x) {680 if (objnose.pose[i].x - leftlegmin2.pose[l].x > -20 && objnose.pose[i].x - leftlegmin2.pose[l].x < 20) {681 headlandfeet++;682 break;683 }684 }685 }686 }687 for (i = 0; i < objrightleg.pose.length; i++) {688 for (m = 0; m < rightlegmin2.pose.length; m++) {689 if (objrightleg.pose[i].x == rightlegmin2.pose[m].x) {690 if (objnose.pose[i].x - rightlegmin2.pose[m].x > -20 && objnose.pose[i].x - rightlegmin2.pose[m].x < 20) {691 headlandfeet++;692 break;693 }694 }695 }696 }697 if ((leftlegmin2.pose.length + rightlegmin2.pose.length) - headlandfeet <= 5) {698 headlandfeetgrade = "A";699 headlandfeetgradenum = 3700 } else if ((leftlegmin2.pose.length + rightlegmin2.pose.length) - headlandfeet > 5 && (leftlegmin2.pose.length + rightlegmin2.pose.length) - headlandfeet < 100) {701 headlandfeetgrade = "B"702 headlandfeetgradenum = 2703 } else {704 headlandfeetgrade = "C"705 headlandfeetgradenum = 1706 }707 console.log("head land feet: " + headlandfeet + " / " + (leftlegmin2.pose.length + rightlegmin2.pose.length));708 headlandfeet2 = "head land feet: " + headlandfeet + " / " + (leftlegmin2.pose.length + rightlegmin2.pose.length) + " (" + headlandfeetgrade + ")";709 document.getElementById("r3").innerHTML = "head land feet: " + headlandfeet + " / " + (leftlegmin2.pose.length + rightlegmin2.pose.length) + " (" + headlandfeetgrade + ")";710}711function getheadmax() {712 history = objnose;713 //console.log(history);714 headmaxY = 0;715 for (i = 0; i < history.pose.length; i++) {716 if (history.pose[i].y > 1080) {717 continue;718 } else if (history.pose[i].y > headmaxY) {719 //headmax = history.pose[i];720 headmaxX = history.pose[i].x;721 headmaxY = history.pose[i].y;722 }723 }724 return headmaxY;725}726function getheadmin() {727 history = objnose;728 headminY = history.pose[0].y;729 for (i = 0; i < history.pose.length; i++) {730 if (history.pose[i].y < headminY) {731 headminY = history.pose[i].y;732 headminX = history.pose[i].x;733 }734 }735 //console.log("headminX: " + headminX + " headminY: " + headminY);736 return headminY;737}738var leftlegfirst;739var leftlegnow;740var leftlegnext;741var gg;742function getleftleg() {743 leftlegfirst = objleftleg.pose[0].y;744 leftlegnow = objleftleg.pose[1].y;745 leftlegnext = objleftleg.pose[2].y;746 for (i = 0; i < objleftleg.pose.length; i++) {747 gg = i + 2;748 if (gg < objleftleg.pose.length) {749 leftlegfirst = objleftleg.pose[i + 0].y;750 leftlegnow = objleftleg.pose[i + 1].y;751 leftlegnext = objleftleg.pose[i + 2].y;752 //console.log(objleftleg.pose[i + 1].y);753 if (leftlegfirst <= leftlegnow && leftlegnext <= leftlegnow) {754 leftlegmin['pose'].push({ "x": objleftleg.pose[i + 1].x, "y": objleftleg.pose[i + 1].y });755 }756 }757 }758 //doagain759 leftlegfirst = leftlegmin.pose[0].y;760 leftlegnow = leftlegmin.pose[1].y;761 leftlegnext = leftlegmin.pose[2].y;762 for (i = 0; i < leftlegmin.pose.length; i++) {763 gg = i + 2;764 if (gg < leftlegmin.pose.length) {765 leftlegfirst = leftlegmin.pose[i + 0].y;766 leftlegnow = leftlegmin.pose[i + 1].y;767 leftlegnext = leftlegmin.pose[i + 2].y;768 //console.log(objleftleg.pose[i + 1].y);769 if (leftlegfirst <= leftlegnow && leftlegnext <= leftlegnow) {770 leftlegmin2['pose'].push({ "x": leftlegmin.pose[i + 1].x, "y": leftlegmin.pose[i + 1].y });771 }772 }773 }774 //doagain775 leftlegfirst = leftlegmin2.pose[0].y;776 leftlegnow = leftlegmin2.pose[1].y;777 leftlegnext = leftlegmin2.pose[2].y;778 for (i = 0; i < leftlegmin2.pose.length; i++) {779 gg = i + 2;780 if (gg < leftlegmin2.pose.length) {781 leftlegfirst = leftlegmin2.pose[i + 0].y;782 leftlegnow = leftlegmin2.pose[i + 1].y;783 leftlegnext = leftlegmin2.pose[i + 2].y;784 //console.log(objleftleg.pose[i + 1].y);785 if (leftlegfirst <= leftlegnow && leftlegnext <= leftlegnow) {786 leftlegmin3['pose'].push({ "x": leftlegmin2.pose[i + 1].x, "y": leftlegmin2.pose[i + 1].y });787 }788 }789 }790}791//dorightleg792var rightlegfirst;793var rightlegnow;794var rightlegnext;795var gg;796function getrightleg() {797 rightlegfirst = objrightleg.pose[0].y;798 rightlegnow = objrightleg.pose[1].y;799 rightlegnext = objrightleg.pose[2].y;800 for (i = 0; i < objrightleg.pose.length; i++) {801 gg = i + 2;802 if (gg < objrightleg.pose.length) {803 rightlegfirst = objrightleg.pose[i + 0].y;804 rightlegnow = objrightleg.pose[i + 1].y;805 rightlegnext = objrightleg.pose[i + 2].y;806 //console.log(objrightleg.pose[i + 1].y);807 if (rightlegfirst <= rightlegnow && rightlegnext <= rightlegnow) {808 rightlegmin['pose'].push({ "x": objrightleg.pose[i + 1].x, "y": objrightleg.pose[i + 1].y });809 }810 }811 }812 //doagain813 rightlegfirst = rightlegmin.pose[0].y;814 rightlegnow = rightlegmin.pose[1].y;815 rightlegnext = rightlegmin.pose[2].y;816 for (i = 0; i < rightlegmin.pose.length; i++) {817 gg = i + 2;818 if (gg < rightlegmin.pose.length) {819 rightlegfirst = rightlegmin.pose[i + 0].y;820 rightlegnow = rightlegmin.pose[i + 1].y;821 rightlegnext = rightlegmin.pose[i + 2].y;822 //console.log(objrightleg.pose[i + 1].y);823 if (rightlegfirst <= rightlegnow && rightlegnext <= rightlegnow) {824 rightlegmin2['pose'].push({ "x": rightlegmin.pose[i + 1].x, "y": rightlegmin.pose[i + 1].y });825 }826 }827 }828 //doagain829 rightlegfirst = rightlegmin2.pose[0].y;830 rightlegnow = rightlegmin2.pose[1].y;831 rightlegnext = rightlegmin2.pose[2].y;832 for (i = 0; i < rightlegmin2.pose.length; i++) {833 gg = i + 2;834 if (gg < rightlegmin2.pose.length) {835 rightlegfirst = rightlegmin2.pose[i + 0].y;836 rightlegnow = rightlegmin2.pose[i + 1].y;837 rightlegnext = rightlegmin2.pose[i + 2].y;838 //console.log(objrightleg.pose[i + 1].y);839 if (rightlegfirst <= rightlegnow && rightlegnext <= rightlegnow) {840 rightlegmin3['pose'].push({ "x": rightlegmin2.pose[i + 1].x, "y": rightlegmin2.pose[i + 1].y });841 }842 }843 }844}845function printrightlegpoint1() {846 clear();847 console.log(rightlegmin);848 background(205);849 for (i = 0; i < rightlegmin.pose.length; i++) {850 fill('yellow');851 strokeWeight(4);852 stroke(51);853 ellipse(round(rightlegmin.pose[i].x), round(rightlegmin.pose[i].y), 8, 8);854 }855}856function printrightlegpoint2() {857 clear();858 console.log(rightlegmin2);859 background(205);860 for (i = 0; i < rightlegmin2.pose.length; i++) {861 fill('yellow');862 strokeWeight(4);863 stroke(51);864 ellipse(round(rightlegmin2.pose[i].x), round(rightlegmin2.pose[i].y), 8, 8);865 }866}867function printrightlegpoint3() {868 clear();869 console.log(rightlegmin3);870 background(205);871 for (i = 0; i < rightlegmin3.pose.length; i++) {872 fill('yellow');873 strokeWeight(4);874 stroke(51);875 ellipse(round(rightlegmin3.pose[i].x), round(rightlegmin3.pose[i].y), 8, 8);876 }877}878function printleftlegpoint1() {879 clear();880 console.log(leftlegmin);881 background(205);882 for (i = 0; i < leftlegmin.pose.length; i++) {883 fill('yellow');884 strokeWeight(4);885 stroke(51);886 ellipse(round(leftlegmin.pose[i].x), round(leftlegmin.pose[i].y), 8, 8);887 }888}889function printleftlegpoint2() {890 clear();891 console.log(leftlegmin);892 background(205);893 for (i = 0; i < leftlegmin2.pose.length; i++) {894 fill('yellow');895 strokeWeight(4);896 stroke(52);897 ellipse(round(leftlegmin2.pose[i].x), round(leftlegmin2.pose[i].y), 8, 8);898 }899}900function printleftlegpoint3() {901 clear();902 console.log(leftlegmin);903 background(205);904 for (i = 0; i < leftlegmin3.pose.length; i++) {905 fill('yellow');906 strokeWeight(4);907 stroke(53);908 ellipse(round(leftlegmin3.pose[i].x), round(leftlegmin3.pose[i].y), 8, 8);909 }910}911function setvideo() {912 video = createVideo(videofile);913 video.id("test2");914 video.size(1280, 720);915 video.speed(0.1);916 video.volume(0);917 video.hide();918 started = true;919 video.play();920}921function endedwithnosave() {922 started = false;923 replaynose = false;924 var videotest2 = document.getElementById("test2");925 videoduration2 = videotest2.duration;926 videotest2.remove();927}928function drawheadwithvideo() {929 setvideo();930 video.onended(endedwithnosave);931 replaynose = true;932}933function endedwithnosavenoseleg() {934 started = false;935 replaynosewithleg = false;936 var videotest2 = document.getElementById("test2");937 videoduration2 = videotest2.duration;938 videotest2.remove();939}940function drawheadwithlegvideo() {941 setvideo();942 video.onended(endedwithnosavenoseleg);943 replaynosewithleg = true;944}945function endedwithnosavehip() {946 started = false;947 replaynosewithhip = false;948 var videotest2 = document.getElementById("test2");949 videoduration2 = videotest2.duration;950 videotest2.remove();951}952function drawheadwithhipvideo() {953 setvideo();954 video.onended(endedwithnosavehip);955 replaynosewithhip = true;956 nosewithhip();957 nosewithhip2();...

Full Screen

Full Screen

sketch.js

Source:sketch.js Github

copy

Full Screen

1// Copyright (c) 2019 ml52//3// This software is released under the MIT License.4// https://opensource.org/licenses/MIT5/* ===6ml5 Example7PoseNet example using p5.js8=== */9let video;10let poseNet;11let poses = [];12let fps = 16;13let poseClass = "Not detected yet";14let previousPose = 'Other';15let happyTime = 0;16let happyMoments = 0;17let shockTime = 0;18let shockMoments = 0;19let annoyTime = 0;20let annoyMoments = 0;21let temporaryVar = 0;22function setup() {23 createCanvas(640, 480);24 video = createCapture(VIDEO);25 video.size(width, height);26 // Create a new poseNet method with a single detection27 poseNet = ml5.poseNet(video, modelReady);28 // This sets up an event that fills the global variable "poses"29 // with an array every time new poses are detected30 poseNet.on('pose', function(results) {31 poses = results;32 });33 // Hide the video element, and just show the canvas34 video.hide();35}36function modelReady() {37 select('#status').html('Model Loaded');38}39function mousePressed(){40 console.log(JSON.stringify(poses))41}42function draw() {43 image(video, 0, 0, width, height);44 strokeWeight(2);45 if (poses.length > 0) {46 let pose = poses[0].pose;47 mousePressed();48 // Extract keypoints from each frame49 for (let i = 0; i < pose.keypoints.length; i++){50 let x = pose.keypoints[i].position.x;51 let y = pose.keypoints[i].position.y;52 fill(0,255,255);53 ellipse(x, y, 16, 16);54 }55 56 57 // For this assignment poses related to 3 emotions were selected: Happiness, Shock and Annoyance. 58 // In order to differentiate between these poses if-else statements with multiple conditions were written.59 60 ///// Pose "Happiness" is with both arms lifted high as if celebrating61 ///// Pose "Shock" is similar but with wrists around the head62 ///// Pose "Annoyed" is when arms are on the hips63 ///// Any pose outside these conditions will be classified as "Other"64 if ((pose['leftElbow'].y > pose['leftWrist'].y) && (pose['rightElbow'].y > pose['rightWrist'].y) 65 && ((pose['leftElbow'].x - pose['leftWrist'].x) < 20) && ((pose['rightElbow'].x - pose['rightWrist'].x) < 20) 66 && (pose['leftElbow'].y < pose['leftShoulder'].y)){67 previousPose = poseClass;68 poseClass = 'Happy';69 } else if ((pose['leftElbow'].y > pose['leftWrist'].y) && (pose['rightElbow'].y > pose['rightWrist'].y) 70 && (pose['leftElbow'].x > pose['leftWrist'].x) && (pose['rightElbow'].x < pose['rightWrist'].x) 71 && (pose['leftWrist'].y < pose['leftShoulder'].y)){72 previousPose = poseClass;73 poseClass = 'Shocked'; 74 } else if ((pose['leftElbow'].y < pose['leftWrist'].y) && (pose['rightElbow'].y < pose['rightWrist'].y) 75 && (pose['leftElbow'].x > pose['leftWrist'].x) && (pose['rightElbow'].x < pose['rightWrist'].x) 76 && (pose['leftWrist'].y > pose['leftShoulder'].y)){77 previousPose = poseClass;78 poseClass = 'Annoyed'; 79 } else {80 previousPose = poseClass;81 poseClass = 'Other';82 }83 84 85 // In order to get the stats on each pose, counters must be written:86 // However, as we are dealing with frame numbers rather than time data,87 // we have to use the frame per second ratio and by counting fps we estimate88 // time in seconds.89 // *In order to track how much time is spent on the current emotion pose, the variable90 // temporaryVar has been created. When the pose changed to another, it is reseted. 91 if (previousPose == poseClass) {92 if (poseClass == 'Happy') {93 happyTime = happyTime + 1;94 temporaryVar = temporaryVar + 1;95 } else if (poseClass == 'Shocked') {96 shockTime = shockTime + 1;97 temporaryVar = temporaryVar + 1;98 } else if (poseClass == 'Annoyed') {99 annoyTime = annoyTime + 1;100 temporaryVar = temporaryVar + 1;101 } else {102 }103 } else {104 // Whenever the emotion pose changes to another, the counter of happy/shock/annoyed moments will increment.105 // In order to eliminate the noise that occur when any emotion pose is selected accidentally for106 // a short period of time, the temporaryVar counter of previous pose has to be at least 2 times fps (or 2 seconds). 107 if (previousPose == 'Happy' && temporaryVar > (fps*2)) {108 happyMoments = happyMoments + 1;109 temporaryVar = 0;110 } else if (previousPose == 'Shocked' && temporaryVar > (fps*2)) {111 shockMoments = shockMoments + 1;112 temporaryVar = 0;113 } else if (previousPose == 'Annoyed' && temporaryVar > (fps*2)) {114 annoyMoments = annoyMoments + 1;115 temporaryVar = 0;116 }117 }118 119 120 121 // Now, in order to display class name on the screen, we use:122 // *The class name text changes its color depending on the class for convenience123 textSize(30);124 if (poseClass == 'Happy') {125 fill(0,255,0);126 } else if (poseClass == 'Shocked') {127 fill(255,255,0);128 } else if (poseClass == 'Annoyed') {129 fill(255,0,100);130 } else {131 fill(255, 255, 255);132 }133 text('Class: ' + poseClass, 10, 400);134 135 fill(255, 255, 255);136 textSize(15);137 text('Happiness moments (time): ' + happyMoments + ' (' + nf(happyTime/fps, 2, 2) + 's)', 10, 425);138 text('Shock moments (time): ' + shockMoments + ' (' + nf(shockTime/fps, 2, 2) + 's)', 10, 450);139 text('Annoyance moments (time): ' + annoyMoments + ' (' + nf(annoyTime/fps, 2, 2) + 's)', 10, 472);140 141}...

Full Screen

Full Screen

Pose.js

Source:Pose.js Github

copy

Full Screen

1var Pose = module.exports = function (data) {2 /**3 * Indicates whether this is a valid Pose object.4 */5 this.valid = data.hasOwnProperty("invalid") ? false : true;6 /**7 * The pose being recognized.8 */9 this.type = data.type;10 /**11 * Default pose type when no pose is being made (PoseTypeNone)12 */13 this.POSE_REST = 0;14 /**15 * Clenching fingers together to make a fist (PoseTypeFist)16 */17 this.POSE_FIST = 1;18 /**19 * Turning your palm towards yourself (PoseTypeWaveIn)20 */21 this.POSE_WAVE_IN = 2;22 /**23 * Turning your palm away from yourself (PoseTypeWaveOut)24 */25 this.POSE_WAVE_OUT = 3;26 /**27 * Spreading your fingers and extending your palm (PoseTypeFingersSpread)28 */29 this.POSE_FINGERS_SPREAD = 4;30 /**31 * Thumb to pinky (unlock)32 */33 this.POSE_RESERVED_1 = 5;34 /**35 * Thumb to pinky (unlock)36 */37 this.POSE_THUMB_TO_PINKY = 6;38};39Pose.prototype.isEqualTo = function (other) {40 return this.type == other.type;41};42/**43 * An invalid Pose object.44 *45 * You can use this Pose instance in comparisons testing46 * whether a given Pose instance is valid or invalid.47 *48 */49Pose.invalid = function() {50 return new Pose({ invalid: true, type: 65536 });51};52/**53 * Return a human-readable string representation of the pose.54 * @return55 *56 */57Pose.prototype.toString = function () {58 if(!this.valid) {59 return "[Pose invalid]";60 }61 switch (this.type) {62 case this.POSE_REST:63 return "[Pose type:" + this.type.toString() + " POSE_NONE]";64 break;65 case this.POSE_FIST:66 return "[Pose type:" + this.type.toString() + " POSE_FIST]";67 break;68 case this.POSE_WAVE_IN:69 return "[Pose type:" + this.type.toString() + " POSE_WAVE_IN]";70 break;71 case this.POSE_WAVE_OUT:72 return "[Pose type:" + this.type.toString() + " POSE_WAVE_OUT]";73 break;74 case this.POSE_FINGERS_SPREAD:75 return "[Pose type:" + this.type.toString() + " POSE_FINGERS_SPREAD]";76 break;77 case this.POSE_RESERVED_1:78 return "[Pose type:" + this.type.toString() + " POSE_RESERVED_1]";79 break;80 case this.POSE_THUMB_TO_PINKY:81 return "[Pose type:" + this.type.toString() + " POSE_THUMB_TO_PINKY]";82 break;83 default:84 break;85 }86 return "[Pose type:" + this.type.toString() + "]";...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3};4var webPageTest = new wpt('www.webpagetest.org', options);5 if (err) {6 console.log(err);7 } else {8 webPageTest.getTestResults(data.data.testId, function(err, data) {9 if (err) {10 console.log(err);11 } else {12 console.log(data.data.average.firstView);13 }14 });15 }16});17var wpt = require('webpagetest');18var options = {19};20var webPageTest = new wpt('www.webpagetest.org', options);21 if (err) {22 console.log(err);23 } else {24 console.log(data);25 }26});27var wpt = require('webpagetest');28var options = {29};30var webPageTest = new wpt('www.webpagetest.org', options);31webPageTest.getTestResults('140327_1M_1', function(err, data) {32 if (err) {33 console.log(err);34 } else {35 console.log(data);36 }37});38var wpt = require('webpagetest');39var options = {40};41var webPageTest = new wpt('www.webpagetest.org', options);42webPageTest.getTestStatus('140327_1M_1', function(err, data) {43 if (err) {44 console.log(err);45 } else {46 console.log(data);47 }48});49var wpt = require('webpagetest');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.runTest('www.google.com', { location: 'ec2-us-west-1:Chrome', connectivity: 'Cable', pollResults: 5 }, function(err, data) {4 if (err) return console.error(err);5 console.log('Test status: ' + data.statusText);6 if (data.statusCode == 200) {7 console.log('Test completed in ' + data.data.median.firstView.loadTime + 'ms');8 }9});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var page = wptools.page('Albert Einstein');3page.get(function(err, resp) {4 .infobox(function(err, infobox) {5 console.log(infobox);6 })7 .imageinfo(function(err, imageinfo) {8 console.log(imageinfo);9 })10 .coordinates(function(err, coordinates) {11 console.log(coordinates);12 })13 .pageviews(function(err, pageviews) {14 console.log(pageviews);15 })16 .categories(function(err, categories) {17 console.log(categories);18 })19 .revisions(function(err, revisions) {20 console.log(revisions);21 })22 .links(function(err, links) {23 console.log(links);24 })25 .redirects(function(err, redirects) {26 console.log(redirects);27 })28 .langlinks(function(err, langlinks) {29 console.log(langlinks);30 })31 .templates(function(err, templates) {32 console.log(templates);33 })34 .extlinks(function(err, extlinks) {35 console.log(extlinks);36 })37 .iwlinks(function(err, iwlinks) {38 console.log(iwlinks);39 })40 .references(function(err, references) {41 console.log(references);42 })43 .extmetadata(function(err, extmetadata) {44 console.log(extmetadata);45 })46 .extract(function(err, extract) {47 console.log(extract);48 })49 .summary(function(err, summary) {50 console.log(summary);51 })52 .disambiguation(function(err, disambiguation) {53 console.log(disambiguation);54 })55 .sections(function(err, sections) {56 console.log(sections);57 })58 .pageprops(function(err, pageprops) {59 console.log(pageprops);60 })61 .images(function(err, images) {62 console.log(images);63 })64 .parse(function(err, parse) {65 console.log(parse);66 })67 .text(function(err, text) {68 console.log(text);69 })70 .data(function(err, data) {71 console.log(data);72 })73 .raw(function(err, raw) {74 console.log(raw);75 })76 .fullinfo(function(err, fullinfo) {77 console.log(fullinfo);78 })79 .pageimage(function(err, pageimage) {80 console.log(pageimage);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = new WebPageTest('www.webpagetest.org', 'A.8f8c0d4e0f9b7c7d8e9e1f0f4f4a1c0a');2wpt.runTest(url, function(err, data) {3 if (err) return console.error(err);4 console.log('Test submitted to WebPageTest for %s', data.data.summary);5 console.log('Poll the JSON results at %s/jsonResult.php?test=%s', wpt.host, data.data.testId);6 console.log(' or the HTML results at %s/result/%s/', wpt.host, data.data.testId);7});8wpt.getLocations(function(err, data) {9 if (err) return console.error(err);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./webpagetest.js');2var fs = require('fs');3var util = require('util');4var wptKey = 'A.4d4a4e7d2d1f0a8a3a3c3d3f3e3a3f3e';5var wptServer = 'www.webpagetest.org';6var wpt = new WebPageTest(wptServer, wptKey);7var locations = ['Dulles:Chrome', 'Dulles:Firefox', 'Dulles:IE10', 'Dulles:IE11', 'Dulles:Opera', 'Dulles:Safari', 'Dulles:iPhone4', 'Dulles:iPhone5', 'Dulles:iPad', 'Dulles:iPad3', 'Dulles:iPad4', 'Dulles:Android2.3', 'Dulles:Android3', 'Dulles:Android4', 'Dulles:Blackberry', 'Dulles:SamsungGalaxyS3', 'Dulles:SamsungGalaxyNote2'];8var count = 0;9var wptResults = [];10var wptResults2 = [];11var wptResults3 = [];12var wptResults4 = [];13var wptResults5 = [];14var wptResults6 = [];15var wptResults7 = [];16var wptResults8 = [];17var wptResults9 = [];18var wptResults10 = [];19var wptResults11 = [];20var wptResults12 = [];21var wptResults13 = [];22var wptResults14 = [];23var wptResults15 = [];24var wptResults16 = [];25var wptResults17 = [];26var wptResults18 = [];27var wptResults19 = [];28var wptResults20 = [];29var wptResults21 = [];30var wptResults22 = [];31var wptResults23 = [];32var wptResults24 = [];33var wptResults25 = [];34var wptResults26 = [];35var wptResults27 = [];36var wptResults28 = [];37var wptResults29 = [];38var wptResults30 = [];39var wptResults31 = [];40var wptResults32 = [];41var wptResults33 = [];

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wptoolkit');2var pose = wptoolkit.pose;3pose.getPose(function(err, data) {4 console.log('err: ', err);5 console.log('data: ', data);6});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require("wptools");2var fs = require("fs");3var path = require("path");4var request = require("request");5var query = "The Beatles";6var language = "en";7var format = "json";8var options = {9};10var wp = wptools(query, language, format, options);11wp.get(function(err, info) {12 if (err) {13 console.log(err);14 } else {15 console.log(info);16 var data = JSON.stringify(info);17 fs.writeFileSync(18 path.join(__dirname, "data", "json", "beatles.json"),19 );20 }21});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful