我正在尝试熟悉 tracking.js,但是当我尝试运行项目页面 ( http://trackingjs.com/docs.html#introduction ) 上给出的相同示例时,什么也没有发生。Google-chrome 甚至没有显示询问我是否要允许该页面访问我的网络摄像头的提示。同样的事情发生在 Firefox 上。
我已经运行了 tracking.js-master/ 包中的其他示例,唯一失败的是我添加的教程中描述的示例。
下面是我从 tracking.js 介绍页面复制并粘贴到我的 first_tracking.html 文件的代码。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>tracking.js - first tracking</title>
<script src="../build/tracking-min.js"></script>
</head>
<body>
<p>This shows in the browser</p>
<video id="myVideo" width="400" height="300" preload autoplay loop muted></video>
<script>
var colors = new tracking.ColorTracker(['magenta', 'cyan', 'yellow']);
colors.on('track', function(event) {
if (event.data.length === 0) {
// No colors were detected in this frame.
} else {
event.data.forEach(function(rect) {
console.log(rect.x, rect.y, rect.height, rect.width, rect.color);
});
}
});
tracking.track('#myVideo', colors);
</script>
</body>
</html>
有没有人尝试并成功运行了 tracking.js 页面上列出的介绍示例并有任何指示?
研究:在谷歌搜索中找到的大部分内容都与谷歌分析、Node.js 和其他 JS 框架有关。我还发现有人建议将preload选项设置为auto,导致preload="auto",但它不起作用。