C# 如何将位图转换为图像<Bgr, Byte>

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16241004/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 00:30:15  来源:igfitidea点击:

How to convert Bitmap to Image<Bgr, Byte>

c#.netopencv

提问by Lemmouchi Rédha Dida

I am using the OpenCV library for image processing.

我正在使用 OpenCV 库进行图像处理。

I want to convert a System.Drawing.Bitmapto an Image<Bgr, Byte>. How can I do this?

我想将 a 转换System.Drawing.BitmapImage<Bgr, Byte>. 我怎样才能做到这一点?

采纳答案by keyboardP

The Imageconstructor has a Bitmapoverload (assuming you're using the Emgu CV wrapper since you've marked it .NET).

Image构造具有Bitmap过载(假设你使用的Emgu CV包装,因为你已经将其标记.NET)。

Image<Bgr, Byte> myImage = new Image<Bgr, Byte>(myBitmap); 

回答by mohammad karim hardani asl

for whom to be concern: you should add dependency dll into project and change 'copy to output directory' property to 'copy always' (add -> existing item) from Emgu\emgucv-windows-universal-cuda 2.9.0.1922\bin\x86

需要关注的对象:您应该将依赖项 dll 添加到项目中,并将 Emgu\emgucv-windows-universal-cuda 2.9.0.1922\bin\ 中的“复制到输出目录”属性更改为“始终复制”(添加 -> 现有项目) x86

in my project add : opencv_core290.dll , opencv_highgui290.dll , opencv_ffmpeg290.dll , opencv_imageproc290.dll and cudart32_55.dll

在我的项目中添加: opencv_core290.dll 、 opencv_highgui290.dll 、 opencv_ffmpeg290.dll 、 opencv_imageproc290.dll 和 cudart32_55.dll

from: The type initializer for 'Emgu.CV.CvInvoke' threw an exception

来自:“Emgu.CV.CvInvoke”的类型初始值设定项引发异常