How to convert system.drawing.bitmap to emgu.cv.image in C#?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JOHNYKUTTY
    New Member
    • Dec 2010
    • 10

    How to convert system.drawing.bitmap to emgu.cv.image in C#?

    i have to convert an image variable(system .drawing.bitmap orsystem.drawin g.image or AForge.Imaging. Image) to Emgu.CV.Image type i have used the code below
    Code:
    Image<Bgr, Byte> cvimage = new Image<Bgr, Byte>(bmp);
    but it is not working but also crashing the program
    When i put this code in a try block then it is not crashing.
    anyone can help me?????????????
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    I'm afraid I don't know what an Emgu.CV.Image is, so I'm afraid I can't help you convert it.

    That said, the crash is likely the result of an exception. When you put a try/catch block around it, it's handling the exception and thus not crashing, but you're still not getting the desired result.

    Try handling the exception and output the message. This should hopefully give you an idea as to what's wrong.

    Code:
    try
    {
      Image<Bgr, Byte> cvimage = new Image<Bgr, Byte>(bmp);
    }
    catch (Exception e)
    {
      Console.WriteLine(e.Message);
      // or MessageBox.Show(e.Message) if you like
    }

    Comment

    • JOHNYKUTTY
      New Member
      • Dec 2010
      • 10

      #3
      the exception message is like this
      The type initializer for 'Emgu.CV.cvInvo ke' threw an exception
      can you explain the reason now

      Comment

      • GaryTexmo
        Recognized Expert Top Contributor
        • Jul 2009
        • 1501

        #4
        No, I can't. I don't know what Emgu.CV.Image is. It looks like it's throwing an internal exception but that's all I can tell you. Is there anything in the inner exception message?

        What is Emgu.CV? Is this a library you downloaded? I don't think it's part of the standard .Net framework, so I'm afraid I can't really help you. Perhaps someone else is more familiar with this and can offer some ideas.

        Comment

        • JOHNYKUTTY
          New Member
          • Dec 2010
          • 10

          #5
          Emgu CV is a C# wrapper of open cv(open source computer vision library) which is developed by intel corporation and is consists of some routines for computer vision programming.

          You can lean more about open cv here

          Comment

          • GaryTexmo
            Recognized Expert Top Contributor
            • Jul 2009
            • 1501

            #6
            Then unless one of the resident experts here is familiar with this library, I think you're going to have to consult the doc and/or support forums (if any exist) for that library.

            Honestly, if I had to take a guess, it would be that you can't supply a bitmap like that... but that's pure speculation. I don't have a background in this, and I'd imagine not many folks around here will... but you never know ;)

            Comment

            • Stefs
              New Member
              • Oct 2011
              • 1

              #7
              Hi,
              I had the same problem. After digging into the exception, I discovered that the compilation could not find "opencv_core231 .dll". I copied this dll from the emguCV bin folder into my project folder, and it solved the issue.

              Comment

              Working...