Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
570 views
in Technique[技术] by (71.8m points)

c# - EmguCV TypeInitializationException

i really a newbie with EgmuCV

i try to capture images from webcam with the following code:

//Program.cs (Winform)
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.UI;
using Emgu.Util;
using Emgu.CV.Structure;

namespace EgmuCVTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Capture cp = new Capture();
            ImageViewer imv = new ImageViewer();

            Application.Idle += new EventHandler(delegate(object s, EventArgs ea)
            {
                imv.Image = cp.QueryFrame();
            });

            imv.ShowDialog();

        }
    }
}

i get the follow error:

enter image description here

i check and have all necesary dll in the .exe folder

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

After experiencing this same problem for a while, I found the instructions for solving this (TypeInitializer Exception) are incomplete.

  1. For a basic app, you need cvextern.dll, Emgu.CV.dll, Emgu.CV.UI.dll, Emgu.Util.dll in the .EXE's directory.

  2. You need a x86(x64) dir in the .exe directory and inside "x86" dir you need opencv_calib3dXXX.dll, opencv_contribXXX.dll, opencv_coreXXX.dll, opencv_features2dXXX.dll, opencv_highguiXXX.dll, opencv_imgprocXXX.dll, opencv_legacyXXX.dll, opencv_mlXXX.dll, opencv_objectdetectXXX.dll, opencv_videoXXX.dll and cudart32_42_9.dll, npp32_42_9.dll, opencv_flann240.dll

The app will work as soon as you include all of the required DLLs.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...