html p5.j​​s + p5.dom.js + clmtracker.js

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html p5.j​​s + p5.dom.js + clmtracker.js相关的知识,希望对你有一定的参考价值。

This example uses clmtracker along with p5.js and p5.dom.js. Make sure you have version 0.1.5 or higher of p5.dom.js - you can grab it [here](https://github.com/lmccart/p5.js/blob/master/lib/addons/p5.dom.js).

You will need to run this with a local server, see this [tutorial](https://github.com/lmccart/p5.js/wiki/Local-server) for help.

* https://github.com/auduno/clmtrackr - download of clmtrackr.js and models.
* http://p5js.org - download of p5.js and p5.dom.js.

__Or download an example [here](http://cl.ly/2g171C1n1p1H).__

![](http://i.imgur.com/UU6ssQG.jpg)
<html>

  <head>
    <script src="clmtrackr.js"></script>
    <script src="model_pca_20_svm.js"></script>
    <script src="p5.js"></script>
    <script src="p5.dom.js"></script>
    <script>
      var ctracker;

      function setup() {

        // setup camera capture
        var videoInput = createCapture();
        videoInput.size(400, 300);
        videoInput.position(0, 0);
        
        // setup canvas
        var cnv = createCanvas(400, 300);
        cnv.position(0, 0);

        // setup tracker
        ctracker = new clm.tracker();
        ctracker.init(pModel);
        ctracker.start(videoInput.elt);

        noStroke();
      }

      function draw() {
        clear();

        // get array of face marker positions [x, y] format
        var positions = ctracker.getCurrentPosition();
        
        for (var i=0; i<positions.length; i++) {
          // set the color of the ellipse based on position on screen
          fill(map(positions[i][0], width*0.33, width*0.66, 0, 255), map(positions[i][1], height*0.33, height*0.66, 0, 255), 255);
          // draw ellipse at each position point
          ellipse(positions[i][0], positions[i][1], 8, 8);
        }

      }
    </script>

    <style> body { padding: 0; margin: 0} </style>

  </head>

  <body>
  </body>

</html>

以上是关于html p5.j​​s + p5.dom.js + clmtracker.js的主要内容,如果未能解决你的问题,请参考以下文章

html p5.j​​s中的基本形状

html p5.j​​s中的基本循环

html p5.j​​s中的基本鼠标交互

html p5.j​​s中的循环也取自http://p5js.org/examples/examples/Math_Random.php

p5.j​​s 时间问题

p5.j​​s 中垂直居中的文本未正确对齐