473,809 Members | 2,931 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

JOHNYKUTTY
10 New Member
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
Expand|Select|Wrap|Line Numbers
  1. 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?????????????
Feb 2 '11 #1
6 20674
GaryTexmo
1,501 Recognized Expert Top Contributor
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.

Expand|Select|Wrap|Line Numbers
  1. try
  2. {
  3.   Image<Bgr, Byte> cvimage = new Image<Bgr, Byte>(bmp);
  4. }
  5. catch (Exception e)
  6. {
  7.   Console.WriteLine(e.Message);
  8.   // or MessageBox.Show(e.Message) if you like
  9. }
Feb 2 '11 #2
JOHNYKUTTY
10 New Member
the exception message is like this
The type initializer for 'Emgu.CV.cvInvo ke' threw an exception
can you explain the reason now
Feb 2 '11 #3
GaryTexmo
1,501 Recognized Expert Top Contributor
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.
Feb 2 '11 #4
JOHNYKUTTY
10 New Member
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
Feb 3 '11 #5
GaryTexmo
1,501 Recognized Expert Top Contributor
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 ;)
Feb 3 '11 #6
Stefs
1 New Member
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.
Oct 16 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

7
14272
by: Toby Mathews | last post by:
Hi, In an ASP.Net application I want to convert open create a FileStream object from a System.Drawing.Image - is this possible? I create an instance of an Image object using the FromFile method, then use the GetThumbnailImage method to create a second Image. This second one is the one I want to get a FileStream from, so that I can then use its Handle to use Response.WriteFile to output the thumbnail on my ASP.Net page. Any help would...
3
7159
by: david | last post by:
As Title. Thanks in advance. David
1
5209
by: Dennis Myrén | last post by:
Hi. I use System.Drawing.Bitmap to copy bitmap pixel data. I use LockBits to retrieve a BitmapData which in turn provides me with the Scan0 property which i then use to loop the pixel data using a byte *. I am aware of that internally GDI+ stores RGB as BGR, therefore i have to manually swap the R and B components of each pixel. Since GDI+ internally stores the components in BGR order, there is'nt a way to copy the entire pixel data...
3
17401
by: instruo | last post by:
I'm using the System.Drawing.Bitmap class for loading a 32-bit bmp file which includes an alpha channel. The problem is, when it gets loaded (just using the Bitmap(string filename) constructor), it doesn't bother bringing the alpha along with it. All of the pixels just show "255" as their alpha value and Bitmap.IsAlphaPixelFormat() returns false. I know that the alpha does exist physically and has worked with this exact image in other...
0
1857
by: John via .NET 247 | last post by:
Hi, I'm using the System.Drawing.Bitmap namespace to load an image,and the RotateNoneFlipY method to flip that image before saving.However I have noticed that the saved image appears cropped andhas a large blue area on a particular side, which gets largerevery time the image is flipped again. I'm assuming that this may be due to a lack of time assigned tothe procedure before saving the image, but I'm not sure how Ican recitify this. I...
7
8246
by: Fir5tSight | last post by:
Hi All, I used the following code in C#: using System.Drawing; //blah blah blah Bitmap bmp = new Bitmap();
3
2976
by: gudguy | last post by:
dear gurus, I have a 3rd party component that triggers an event and exposed the Width and Height of the video frame, plus the Device context handle (hDC) for the data packet (it is supposed to be a bitmap packets). I want to know how to save this to System::Drawing::Bitmap object i.e. System::Drawing::Bitmap SaveToBitmap(int width, int height, IntPtr hDC) { return theBitmapObject; }
3
5545
by: wingsganesh | last post by:
Hi buddys, I have the followinf Bug......... when i run my application "NotSupportedException was un handled" in "System.Drawing.Icon" for the following designer code.... Me.picImgMain.Image = CType(resources.GetObject("picImgMain.Image"), System.Drawing.Image) can u give any idea
3
8728
by: =?Utf-8?B?UGVy?= | last post by:
I'm working on a project that have to load an display pcx-images in a PictureBox-control. When I try to load the file with Bitmap.FromFile I get an exception. Does anybody have an idea ?
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10633
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10375
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10114
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9198
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7651
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3860
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.