问题
I need to convert a Mat to an Image in Emgu CV. Trying to cast a Mat to an image produces an exception: Cannot implicitly convert type 'Emgu.CV.Mat' to 'Emgu.CV.Image
Image<Bgr, Byte> imgeOrigenal;
Capture capWebcam = null;
imgeOrigenal = capWebcam.QueryFrame();//error line
How can I convert the Mat to an Image?
回答1:
the correct answer is the first comment @David_D sent under the question.
Image<Bgr, Byte> imgeOrigenal = capWebcam.QueryFrame().ToImage<Bgr, Byte>();
回答2:
In can you want to show the image in a pictureBox
or a dataGridView
, you can also load the image as a Bitmap object like this:
imgeOrigenal = new Bitmap(capWebcam.Bitmap);
来源:https://stackoverflow.com/questions/34914417/how-to-convert-mat-to-image