hiukim / mind-ar-js

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

Data import error - RangeError: Extra bytes found at buffer #257

Closed positlabs closed 1 year ago

positlabs commented 1 year ago

I have been getting this error intermittently while trying to load my image targets.

RangeError: Extra 5000 byte(s) found at buffer

I took some random screenshots... terrible targets, but you can use these to reproduce the bug.

Screen Shot 2022-10-04 at 3 11 06 PM Screen Shot 2022-10-04 at 3 11 04 PM Screen Shot 2022-10-04 at 3 11 01 PM Screen Shot 2022-10-04 at 3 11 09 PM

Do the target images need to be a specific size? I tried 1024 square but it gave me the same error.

divljikunic commented 1 year ago

Can confirm this is happening. It seems to never appear when using certain markers, but always (or almost always) when using others. However when generating .mind again (using the same image that apparently works) also produces erroneous .mind. If the problem is even there, that is.

divljikunic commented 1 year ago

Upon further investigation this turned out to be a simple case of missing files, the path to the .mind 'imageTargetSrc' file was wrong.

Create-react-app (or webpack) can't know .mind files should be copied to a folder that will be served publicly, unless you specifically configure them to do so.

The error itself sounds strange and/or misleading but, in my case at least, was resolved.

I suggest you copy your targets file (e.g. 'targets.mind') to your build folder (public, dist, or whatever the final destination of your app is called), then set:

<a-scene mindar-image="imageTargetSrc: ./targets.mind;" >
positlabs commented 1 year ago

Oh, that sort of makes sense because in that case, my server would have been returning an html 404 page and not a response with an error code.

positlabs commented 1 year ago

I tested and confirmed this is the issue. Thanks for your insights @divljikunic!

@hiukim Do you think it would make sense to catch this error and emit something more descriptive?

tranphuongthao2405 commented 1 year ago

I've encountered this in my project. I moved my files to public folder and it works. Thanks.