2015-10-20 86 views
0

好吧,首先我只想说,我已经尝试了多个教程来解决这个错误和众多的网站,我已经搜索了这个论坛的潜在解决方案,但无济于事。我使用的代码几乎与我在互联网上找到的代码完全相同,并且在运行代码时不会出现语法错误。所以我得出结论,我有一个参考或联系问题。新的OpenCV和遇到了一个奇怪的错误

namespace Video_Capture 
{ 
    public partial class CameraCapture : Form 
    { 
     //Variable Declaration 
     private Capture capture; //takes images from camera as image frame 
     private bool captureInProgress; //checks if capture is executing 

     private void ProcessFram(object sender, EventArgs arg) 
     { 
      Image<Bgr, Byte> ImageFrame = capture.QueryFrame(); 
      CamImageBox.Image = ImageFrame; 
     } 
     public CameraCapture() 
     { 
      InitializeComponent(); 
     } 

     private void btnStart_Click(object sender, EventArgs e) 
     { 
      #region if capture is not created, create it now 
      if (capture == null) 
      { 
       try 
       { 
        capture = new Capture(); 
       } 
       catch (NullReferenceException excpt) 
       { 
        MessageBox.Show(excpt.Message); 
       } 
      } 
      #endregion 

      if (capture != null) 
      { 
       if (captureInProgress) 
       { //if camera is getting frames then stop the capture and set button Text 
        //"Start" for resuming capture 
        btnStart.Text = "Start!"; 
        Application.Idle -= ProcessFram; 

       } 
       else 
       { 
        //if camera is not getting frames then start the capture and set button 
        //Text to "stop" for pausing capture 
        btnStart.Text = "Stop"; 
        Application.Idle += ProcessFram; 

       } 
       captureInProgress = !captureInProgress; 
      } 
     } 
      private void ReleaseData() 
      { 
       if (capture != null) 
        capture.Dispose(); 
      } 
     } 
    } 

After running the code and pressing the "start" button I get this error.

+0

您使用的是哪个版本的Emgu?另外,确保您的项目在属性下设置为正确的目标平台(32/64位)。它必须匹配Emgu dlls。 –

回答

0

你检查你的依赖呢?您的问题看起来像是这个问题的复本,请检查接受的答案:EmguCV TypeInitializationException

+0

是的,我试图粘贴目录中的这些.dll文件,但它仍然显示相同的错误。 – rorivy15

+0

您是否尝试过使用Process Monitor或Dependency Walker来确定是否缺少其他东西?我推荐进程监视器,在线上放置一个断点,在进程监视器上开始捕获事件,在Visual Studio上执行步骤(F5),停止捕获事件。然后从列表中筛选您的进程并搜索您的进程找不到的DLL。 您可以在此处下载Process Monitor:https://technet.microsoft.com/en-us/library/bb896645.aspx –