2

我试图让这个信用卡读卡器在我的角度应用程序上工作。我按照阅读中的所有步骤操作并获得了许可证密钥,但由于某种原因,我收到以下错误

Error during the initialization of the SDK! DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'http://localhost:4200/BlinkCardWasmSDK.js' failed to load.

在我的组件中,我根据说明实现了以下方法:

 scanCard() {
    if ( BlinkCardSDK.isBrowserSupported() ) {
      const loadSettings = new BlinkCardSDK.WasmSDKLoadSettings( 'sRwAAAYJbG9jYA==' );

      BlinkCardSDK.loadWasmModule( loadSettings ).then
      (
        ( wasmSDK: BlinkCardSDK.WasmSDK ) => {
          // The SDK was initialized successfully, save the wasmSDK for future use
          BlinkCardSDK.createBlinkCardRecognizer( wasmSDK ).then(recognizer => {
            BlinkCardSDK.createRecognizerRunner( wasmSDK, [ recognizer ], true ).then(recognizerRunner => {
              const cameraFeed = document.getElementById( 'camera-feed' ) as HTMLVideoElement;
              BlinkIDSDK.VideoRecognizer.createVideoRecognizerFromCameraStream(cameraFeed, recognizerRunner)
                .then(videoRecognizer => {
                  videoRecognizer.recognize().then(processResult => {
                    if ( processResult !== BlinkIDSDK.RecognizerResultState.Empty ) {
                     recognizer.getResult().then(recognitionResult => {
                       console.log( recognitionResult );

                     });
                    } else {
                      console.log( 'Recognition was not successful!' );
                    }
                    console.log(processResult);
                  });

              });
            });

          });
        },
        ( error: any ) => {
          // Error happened during the initialization of the SDK
          console.log( 'Error during the initialization of the SDK!', error );
        });
    } else {
      console.log( 'This browser is not supported by the SDK!' );
    }
  }

在html中我有:

<body>
<div id="screen-initial">
  <h1 id="msg">Loading...</h1>
  <progress id="load-progress" value="0" max="100"></progress>
</div>

<div id="screen-start" class="hidden">
  <a href="#" id="start-scan">Start scan</a>
</div>

<div id="screen-scanning" class="hidden">
  <video id="camera-feed" playsinline></video>
  <!-- Recognition events will be drawn here. -->
  <canvas id="camera-feedback"></canvas>
  <p id="camera-guides">Point the camera towards Payment cards.</p>
</div>
</body>

我在 /src/assets/BlinkCardWasmSDK.js 中添加了 BlinkCardWasmSDK.js,但它仍然给我错误。我是否缺少参考资料或其他内容?在此先感谢您的帮助。

4

1 回答 1

2

问题是 BlinkID 找不到它需要的资源。您需要将其指向架构、构建、选项和最后的资产数组中的 angular.json 配置文件( Angular 工作空间配置文档)中的资源位置。

          "assets": [
              {
                "glob": "**/*",
                "input": "node_modules/@microblink/blinkid-in-browser-sdk/resources",
                "output": "/"
              }
            ]

您不需要将 BlinkID 资源移动到您的资产中,而是指向它在 node_modules 中的位置。让我知道这是否有帮助。

于 2021-05-01T18:09:24.617 回答