Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Can’;t创建Emgu.CV.Image<;Bgr,字节>;从位图构造函数参数_C#_Opencv_Emgucv - Fatal编程技术网

C# Can’;t创建Emgu.CV.Image<;Bgr,字节>;从位图构造函数参数

C# Can’;t创建Emgu.CV.Image<;Bgr,字节>;从位图构造函数参数,c#,opencv,emgucv,C#,Opencv,Emgucv,根据Emgu,我应该能够从位图创建Emgu.CV.Image: Image<Bgr, Byte> img = new Image<Bgr, Byte>(bmp); //where bmp is a Bitmap 致: Image source=新图像(bitmap.Width、bitmap.Height、strip0、ptr0); 成功了。我将在几天后发布这篇文章作为答案,但我希望其他使用Emgu的人能够发布文档的最新情况以及最新版本中是否缺少构造函数 /// <

根据Emgu,我应该能够从位图创建Emgu.CV.Image:

Image<Bgr, Byte> img = new Image<Bgr, Byte>(bmp); //where bmp is a Bitmap
致:

Image source=新图像(bitmap.Width、bitmap.Height、strip0、ptr0);
成功了。我将在几天后发布这篇文章作为答案,但我希望其他使用Emgu的人能够发布文档的最新情况以及最新版本中是否缺少构造函数

/// <summary>Create an Image from unmanaged data.</summary>
/// <param name="width">The width of the image</param>
/// <param name="height">The height of the image</param>
/// <param name="stride">Size of aligned image row in bytes</param>
/// <param name="scan0">Pointer to aligned image data, <b>where each row should be 4-align</b> </param>
/// <remarks>The caller is responsible for allocating and freeing the block of memory specified by the scan0 parameter, however, the memory should not be released until the related Image is released. </remarks>

public Image(int width, int height, int stride, IntPtr scan0)
{
  this.MapDataToImage(width, height, stride, scan0);
}
// bitmap being a screenshot I painted earlier in code
BitmapData InputBitmapData0 = bitmap.LockBits(
new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, bitmap.PixelFormat);

IntPtr ptr0 = InputBitmapData0.Scan0;
int stride0 = InputBitmapData0.Stride;
byte[]  byteArray = new byte[InputBitmapData0.Stride * bitmap.Height];
Marshal.Copy(ptr0, byteArray, 0, byteArray.Length);

...
Image<Bgr, Byte> source = new Image<Bgr, Byte>(bitmap.Width, bitmap.Height,stride0, ptr0);
Image<Bgr, byte> template= new Image<Bgr, byte>(@"C:\debuggerIcon.jpg");
...

Image<Bgr, byte> source = new Image<Bgr, byte>(bitmap.Width, bitmap.Height,stride0, ptr0);
Image<Bgra, byte> source = new Image<Bgra, byte>(bitmap.Width, bitmap.Height,stride0, ptr0);