title: BarcodeDetector DOMException: Barcode detection service unavailable (in Chrome)
body: <p>We are currently trying to use the native <a href="https://wicg.github.io/shape-detection-api/#barcode-detection-api" rel="nofollow noreferrer">BarcodeDetector</a> in the latest Chrome (59). It is available under the enabled flag <code>chrome://flags/#enable-experimental-web-platform-features</code>.</p>
  <p>You can have look at another example <a href="https://paul.kinlan.me/barcode-detection/" rel="nofollow noreferrer">here</a>.</p>
  <p>We are checking for the native BarcodeDetector like this:</p>
  <pre><code>typeof window.BarcodeDetector === 'function'
  </code></pre>
  <p>But even when we fall into this branch and we finally manage to pour some image data into the detector we only get an exception:</p>
  <blockquote>
  <p>DOMException: Barcode detection service unavailable.</p>
  </blockquote>
  <p>I've googled that, but was not very successful. The most promising hint is <a href="https://github.com/scheib/chromium/blob/master/third_party/WebKit/Source/modules/shapedetection/BarcodeDetector.cpp#L34" rel="nofollow noreferrer">this one</a>, but it seems to be an odd Webkit fork.</p>
  <p>What we are doing is the following (pseudocode!):</p>
  <pre><code>window.createImageBitmap(canvasContext.canvas) // from canvasEl.getContext('2d')
    .then(function(data)
    {
      window.BarcodeDetector.detect(data);
    });
    // go on: catch the exception
  </code></pre>
  <p>Has anybody ever heard of this and can share some experiences with the <code>BarcodeDetector</code>?</p>