Move an object between two ml5js poseNet keypoints using p5jsLooping an oscillator in p5jsUpdating text with p5jsIs there a way to live update the page when using p5js?p5js - touchStarted event on specific objectp5js website infinite pageMouse Tracking in p5jsCreating Multiple Clickable Divs with p5jsMove along an arc in p5jsp5js with Jekyllwatch and move midi notes with p5js and react

Is there an in-universe explanation given to the senior Imperial Navy Officers as to why Darth Vader serves Emperor Palpatine?

If I said I had $100 when asked, but I actually had $200, would I be lying by omission?

Is this password scheme legit?

Is a memoized pure function itself considered pure?

Can I use coax outlets for cable modem?

A first "Hangman" game in Python

Do sharpies or markers damage soft rock climbing gear?

Why did Lucius make a deal out of Buckbeak hurting Draco but not about Draco being turned into a ferret?

Grep contents before a colon

No hyphenation on "section", "Table", etc. with Cleveref package

Dotted background on a flowchart

Recommended Breathing Exercises to Play Woodwinds

How many petaflops does it take to land on the moon? What does Artemis need with an Aitken?

Can someone identify this unusual plane at airport?

Stolen MacBook should I worry about my data?

Does the Reduce option from the Enlarge/Reduce spell cause a critical hit to do 2d4 less damage?

To what extent should we fear giving offense?

What to do about my 1-month-old boy peeing through diapers?

Why does a sticker slowly peel off, but if it is pulled quickly it tears?

How do I insert two edge loops equally spaced from the edges?

How to say "I only speak one which is English." in French?

Why does the `ls` command sort files like this?

Can a character use multiple reactions in response to the same trigger?

Pen test results for web application include a file from a forbidden directory that is not even used or referenced



Move an object between two ml5js poseNet keypoints using p5js


Looping an oscillator in p5jsUpdating text with p5jsIs there a way to live update the page when using p5js?p5js - touchStarted event on specific objectp5js website infinite pageMouse Tracking in p5jsCreating Multiple Clickable Divs with p5jsMove along an arc in p5jsp5js with Jekyllwatch and move midi notes with p5js and react






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I'm trying to make a circle move between two body keypoints – i.e between left and right shoulder. I started with this code to make an object following some position:






var rectLocation;
var x = 50;
var y = 50;

function setup()
createCanvas(640,400);
rectLocation = createVector(width/2,height/2);


function draw()
background(255);

var target = createVector(x,y);
var distance = target.dist(rectLocation);
var mappedDistance = map(distance, 100, 0, 1.5, 0.5);

target.sub(rectLocation);
target.normalize();
target.mult(mappedDistance);
rectLocation.add(target);

text('hello',rectLocation.x, rectLocation.y);

x = x + 1 ;

if (x > width)
x = 50;


<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.3/p5.js"></script>





So with poseNet I converted x and y values of each keypoint into p5 Vectors and made one location follow another, but it doesn't seem to move and I can't get why. Sketch: https://editor.p5js.org/sebyakin/sketches/LQ7gqwGZH and my code here:






let video;
let poseNet;
let noseX = 0;
let noseY = 0;
let eyelX = 0;
let eyelY = 0;
let shoulderX = 0;
let shoulderY = 0;
let firstLocation;
let target;

function setup()
createCanvas(640, 480);
video = createCapture(VIDEO);
video.hide();

poseNet = ml5.poseNet(video, modelReady);
poseNet.on('pose', gotPoses);
// creating empty vectors
firstLocation = createVector(0,0);
target = createVector(0,0);



function gotPoses(poses)
if (poses.length > 0)
let nX = poses[0].pose.keypoints[0].position.x;
let nY = poses[0].pose.keypoints[0].position.y;
let eX = poses[0].pose.keypoints[1].position.x;
let eY = poses[0].pose.keypoints[1].position.y;
let sX = poses[0].pose.keypoints[5].position.x;
let sY = poses[0].pose.keypoints[5].position.y;
noseX = nX;
noseY = nY;
eyelX = eX;
eyelY = eY;
shoulderX = sX;
shoulderY = sY;




function modelReady()
console.log('model ready');



function draw()
image(video, 0, 0);
fill(0,0,255);

// set vectors to keypoints values
firstLocation.set(noseX, noseY);
target.set(shoulderX, shoulderY)

// make a circle follow target loaction
let distance = target.dist(firstLocation);
let mappedDistance = map(distance, 100, 0, 1.5, 0.5);
target.sub(firstLocation);
// target.normalize();
// target.mult(mappedDistance);
firstLocation.add(target);

ellipse(firstLocation.x, firstLocation.y, 50);
console.log(target.x);





Where did I go wrong?










share|improve this question
































    1















    I'm trying to make a circle move between two body keypoints – i.e between left and right shoulder. I started with this code to make an object following some position:






    var rectLocation;
    var x = 50;
    var y = 50;

    function setup()
    createCanvas(640,400);
    rectLocation = createVector(width/2,height/2);


    function draw()
    background(255);

    var target = createVector(x,y);
    var distance = target.dist(rectLocation);
    var mappedDistance = map(distance, 100, 0, 1.5, 0.5);

    target.sub(rectLocation);
    target.normalize();
    target.mult(mappedDistance);
    rectLocation.add(target);

    text('hello',rectLocation.x, rectLocation.y);

    x = x + 1 ;

    if (x > width)
    x = 50;


    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.3/p5.js"></script>





    So with poseNet I converted x and y values of each keypoint into p5 Vectors and made one location follow another, but it doesn't seem to move and I can't get why. Sketch: https://editor.p5js.org/sebyakin/sketches/LQ7gqwGZH and my code here:






    let video;
    let poseNet;
    let noseX = 0;
    let noseY = 0;
    let eyelX = 0;
    let eyelY = 0;
    let shoulderX = 0;
    let shoulderY = 0;
    let firstLocation;
    let target;

    function setup()
    createCanvas(640, 480);
    video = createCapture(VIDEO);
    video.hide();

    poseNet = ml5.poseNet(video, modelReady);
    poseNet.on('pose', gotPoses);
    // creating empty vectors
    firstLocation = createVector(0,0);
    target = createVector(0,0);



    function gotPoses(poses)
    if (poses.length > 0)
    let nX = poses[0].pose.keypoints[0].position.x;
    let nY = poses[0].pose.keypoints[0].position.y;
    let eX = poses[0].pose.keypoints[1].position.x;
    let eY = poses[0].pose.keypoints[1].position.y;
    let sX = poses[0].pose.keypoints[5].position.x;
    let sY = poses[0].pose.keypoints[5].position.y;
    noseX = nX;
    noseY = nY;
    eyelX = eX;
    eyelY = eY;
    shoulderX = sX;
    shoulderY = sY;




    function modelReady()
    console.log('model ready');



    function draw()
    image(video, 0, 0);
    fill(0,0,255);

    // set vectors to keypoints values
    firstLocation.set(noseX, noseY);
    target.set(shoulderX, shoulderY)

    // make a circle follow target loaction
    let distance = target.dist(firstLocation);
    let mappedDistance = map(distance, 100, 0, 1.5, 0.5);
    target.sub(firstLocation);
    // target.normalize();
    // target.mult(mappedDistance);
    firstLocation.add(target);

    ellipse(firstLocation.x, firstLocation.y, 50);
    console.log(target.x);





    Where did I go wrong?










    share|improve this question




























      1












      1








      1


      1






      I'm trying to make a circle move between two body keypoints – i.e between left and right shoulder. I started with this code to make an object following some position:






      var rectLocation;
      var x = 50;
      var y = 50;

      function setup()
      createCanvas(640,400);
      rectLocation = createVector(width/2,height/2);


      function draw()
      background(255);

      var target = createVector(x,y);
      var distance = target.dist(rectLocation);
      var mappedDistance = map(distance, 100, 0, 1.5, 0.5);

      target.sub(rectLocation);
      target.normalize();
      target.mult(mappedDistance);
      rectLocation.add(target);

      text('hello',rectLocation.x, rectLocation.y);

      x = x + 1 ;

      if (x > width)
      x = 50;


      <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.3/p5.js"></script>





      So with poseNet I converted x and y values of each keypoint into p5 Vectors and made one location follow another, but it doesn't seem to move and I can't get why. Sketch: https://editor.p5js.org/sebyakin/sketches/LQ7gqwGZH and my code here:






      let video;
      let poseNet;
      let noseX = 0;
      let noseY = 0;
      let eyelX = 0;
      let eyelY = 0;
      let shoulderX = 0;
      let shoulderY = 0;
      let firstLocation;
      let target;

      function setup()
      createCanvas(640, 480);
      video = createCapture(VIDEO);
      video.hide();

      poseNet = ml5.poseNet(video, modelReady);
      poseNet.on('pose', gotPoses);
      // creating empty vectors
      firstLocation = createVector(0,0);
      target = createVector(0,0);



      function gotPoses(poses)
      if (poses.length > 0)
      let nX = poses[0].pose.keypoints[0].position.x;
      let nY = poses[0].pose.keypoints[0].position.y;
      let eX = poses[0].pose.keypoints[1].position.x;
      let eY = poses[0].pose.keypoints[1].position.y;
      let sX = poses[0].pose.keypoints[5].position.x;
      let sY = poses[0].pose.keypoints[5].position.y;
      noseX = nX;
      noseY = nY;
      eyelX = eX;
      eyelY = eY;
      shoulderX = sX;
      shoulderY = sY;




      function modelReady()
      console.log('model ready');



      function draw()
      image(video, 0, 0);
      fill(0,0,255);

      // set vectors to keypoints values
      firstLocation.set(noseX, noseY);
      target.set(shoulderX, shoulderY)

      // make a circle follow target loaction
      let distance = target.dist(firstLocation);
      let mappedDistance = map(distance, 100, 0, 1.5, 0.5);
      target.sub(firstLocation);
      // target.normalize();
      // target.mult(mappedDistance);
      firstLocation.add(target);

      ellipse(firstLocation.x, firstLocation.y, 50);
      console.log(target.x);





      Where did I go wrong?










      share|improve this question
















      I'm trying to make a circle move between two body keypoints – i.e between left and right shoulder. I started with this code to make an object following some position:






      var rectLocation;
      var x = 50;
      var y = 50;

      function setup()
      createCanvas(640,400);
      rectLocation = createVector(width/2,height/2);


      function draw()
      background(255);

      var target = createVector(x,y);
      var distance = target.dist(rectLocation);
      var mappedDistance = map(distance, 100, 0, 1.5, 0.5);

      target.sub(rectLocation);
      target.normalize();
      target.mult(mappedDistance);
      rectLocation.add(target);

      text('hello',rectLocation.x, rectLocation.y);

      x = x + 1 ;

      if (x > width)
      x = 50;


      <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.3/p5.js"></script>





      So with poseNet I converted x and y values of each keypoint into p5 Vectors and made one location follow another, but it doesn't seem to move and I can't get why. Sketch: https://editor.p5js.org/sebyakin/sketches/LQ7gqwGZH and my code here:






      let video;
      let poseNet;
      let noseX = 0;
      let noseY = 0;
      let eyelX = 0;
      let eyelY = 0;
      let shoulderX = 0;
      let shoulderY = 0;
      let firstLocation;
      let target;

      function setup()
      createCanvas(640, 480);
      video = createCapture(VIDEO);
      video.hide();

      poseNet = ml5.poseNet(video, modelReady);
      poseNet.on('pose', gotPoses);
      // creating empty vectors
      firstLocation = createVector(0,0);
      target = createVector(0,0);



      function gotPoses(poses)
      if (poses.length > 0)
      let nX = poses[0].pose.keypoints[0].position.x;
      let nY = poses[0].pose.keypoints[0].position.y;
      let eX = poses[0].pose.keypoints[1].position.x;
      let eY = poses[0].pose.keypoints[1].position.y;
      let sX = poses[0].pose.keypoints[5].position.x;
      let sY = poses[0].pose.keypoints[5].position.y;
      noseX = nX;
      noseY = nY;
      eyelX = eX;
      eyelY = eY;
      shoulderX = sX;
      shoulderY = sY;




      function modelReady()
      console.log('model ready');



      function draw()
      image(video, 0, 0);
      fill(0,0,255);

      // set vectors to keypoints values
      firstLocation.set(noseX, noseY);
      target.set(shoulderX, shoulderY)

      // make a circle follow target loaction
      let distance = target.dist(firstLocation);
      let mappedDistance = map(distance, 100, 0, 1.5, 0.5);
      target.sub(firstLocation);
      // target.normalize();
      // target.mult(mappedDistance);
      firstLocation.add(target);

      ellipse(firstLocation.x, firstLocation.y, 50);
      console.log(target.x);





      Where did I go wrong?






      var rectLocation;
      var x = 50;
      var y = 50;

      function setup()
      createCanvas(640,400);
      rectLocation = createVector(width/2,height/2);


      function draw()
      background(255);

      var target = createVector(x,y);
      var distance = target.dist(rectLocation);
      var mappedDistance = map(distance, 100, 0, 1.5, 0.5);

      target.sub(rectLocation);
      target.normalize();
      target.mult(mappedDistance);
      rectLocation.add(target);

      text('hello',rectLocation.x, rectLocation.y);

      x = x + 1 ;

      if (x > width)
      x = 50;


      <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.3/p5.js"></script>





      var rectLocation;
      var x = 50;
      var y = 50;

      function setup()
      createCanvas(640,400);
      rectLocation = createVector(width/2,height/2);


      function draw()
      background(255);

      var target = createVector(x,y);
      var distance = target.dist(rectLocation);
      var mappedDistance = map(distance, 100, 0, 1.5, 0.5);

      target.sub(rectLocation);
      target.normalize();
      target.mult(mappedDistance);
      rectLocation.add(target);

      text('hello',rectLocation.x, rectLocation.y);

      x = x + 1 ;

      if (x > width)
      x = 50;


      <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.3/p5.js"></script>





      let video;
      let poseNet;
      let noseX = 0;
      let noseY = 0;
      let eyelX = 0;
      let eyelY = 0;
      let shoulderX = 0;
      let shoulderY = 0;
      let firstLocation;
      let target;

      function setup()
      createCanvas(640, 480);
      video = createCapture(VIDEO);
      video.hide();

      poseNet = ml5.poseNet(video, modelReady);
      poseNet.on('pose', gotPoses);
      // creating empty vectors
      firstLocation = createVector(0,0);
      target = createVector(0,0);



      function gotPoses(poses)
      if (poses.length > 0)
      let nX = poses[0].pose.keypoints[0].position.x;
      let nY = poses[0].pose.keypoints[0].position.y;
      let eX = poses[0].pose.keypoints[1].position.x;
      let eY = poses[0].pose.keypoints[1].position.y;
      let sX = poses[0].pose.keypoints[5].position.x;
      let sY = poses[0].pose.keypoints[5].position.y;
      noseX = nX;
      noseY = nY;
      eyelX = eX;
      eyelY = eY;
      shoulderX = sX;
      shoulderY = sY;




      function modelReady()
      console.log('model ready');



      function draw()
      image(video, 0, 0);
      fill(0,0,255);

      // set vectors to keypoints values
      firstLocation.set(noseX, noseY);
      target.set(shoulderX, shoulderY)

      // make a circle follow target loaction
      let distance = target.dist(firstLocation);
      let mappedDistance = map(distance, 100, 0, 1.5, 0.5);
      target.sub(firstLocation);
      // target.normalize();
      // target.mult(mappedDistance);
      firstLocation.add(target);

      ellipse(firstLocation.x, firstLocation.y, 50);
      console.log(target.x);





      let video;
      let poseNet;
      let noseX = 0;
      let noseY = 0;
      let eyelX = 0;
      let eyelY = 0;
      let shoulderX = 0;
      let shoulderY = 0;
      let firstLocation;
      let target;

      function setup()
      createCanvas(640, 480);
      video = createCapture(VIDEO);
      video.hide();

      poseNet = ml5.poseNet(video, modelReady);
      poseNet.on('pose', gotPoses);
      // creating empty vectors
      firstLocation = createVector(0,0);
      target = createVector(0,0);



      function gotPoses(poses)
      if (poses.length > 0)
      let nX = poses[0].pose.keypoints[0].position.x;
      let nY = poses[0].pose.keypoints[0].position.y;
      let eX = poses[0].pose.keypoints[1].position.x;
      let eY = poses[0].pose.keypoints[1].position.y;
      let sX = poses[0].pose.keypoints[5].position.x;
      let sY = poses[0].pose.keypoints[5].position.y;
      noseX = nX;
      noseY = nY;
      eyelX = eX;
      eyelY = eY;
      shoulderX = sX;
      shoulderY = sY;




      function modelReady()
      console.log('model ready');



      function draw()
      image(video, 0, 0);
      fill(0,0,255);

      // set vectors to keypoints values
      firstLocation.set(noseX, noseY);
      target.set(shoulderX, shoulderY)

      // make a circle follow target loaction
      let distance = target.dist(firstLocation);
      let mappedDistance = map(distance, 100, 0, 1.5, 0.5);
      target.sub(firstLocation);
      // target.normalize();
      // target.mult(mappedDistance);
      firstLocation.add(target);

      ellipse(firstLocation.x, firstLocation.y, 50);
      console.log(target.x);






      processing p5.js pose-estimation






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 22:37









      Rabbid76

      58.1k13 gold badges38 silver badges69 bronze badges




      58.1k13 gold badges38 silver badges69 bronze badges










      asked Mar 27 at 20:38









      sebyakinsebyakin

      61 bronze badge




      61 bronze badge

























          0






          active

          oldest

          votes










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55386047%2fmove-an-object-between-two-ml5js-posenet-keypoints-using-p5js%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes




          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55386047%2fmove-an-object-between-two-ml5js-posenet-keypoints-using-p5js%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript