artoolkitx / arunityx

artoolkitX for Unity, providing high-performance video acquisition, marker and texture tracking and full Unity Editor support
https://www.artoolkitx.org/
Other
41 stars 22 forks source link

Windows+Unity: AR_PIXEL_FORMAT_420f --> source->bufPlanes empty --> Access Violation #23

Closed LeonardOertelt closed 1 year ago

LeonardOertelt commented 5 years ago

After I finally managed to compile the ARX.dll for Windows using mingw/cmake/Visual Studio 2019 and imported it alongside other libraries into Unity (see image) I always ended up crashing the editor as soon as I hit play. image After some digging in the code and in the Unity logs I found the problem in the file videoRGBA.c:

int videoRGBA::videoRGBA(uint32_t destRGBA, AR2VideoBufferT source, int width, int height, AR_PIXEL_FORMAT pixelFormat)

In case AR_PIXEL_FORMAT_420f bufPlanes has no valid index 0 and the access causes the access violation: image

I also found out that in video2.c it uses ARVIDEO_INPUT_WINDOWS_MEDIA_FOUNDATION if that helps.

I have been trying to fix it myself but I am not very familiar with the code and haven't managed to get a working build with correct image output. All I managed to get was a green screen. So any help is appreciated!

sfigueroac90 commented 5 years ago

Just add "-format=BGRA" to solve temporally in Windows config line. It seems a problem in the updateTexture32() method in Unity due to TextureFormat in Unity. It seems ARWrapper in ARToolkitX olny exports updatetexture32, and not updateTexture, so it only works with BGRA format.

ARCONFIG

LeonardOertelt commented 5 years ago

That solved it for me. Thank you! It would be nice if there was a note in the documentation regarding this issue or a change of the default configuration until this is fixed.

philip-lamb commented 1 year ago

This is now handled automatically. See https://github.com/artoolkitx/arunityx/blob/release/1.1.2/Source/Package/Assets/artoolkitX-Unity/Scripts/ARController.cs#L674