处理headtrackr.js的事件监听器

时间:2016-06-30 11:28:46

标签: javascript computer-vision getusermedia

我希望能够使用headtrackr.js

滚动包含头部动作的页面

https://github.com/auduno/headtrackr

我已将代码实现到基本的html页面上。

<html>
<head>
<title>Test</title>
  <script src="headtrackr.js"></script>

</head>
<body>
<canvas id="inputCanvas" width="320" height="240" style="display:none"></canvas>
<video id="inputVideo" autoplay loop></video>
<script type="text/javascript">
  var videoInput = document.getElementById('inputVideo');
  var canvasInput = document.getElementById('inputCanvas');
  var htracker = new headtrackr.Tracker();
  htracker.init(videoInput, canvasInput);
  htracker.start();
</script>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. </p>
</body>
</html>

以上是启用SSL的 - 视频出现。脸部被检测到。但该文件不会滚动。

我还需要其他东西吗?像听众一样阅读headtrackr的读物?我在github或http://www.digitoffee.com/video/scroll-a-document-by-just-moving-your-head/428/

上的文档中找不到这个

1 个答案:

答案 0 :(得分:1)

也许尝试添加此事件监听器来更改您想要做的事情?

document.addEventListener('headtrackingEvent', function(e) {
 window.scrollTo( e.x, e.y );
}