- Home /
Convert Texture2D to Image emgu CV - fast way
Hi all,
I'm trying to convert a texture2D to an emgu CV Image. I want a fast way to do it, without access each pixel individually (for loop). I'm trying to use Marshal.copy or some memory access.
If I know how color32[] are place in memory it would be great.
Thanks in advance.
Answer by arjunc007 · Aug 12, 2018 at 08:11 PM
I'm doing something like this:
Image<Bgr, byte> output;
MemoryStream m = new MemoryStream(input.EncodeToPNG());
Image<Rgba, byte> temp = new Image<Rgba, byte>(input.width, input.height);
temp.Bitmap = new Bitmap(m);
output = temp.Convert<Bgr, byte>();
Hope this helps.
Your answer
![](https://koobas.hobune.stream/wayback/20220613145635im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unity Crash - Texture2D.ReadPixels - Only Occurs in Builds on certain Machines 0 Answers
Loading external Image as Texture2D increases memory consumption dramatically on iOS 0 Answers
Are Texture2Ds in a Resources folder always loaded in memory? 1 Answer
How do I know if there's enough graphics card memory to allocate a new texture? 0 Answers
iOS crash with "Memory pressure" error - too many sprites? 0 Answers