Image Uploading in C# Emgu Open CV not working, giving an Exception every time I try and load

StackOverflow https://stackoverflow.com/questions/22670253

  •  22-06-2023
  •  | 
  •  

Question

Trying to upload an image into my image box and keep getting an exception, that breaks the code any ideas? (Type initialized Exception). This is the first time I have used the Emgu like this

       private void btnload_Click(object sender, EventArgs e)
        {
        if (ofd.ShowDialog() == DialogResult.OK)
            {
                input = new Image<Bgr, byte>(ofd.FileName).Resize(500, 500,INTER.CV_INTER_CUBIC, false);
                imageBox1.Image = input;
                gray = input.Convert<Gray, Byte>().PyrDown().PyrUp();
            }
            btnSet.Enabled = true;
        }
Was it helpful?

Solution

The Stack Trace surely has more info. Usually the most common problems are:

  • EMGU and OpenCV DLL verisons: Check if you're using the correct 32 or 64 bit DLL's version like your project.
  • EMGU version agains OpenCV version: Check the Stack Trace Message, you might find something saying "Unable to load DLL 'some DLL'"
    • If this is the case, check if the DLL's next to your EXE have the same version (number at the end of the file name)
  • OpenCV DLL's Missing: Do not forget to copy OpenCV DLL's to the same folder of the EXE

Hope this helps, Cheers

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top