-1
我在Unity中使用opencvsharp。如何將IplImage轉換爲Unity中的Texture2d
我想將iplImage轉換爲Texture2D。我想這樣做:
Texture2D alphaTexture = new Texture2D(1024, 768, TextureFormat.Alpha8, false);
alphaTexture.wrapMode = TextureWrapMode.Clamp;
alphaTexture.filterMode = FilterMode.Point;
IplImage originIplImageAAA = Cv.CreateImage(new CvSize(1024, 768), BitDepth.U8, 1);
Cv.Zero(originIplImageAAA);
int imgSize = originIplImageAAA.ImageSize;
IntPtr aa;
int step;
CvSize rawSize;
originIplImageAAA.GetRawData(out aa, out step, out rawSize);
byte[] imageData = new byte[imgSize];
Marshal.Copy(aa, imageData, 0, imgSize);
alphaTexture.LoadImage(imageData);
但它不起作用。我如何正確轉換它?
我試過你說的和我發現它有點慢。你能告訴我這個艱難的解決方案嗎? – xushunwang