I wanted to get the texture of the front camera and used ViveSR_DaulCameraImageCapture.GetUndistortedTexture with the following code, but I could not get the texture well.
Texture2D imgTexture_Left = new Texture2D(ViveSR_DualCameraImageCapture.UndistortedImageWidth, ViveSR_DualCameraImageCapture.UndistortedImageHeight, TextureFormat.RGBA32, false);
Texture2D imgTexture_Right = new Texture2D(ViveSR_DualCameraImageCapture.UndistortedImageWidth, ViveSR_DualCameraImageCapture.UndistortedImageHeight, TextureFormat.RGBA32, false);
int frameIndex, timeIndex;
Matrix4x4 poseLeft, poseRight;
ViveSR_DualCameraImageCapture.GetUndistortedTexture(out imgTexture_Left, out imgTexture_Right, out frameIndex, out timeIndex, out poseLeft, out poseRight); // Line 97
quad.GetComponent<Renderer>().material.mainTexture = imgTexture_Left;
The runtime errors are as follows:
NullReferenceException: Object reference not set to an instance of an object
Vive.Plugin.SR.ViveSR_DualCameraImageCapture.GetUndistortedTexture (UnityEngine.Texture2D& imageLeft, UnityEngine.Texture2D& imageRight, System.Int32& frameIndex, System.Int32& timeIndex, UnityEngine.Matrix4x4& poseLeft, UnityEngine.Matrix4x4& poseRight) (at Assets/ViveSR/Scripts/ViveSR_DualCameraImageCapture.cs:353)
******.*******.Start () (at Assets/********/MyScript.cs:97)
Line 353 of ViveSR_DaulCameraImageCapture is the following code.
if (DataInfoUndistorted[(int)SeeThroughDataMask.UNDISTORTED_FRAME_LEFT].ptr != IntPtr.Zero && DataInfoUndistorted[(int)SeeThroughDataMask.UNDISTORTED_FRAME_RIGHT].ptr != IntPtr.Zero)
Please let me know if there is a solution.
Other methods are acceptable.
Thank you.
@Sean_Su