EmguCv EigenObjectRecognizer创建实例

时间:2017-07-23 19:41:19

标签: c# emgucv

当我的应用程序在创建EigenObjectRecognizer类的识别器对象时没有给出任何错误或警告,它会被关闭,我是否传递了错误的参数或者还有其他问题?这是我的代码

 string[] allFaces = Directory.GetFiles(savepath);
            if (allFaces != null)
            {


                Image<Gray, Byte>[] trainingImages = new Image<Gray, Byte>[allFaces.Length];
                string[] labels = new String[allFaces.Length];

                for (int i = 0; i < allFaces.Length; i++)
                {
                    trainingImages[i]  = new Image<Gray, byte>(new Bitmap(allFaces[i]));
                    labels[i] = allFaces[i].Substring(allFaces[i].LastIndexOf("\\")+1);
                }


                MCvTermCriteria termCrit = new MCvTermCriteria(allFaces.Length, 0.001);

                EigenObjectRecognizer recognizer = new EigenObjectRecognizer(
                   trainingImages,
                   labels,
                   1000,
                     ref termCrit);



                Image<Gray, Byte> testImage = new Image<Gray, Byte>(@"C:\..test\1");

                string label = recognizer.Recognize(testImage).Label;
                MessageBox.Show(label);
            }

1 个答案:

答案 0 :(得分:0)

通过从已编译的exe的原始运行中获取错误来解决问题,该错误导致从opencv而不是emgucv输入不同大小的错误。当我查看我的训练图像时,它们的大小不同。希望它能帮助别人