webarkit / jsartoolkitNFT

jsartolkitNFT is a smaller version of jsartoolkit5 with only NFT support
GNU Lesser General Public License v3.0
130 stars 26 forks source link

Resolved videoLuma array size to scan whole the camera frame for marker detection #352

Closed MasoudShah closed 7 months ago

MasoudShah commented 7 months ago

The start of marker detection had an issue since a specific version. After digging into code and monitoring some variables, I realized that videoLuma array size, is 1/4 of the size that it had to be. I think this division has happened 2 times from the main video frame, and this is causing the issue. In the ARControllerNFT file at _copyImageToHeap function, videoLuma get filled with values in the whole true size, but the size that is defined before, is a quarter of that. This caused the detection, only work at the first quarter of the video frame and it was not very performant.

kalwalt commented 7 months ago

@MasoudShah i tested your changes and yes i confirm that the issue was solved. It needs to re build the dist files but i will do by myself. When after version 0.9.7 i switched to an ew approach for passing the videoLuma data I underestimated the code and i do not consider that there was a slightly change. Basically videoLuma is a single channel of data, instead videoData is RGBA (4 channel) so 4 times videoLuma, in the old code we create a Uint8Array passing a pointer. But with the new code we don't need this, thanks to emscripten::val we passs directly the data... Fortunately your perseverance led to the solution of the problem. Thank you very much! I will merge into the fix-version-1.6.0 branch and soon it will be merged.