google-ar / arcore-unreal-sdk

ARCore SDK for Unreal
https://developers.google.com/ar/
Apache License 2.0
277 stars 122 forks source link

UGoogleARCoreFrameFunctionLibrary::GetCameraTexture() blank image #50

Closed SeyelentEco closed 5 years ago

SeyelentEco commented 5 years ago

UnrealEngine 4.20.3 built from Google fork ARCore 1.6 Google Pixel Android OS 9

I've tried using both using Blueprint and using C++ but the Texture returned by GetCameraTexture is always black (all the bytes are 0). The width and height and format are okay but all the bytes are zero.

UTexture *uText = UGoogleARCoreFrameFunctionLibrary::GetCameraTexture();
UTexture2D *Texture = static_cast<UTexture2D*>(uText);

TArray<uint8*> RawData;
RawData.AddZeroed(Texture->GetNumMips()); //1
Texture->GetMipData(0, (void**)RawData.GetData());
for (int i = 0; i<100; i++) {
      UE_LOG(LogTemp, Warning, TEXT("%d"), RawData[0][i]);
}

All the bytes are 0.

When I use blueprint to hook up a HUD Image to GetCameraTexture, it turns transparent immediately. There are no errors.

screen shot 2019-02-11 at 11 28 48 am
bopangzz commented 5 years ago

Have you tried render the texture in a material?

SeyelentEco commented 5 years ago

What do you think that would show? Also I'm a bit of a noob with UE4. Do I create a Material and assign it's color to the Passthrough Camera?

bopangzz commented 5 years ago

Basically try to do something similar to this: https://answers.unrealengine.com/questions/44139/texture-change-with-blueprint.html

You should be able to see the camera textured rendered on your object if the texture is working properly.