C#中的错误“"emgu.cv.cvinvoke"的类型初始值设定项引发了异常." [英] Error in C# "the type initializer for 'emgu.cv.cvinvoke' threw an exception."

查看:244
本文介绍了C#中的错误“"emgu.cv.cvinvoke"的类型初始值设定项引发了异常."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码错误,请帮帮我!!!!

Code error, Please help me!!!

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using Emgu.CV.UI;

         
namespace WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        Capture capturecam = null;       //instance for capture using webcam
            bool CapturingProcess = false;   //boolean stating the capturing process status
            Image<Bgr, Byte> imgOrg;   //image type RGB (or Bgr as we say in Open CV)
            Image<Gray, Byte> imgProc; //processed image will be grayscale so a gray image
            
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

            
            try
            {
                capturecam = new Capture();
               
            }
            catch (NullReferenceException exception)
            {
                MessageBox.Show(exception.Message);
                return;
            }
            Application.Idle += new EventHandler(ProcessFunction);
            CapturingProcess = true;

        }
        void ProcessFunction (object sender, EventArgs e)
        {
            imgOrg=capturecam.QueryFrame();
            if (imgOrg == null) return;

            imgProc = imgOrg.InRange(new Bgr(50,50,50) , new Bgr (255,255,255));
            imgProc = imgProc.SmoothGaussian(9);
            original.Image=imgOrg;
            processed.Image=imgProc;
        }

        private void playorpause_Click(object sender, EventArgs e)
        {
            if (CapturingProcess == true)
            {
                Application.Idle -= ProcessFunction;
                CapturingProcess = false;
                playorpause.Text= "Play";
            }
            else
            {
                Application.Idle += ProcessFunction;
                CapturingProcess = true;
                playorpause.Text= "Pause";
            }
        }
    }
}



我尝试过的事情:

调试后,错误:



What I have tried:

After Debug, error:

"The type initializer for ''Emgu.CV.CvInvoke'' threw an exception."

.

推荐答案

,这是运行时问题,具体取决于何时发生.可能的原因可能是"Emgu"运行时不存在或无法在应用程序中运行.就像未注册的dll或不在应用程序目录中的dll或该问题的某些错误版本.

尝试检查异常的详细信息,因为通常会有一些详细的文本解释发生了什么.
it is a runtime issue, depending when it happens. A possible reason maybe that the "Emgu"-runtime isnt present or working in the app. Like not registered or dlls not in the app-directory or some wrong version like in that question The type initializer for '''' threw an exception.

Try to inspect the details of the exception, because often some detail text explains what happened.


这篇关于C#中的错误“"emgu.cv.cvinvoke"的类型初始值设定项引发了异常."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆