【问题标题】:Unity crash caused by EmguCVEmguCV 导致 Unity 崩溃
【发布时间】:2018-05-25 10:44:43
【问题描述】:

我的程序出现错误,在尝试运行此功能后,unity 崩溃了。作用是将Texture2D转为Image

void SetTextureDefault()
{
    try
    {
        Texture2D currentTexture = new Texture2D(CameraTexture.width, CameraTexture.height);
        currentTexture.SetPixels(CameraTexture.GetPixels());
        currentTexture.Apply();

        // Asuming leftBackground and rightBackground of Image<Bgra, byte> exist

        if (leftBackground == null || rightBackground == null)
        {
            using (var ms = new MemoryStream(currentTexture.EncodeToPNG()))
            {
                leftBackground = new Image<Bgra, byte>(new Bitmap(ms));
            }
        }
        else
        {
            rightBackground.Bytes = leftBackground.Bytes = currentTexture.EncodeToPNG();
        }
    }
    catch (Exception err)
    {
        Debug.Log(err.StackTrace);
    }
}

Unity(编辑器和独立应用程序)刚刚崩溃并且没有显示任何错误。仅显示此window

我只能考虑内存访问冲突(但应用程序没有显示任何异常)

如果我删除该功能,程序将正常运行

我在 EmguCV(桌面版)中使用 Unity 个人版。

【问题讨论】:

    标签: unity3d emgucv


    【解决方案1】:

    导致应用崩溃的问题是:

    leftBackground = new Image<Bgra, byte>(new Bitmap(ms));
    

    在构建一个包含该函数的新 dll 并将其附加到统一并工作后,问题解决了。 奇怪...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-23
      • 2020-12-02
      • 2013-11-11
      • 2011-01-24
      相关资源
      最近更新 更多