程序找不到文件(EmguCV)

时间:2016-10-19 11:02:25

标签: c# visual-studio opencv emgucv

我下载了EmguCV的示例。

我尝试将图片从默认更改为我的图片

默认情况下就像这样

 static void Run()
  {
     var image = new Mat("lena.jpg", LoadImageType.Color); //Read the files as an 8-bit Bgr image  
     long detectionTime;
     List<Rectangle> faces = new List<Rectangle>();
     List<Rectangle> eyes = new List<Rectangle>();

     //The cuda cascade classifier doesn't seem to be able to load "haarcascade_frontalface_default.xml" file in this release
     //disabling CUDA module for now
     bool tryUseCuda = false;

     DetectFace.Detect(
       image, "haarcascade_frontalface_default.xml", "haarcascade_eye.xml", 
       faces, eyes,
       tryUseCuda,
       out detectionTime);

     foreach (Rectangle face in faces)
        CvInvoke.Rectangle(image, face, new Bgr(Color.Green).MCvScalar, 2);
     foreach (Rectangle eye in eyes)
        CvInvoke.Rectangle(image, eye, new Bgr(Color.Aquamarine).MCvScalar, 2);

     //display the image 
     ImageViewer.Show(image, String.Format(
        "Completed face and eye detection using {0} in {1} milliseconds", 
        (tryUseCuda && CudaInvoke.HasCuda) ? "GPU"
        : CvInvoke.UseOpenCL ? "OpenCL" 
        : "CPU",
        detectionTime));
  }

} }

我将“lena.jpg”更改为我的图片 - “oleg.jpg”。

我将此图片添加到项目文件夹

通过添加现有文件 - oleg.jpg。

但是当我运行我的程序时,它说'File oleg.jpg不存在'

问题在哪里?

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

它可以将您的图像文件放在 Bin 地毯上。

问候。