1
我在使用Affectiva的新JS SDK(http://developer.affectiva.com/v3_1/javascript/analyze-frames/)时遇到问题,特别是在帧检测器模式下。我没有任何问题让CameraFeed版本&运行,他们甚至在JSFiddle上有一个很好的例子()。但是帧检测器模式给了我上百个来自Web Worker的“运行时错误”。使用Affectiva JS SDK(帧检测器模式)的错误
<body class='session'>
<div class='col-md-8' id='affdex_elements' style='width:680px;height:480px;'>
<video autoplay id='video'></video>
<canvas id='canvas'></canvas>
</div>
<div id='results' style='word-wrap:break-word;'></div>
<div id='logs'></div>
<script src="https://download.affectiva.com/js/3.1/affdex.js"></script>
<script>
var width = 640;
var height = 480;
var faceMode = affdex.FaceDetectorMode.LARGE_FACES;
var detector = new affdex.FrameDetector(faceMode);
detector.addEventListener("onInitializeSuccess", function() {
console.log('Detector reports initialized.');
// Start with first capture...
captureImage();
});
detector.addEventListener("onImageResultsSuccess", function (faces, image, timestamp) {
console.log(faces);
captureImage();
});
detector.addEventListener("onImageResultsFailure", function (image, timestamp, err_detail) {
console.log(err_detail);
captureImage();
});
detector.detectAllExpressions();
detector.detectAllEmotions();
detector.detectAllEmojis();
detector.detectAllAppearance();
detector.start();
var v = document.getElementById('video');
var c = document.getElementById('canvas');
var t = c.getContext('2d');
c.width = width;
c.height = height;
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia;
if (navigator.getUserMedia) {
navigator.getUserMedia({video: true}, handleVideo, videoError);
}
function handleVideo(stream) { v.src = window.URL.createObjectURL(stream); }
function videoError(e) { console.log(e); }
function captureImage() {
console.log('Capturing...');
t.clearRect(0, 0, c.width, c.height);
t.drawImage(v, 0, 0, width, height);
var imgData = t.getImageData(0, 0, c.width, c.height);
var currentTimeStamp = (new Date()).getTime()/1000;
detector.process(imgData, currentTimeStamp);
}
</script>
我已经删除任何非必要的只是去一个简单的工作示例。再次,我没有问题运行此CameraFeed版本。只是这个不起作用。我错过了一些愚蠢的东西吗?文档有点轻...
好想法。这就是他们在代码中的做法,我认为这纯粹是为了内部一致性而不是溢出问题。我会尝试并报告。 – Nuby
我不敢相信这工作!你不知道我一直在试图追踪这个问题多久......如果没有你,我永远都不会知道。谢谢! – Nuby