Jump to content
 
Sign in to follow this  
aroboyko

Access camera resources to openCV

Recommended Posts

I  try to use find edge in Unity. I think it is to import the camera image to openCV process(for find edge), and import back to the material of unity.
Is any one know how to get camera resource import to openCV?(I use unity SRWorks SDK)
Or there is a better way to achieve the effect I want

@Daniel_Y @Andy.YC_Wang

Share this post


Link to post
Share on other sites

You can get the texture buffer of camera image in ViveSR_DaulCameraImageCapture.cs
There are four textures in our script.(TextureDistoredLeft, TextureDistoredRight, TextureUndistoredLeft, TextureUndistoredRight)
And you can find out more detailed information in Vive.Plugin.SR.ViveSR_DualCameraImageCapture.Initial().

The texture buffer can be converted to opencv mat.

 

@aroboyko

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Please sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...