I try to render image from the Emgu's camera capture on new Unity3D UI system. Till now, I used ImageToTexture2d from this repository: https://github.com/neutmute/emgucv/blob/3ceb85cba71cf957d5e31ae0a70da4bbf746d0e8/Emgu.CV/PInvoke/Unity/TextureConvert.cs and then used Sprite.Create() to finally achieve the wanted result.
BUT! It appears there is some massive memory leak as after 2-3 minutes of my game running Unity editor suddenly takes about 3GB of RAM where it started with about 200MB.
I have two susspects:
- (More Probabble) The method I'm using does not clean the memory. It uses InterOp and creates some unsafe pointers - it smells leakage.
- The Sprite.Create runned every frame holds old sprites in memory and does not remove them.
Does any of You knows any other way to convert Emgu's Image to Sprite/Texture(without using an InterOp) or any other way I could show it on New Unity's UI. It has to be the Emgu's Image as I also do some operations on the images I recieve from camera.
Thanks in advance for responses and help. :D