如何创建具有特定类型的 Emgu::CV::Image?

How to create an Emgu::CV::Image with a specific type?

在 OpenCV 中,我们可以访问 CV_XX 类型,它允许您创建矩阵,例如 CV_32SC1。我如何在 EmguCV 中执行此操作?

提问的原因是:

我目前正在使用 EmguCV 并在需要创建特定类型的图像时遇到错误,但无法找到这些值。

这是我的代码:

Emgu::CV::Image<Emgu::CV::Structure::Gray, byte>^ mask = gcnew Emgu::CV::Image<Emgu::CV::Structure::Gray, byte>(gray->Size);
try { CvInvoke::cvDistTransform(255-gray, tmp, CvEnum::DIST_TYPE::CV_DIST_L1, 3, nullptr, mask); }

给出错误:

OpenCV: the output array of labels must be 32sC1

所以我认为我需要将字节类型更改为 32sC1,我该怎么做?

我正在使用 EmguCV 2.0

Working with images 页面,特别是关于 EmguCV 2.0 的部分,它提供了以下关于图像深度的说明:

Image Depth Image Depth is specified using the second generic parameter Depth. The types of depth supported in Emgu CV 1.4.0.0 include

  • Byte
  • SByte
  • Single (float)
  • Double
  • UInt16
  • Int16
  • Int32 (int)

我相信这意味着它根本不使用 CV_XXX 类型,只使用上述类型。

对于我的问题,我将类型设置为 Int32,它似乎停止了错误。