문제

Is there any way to convert an Image of type System.Drawing.Image in to Image of Emgu.CV.Image type or vice versa on EmguCV using C#? I will explain per your request if additional explanation is needed about the purpose of doing this.

도움이 되었습니까?

해결책

// Converting the master image to a bitmap
Bitmap masterImage = (Bitmap) pbxMaster.Image;

// Normalizing it to grayscale
Image<Gray, Byte> normalizedMasterImage = new Image<Gray, Byte>(masterImage);

다른 팁

EmguCV version 4.2.0.3636 [and forward] works with below code:

using System.Drawing;
using System.Drawing.Imaging;
using Emgu.CV;
using Emgu.CV.Structure;

//inputImage type is System.Drawing.Image
Bitmap bitmapImage = new Bitmap(pictureBox1.Image);

Rectangle rectangle = new Rectangle(0, 0, bitmapImage.Width, bitmapImage.Height);//System.Drawing
BitmapData bmpData = bitmapImage.LockBits(rectangle, ImageLockMode.ReadWrite, bitmapImage.PixelFormat);//System.Drawing.Imaging

Image<Bgr, byte> outputImage = new Image<Bgr, byte>(bitmapImage.Width, bitmapImage.Height, bmpData.Stride, bmpData.Scan0);//(IntPtr)
//outputImage type is Emgu.CV.Image
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top