Closed Rombond closed 1 week ago
After using fastTexture2DToMat in the Update loop i've got a lot of memory leak. (Editor and Build)
fastTexture2DToMat
I used https://github.com/Unity-Technologies/UnityBlackmagicVideo/tree/main to get a renderTexture of my camera Size: 1280x720 Format: ARGBHalf
[SerializeField] InputVideoDeviceHandle inputDevice; RenderTexture renderTexture; int width = renderTexture.width; int height = renderTexture.height; Mat rgbaMat = new Mat(height, width, CvType.CV_8UC4); Mat grayMat = new Mat(height, width, CvType.CV_8UC1); Texture2D rgbaTexture = new Texture2D(rgbaMat.width(), rgbaMat.height(), TextureFormat.ARGB32, false); void Update() { if (inputDevice.IsActive()) { if (inputDevice.TryGetRenderTexture(out renderTexture)) { Utils.textureToTexture2D(renderTexture, rgbaTexture); Utils.fastTexture2DToMat(rgbaTexture, rgbaMat); Imgproc.cvtColor(rgbaMat, grayMat, Imgproc.COLOR_RGBA2GRAY); } } }
It doesn't happen with texture2DToMat but it is too slow for the Update loop. In profiler and memory profiler, memory leak is in "Untracked" type.
texture2DToMat
@Rombond Upon investigation, a bug was found in the C# and C++ data passing process code. OpenCVForUnity 2.6.1 has already been fixed and updated. Thank you for your report.
After using
fastTexture2DToMat
in the Update loop i've got a lot of memory leak. (Editor and Build)I used https://github.com/Unity-Technologies/UnityBlackmagicVideo/tree/main to get a renderTexture of my camera Size: 1280x720 Format: ARGBHalf
It doesn't happen with
texture2DToMat
but it is too slow for the Update loop. In profiler and memory profiler, memory leak is in "Untracked" type.