1. Texture2D to Mat
1.1 通过png编码
int w=... int h=... ... Texture2D tex=new Texture2D(w,h,TextureFormat.RGB24,false,false); Mat frame = new Mat(h,w, MatType.CV_8UC3); ... //the key code tex.LoadImage (mat.ToBytes(".png"));
1.2 通过原始像素矩阵(数组)
2.Mat to Texture2D
2.1 通过png编码
int w=... int h=... ... Texture2D tex=new Texture2D(w,h,TextureFormat.RGB24,false,false); ... //the key code Mat mat=Mat.FromImageData(img.EncodeToPNG());
2.2 通过原始像素矩阵(数组)
int w=... int h=... ... Texture2D tex=new Texture2D(w,h,TextureFormat.RGB24,false,false); //key code Mat mat= new Mat(h, w, MatType.CV_8UC3, img.GetRawTextureData()); Cv2.CvtColor(tmp, tmp, ColorConversion.BgrToRgb); Cv2.Flip(tmp, tmp, FlipMode.X);
时间: 2024-10-11 01:19:21