参考类型' ISerializable'声称它是在&#m; mscorelib'中定义的。

时间:2017-08-22 19:11:52

标签: c# unity3d emgucv hololens

我在 Unity 5.6.2f1个人中使用 EmguCV 来检测相机信息流中的人脸。
如果我试图在内置的编辑器/游戏输出中运行它并且控制台中没有错误,它就可以正常工作。

但是,当我尝试将其构建到Windows应用商店,特别是HoloLens时,我在控制台中收到4个错误:

Assets\OpenCVTest.cs(57,11): error CS7069: Reference to type 'ISerializable' claims it is defined in 'mscorlib', but it could not be found
Assets\OpenCVTest.cs(57,11): error CS7069: Reference to type 'ICloneable' claims it is defined in 'mscorlib', but it could not be found
Assets\OpenCVTest.cs(62,26): error CS7069: Reference to type 'ISerializable' claims it is defined in 'mscorlib', but it could not be found
Assets\OpenCVTest.cs(62,26): error CS7069: Reference to type 'ICloneable' claims it is defined in 'mscorlib', but it could not be found

这看起来很奇怪,因为它在内置预览中运行得很好,但是当我尝试导出它时却不行。

有问题的行是

using (Image<Gray, byte> nextFrame = cap.QueryFrame ().ToImage<Gray, byte>()) {

Rectangle[] faces = cascade.DetectMultiScale(nextFrame, 1.4, 1);

根据行号,它在一行中引用Image,在另一行中引用cascade(这是CascadeClassifier)。
一些谷歌搜索不同的关键字,包括错误数字没有产生任何有用的结果。这里的类似问题也无法帮助我,因为周围环境完全不同。

这是我的完整代码,没有所有不必要的东西:

using UnityEngine;
using System.Collections;
using Emgu.CV;
using Emgu.CV.Util;
using Emgu.CV.UI;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using Emgu.Util;
using System.Runtime.InteropServices;
using System;
using System.Drawing;
using System.Windows.Forms;

public class OpenCVTest : MonoBehaviour {

private VideoCapture cap;
private CascadeClassifier cascade;
private int counter;
private int intervall;
private GameObject border;

// Use this for initialization
void Start () {
    counter = 0;
    intervall = 6;
    cap = new VideoCapture (0);
    cascade = new CascadeClassifier ("haarcascade_frontalface_alt.xml");
    border = Resources.Load ("Border") as GameObject;

}

// Update is called once per frame
void Update () {
    counter++;
    if (counter >= intervall) {
        counter = 0;
        using (Image<Gray, byte> nextFrame = cap.QueryFrame ().ToImage<Gray, byte>()) {  //ERROR 1
            if (nextFrame != null) {
                Rectangle[] faces = cascade.DetectMultiScale(nextFrame, 1.4, 1);    //ERROR 2

                //remove preivious borders
                var previous = GameObject.FindGameObjectsWithTag("Face");

                foreach (var box in previous) {
                    Destroy (box.gameObject);
                }

                //instanciate new ones
                foreach (var face in faces) {
                    GameObject newBorder = Instantiate (border);
                    newBorder.transform.position = new Vector3 (face.X / 100f, face.Y / -100f, 10);
                }
            }
        }
    }
}
}

我所有的EmguCV dll都在Assets\Plugins

0 个答案:

没有答案