1

Affectiva の新しい JS SDK ( http://developer.affectiva.com/v3_1/javascript/analyze-frames/ )、特にフレーム検出モードでの使用に問題があります。CameraFeed バージョンを起動して実行するのに問題はありませんでした。JSFiddle ( https://jsfiddle.net/affectiva/opyh5e8d/show/ ) の良い例もあります。しかし、Frame Detector モードでは、Web Worker から数百の「実行時エラー」が表示されるだけです。

<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 バージョンを実行しても問題ありません。機能していないのはこれだけです。私は何かばかげたことを見逃していますか?ドキュメンテーションは少し軽いです...

4

1 に答える 1

4

内部的に、タイムスタンプはストレージ用の整数に変換されます。整数オーバーフローが発生している可能性があると思います。最初のタイムスタンプをキャッシュし、それを後続のタイムスタンプから差し引いて、process() に渡される最初のタイムスタンプが 0 になり、その後の値が大きくなるようにできますか?

于 2016-08-15T03:38:43.367 に答える