hiukim / mind-ar-js

Web Augmented Reality. Image Tracking, Face Tracking. Tensorflow.js
MIT License
2.21k stars 413 forks source link

Canvas rendering related error #465

Open arladmin opened 11 months ago

arladmin commented 11 months ago

Why am i seeing this error?

Uncaught (in promise) DOMException: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The source width is 0.
    at https://cdn.jsdelivr.net/gh/hiukim/mind-ar-js@0.4.2/dist/mindar.prod.js:2:2507895
    at new Promise (<anonymous>)
    at Compiler.compileImageTargets (https://cdn.jsdelivr.net/gh/hiukim/mind-ar-js@0.4.2/dist/mindar.prod.js:2:2507675)
    at <anonymous>:23:37

How can i bypass this issue?

Also, as i'm using just the Core API to run the Compile operation, programmatically, i don't need to render anything on the canvas.

My html file is essentially this: https://github.com/hiukim/mind-ar-js-doc/blob/d13ad927647504852b0fa7aaf190a6893db4fa05/static/samples/compile.html

with the following extra code:

    const res={};
    const urls = [...];  /// a list of URLs
    const files = [];

    const main = async function () {
      for (let i = 0; i < urls.length; i++) {
        let response = await fetch(urls[i]);
        let blob = await response.blob();
        let temp = new Image();
        temp.src = URL.createObjectURL(blob);
        files.push(temp);
      }
    };

    await main();

    const dataList = await compiler.compileImageTargets(files, (progress) => {
      console.log("progress", progress);
    });
    const exportedBuffer = await compiler.exportData();
    //console.log({ exportedBuffer });
    res.data = exportedBuffer;
    //res = new File(exportedBuffer, "targets.mind");
hiukim commented 8 months ago

The source width is 0. seems to indicate something wrong with the input files?