Unity-Technologies / arfoundation-samples

Example content for Unity projects based on AR Foundation
Other
2.99k stars 1.11k forks source link

The CpuImage of the Camera returns only a low resolution texture #1009

Closed valantano closed 1 year ago

valantano commented 1 year ago

When accessing the XRCpuImage I only get a resolution of 640,480. Is there a way to access the full resolution camera image.

bool successful = cameraManager.TryAcquireLatestCpuImage(out XRCpuImage image);
Debug.Log("#################### Background" + image.dimensions); //Info Unity #################### Background(640, 480)

I could not find anything in the Sample below: https://github.com/Unity-Technologies/arfoundation-samples/blob/main/Assets/Scripts/CpuImageSample.cs

Thanks in advance.

DavidMohrhardt commented 1 year ago

You may want to look into your current camera configuration. https://github.com/Unity-Technologies/arfoundation-samples#cpuimages

Edit: The relevant section of the documentation I linked:

"The resolution of the camera image is affected by the camera's configuration. The current configuration is indicated at the bottom left of the screen inside a dropdown box which lets you select one of the supported camera configurations. The CameraConfigController.cs demonstrates enumerating and selecting a camera configuration. It is on the CameraConfigs GameObject."

valantano commented 1 year ago

Thank you.

I was able to get a resolution of 1440x1080. Its still smaller than the actual Screen image (2280x1080) but it will do. Do you know where the right place is to set this configuration? I did it very clumsy in an Update function which tries do set it until it was successful.

For me it seems that the cameraManager takes a low resolution copy of the real camera image and uses this to do anything AR related but then displays the real camera image on the screen and over it the AR stuff. Am I correct?

And does this also influence the quality of the environment depth map and all other AR functionalities?

Thank you in advance.

andyb-unity commented 1 year ago

From our docs:

AR Foundation allows you to work with augmented reality platforms in a multi-platform way within Unity. This package presents an interface for Unity developers to use, but doesn't implement any AR features itself.

So the ARCameraManager does not perform any AR-related calculations. It only mediates data to and from ARKit (or your other installed provider(s)), nor does it alter images given by the provider.

Your CPU image size is solely dependent on camera configuration regardless of screen resolution.

andyb-unity commented 1 year ago

Realizing I missed part of your question when I answered a couple days ago.

Instead of Update, you can use a Coroutine on Start to query available camera configurations and select one. I posted an example like this to the forums a while back that you can use as reference:

https://forum.unity.com/threads/can-we-use-arkit-6.1293639/#post-8272695

valantano commented 1 year ago

Thank you very much, for your help :) I think this Topic can be closed now.