How to capture a camera with NRRGBCamTexture class

Hello,

I’m trying to camera capture with NRSDK.
(Also, I read https://xreal.gitbook.io/nrsdk/development/miscellaneous/recording this article.)

And, I followed below code like this.

public NRKernal.NRRGBCamTexture RGBCamTexture;
private Texture2D captureTexture;

RGBCamTexture = new NRKernal.NRRGBCamTexture();
RGBCamTexture.Play();
captureTexture = RGBCamTexture.GetTexture();
File.WriteAllBytes(ImageSavePath, captureTexture.EncodeToPNG());

However, the saved .png file does not show anything (null file).
For this reason, can you help me, using NRRGBCamTexture class?

Actually, I have implemented based on NRPhotoCaptureExample.cs, but it does not contain RGBCamTexture.GetTexture();.

Here’s my question:
Can the camera get texture through NR camera with RGBCamTexture.GetTexture();.?

NRSDK 2.1.0
Unity 2021.3.18f1

Thanks.

Do I have to call OnRawDataUpdate()?

How can I protected method?

Sorry for bothering you.
It did not work on my computer unity playmode, however it works with Nreal light glass on Android.

However, I have a question with this capturing method.
The captured image is flipped upside down.

Is there another way to configure this problem, except rawdata flipping? (which consumes a lot of GPU data)

Hi, Kenzo. We used a shader to flip it backward in Y and the image direction looks normal in the RGBCamera-Capture demo. The reason why the image is reversed is that the origin of the pixel is different in Unity and OpenGL. Please take the shader as a reference and reverse the image.