OpenCV的新手并遇到了一个奇怪的错误

时间:2015-10-20 17:34:30

标签: c# opencv emgucv

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

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.

1 个答案:

答案 0 :(得分:0)

你检查了你的依赖关系吗?您的问题看起来与此问题重复,请检查已接受的答案:EmguCV TypeInitializationException