gpt4 book ai didi

C# EMGU 3.1 图像拼接方法参数

转载 作者:行者123 更新时间:2023-11-30 21:46:44 27 4
gpt4 key购买 nike

我正在尝试将多张图像拼接成单张(全景)图像。

以下代码在 EMGU-2.4 中运行良好,但在 EMGU-3.1 中,我在 stitch 方法中传递参数时遇到问题。

  // Collect all images
List<Image<Bgr, Byte>> sourceImages = new List<Image<Bgr, Byte>>();

for (int i = 1; i <7 ; i++)
{
string fileN = fl1 + "n (" + i.ToString() + ").jpg";
sourceImages.Add(new Image<Bgr, Byte>(fileN));
}

try
{
using (Stitcher stitcher = new Stitcher(false))
{
// Stitch images
Image<Bgr, Byte> result = stitcher.Stitch(sourceImages.ToArray());
Bitmap bm = result.ToBitmap();
bm.Save(fl1 + "resul.jpeg", ImageFormat.Jpeg);
}
}
finally
{

}

EMGU-3.1 文档:stitch 方法包含如下新参数

  //
// Summary:
// Compute the panoramic images given the images
//
// Parameters:
// images:
// The input images. This can be, for example, a VectorOfMat
//
// pano:
// The panoramic image
//
// Returns:
// true if successful
public bool Stitch(IInputArray images, IOutputArray pano);

如何在我现有的代码中传递这两个参数,这个参数有什么用?

拜托,我是 EMGU 的新手

最佳答案

您可以传递 Emgu.CV.Util.VectorOfMat 作为输入并使用 EMGU.CV.Mat 来存储输出,如下所示:

using (Stitcher stitcher = new Stitcher(false))
{
using (VectorOfMat vm = new VectorOfMat())
{
Mat result = new Mat();
vm.Push(sourceImages);
stitcher.Stitch(vm, result);
resultImageBox.Image = result; //Display the result
}
}

请注意,上面使用的“resultImageBox”是来自 EMGU 的 ImageBox,但您可以使用 PictureBox 来显示 result.Bitmap,例如。

这个例子取自EMGU提供的Stitching例子,你可以在那里找到更多信息

关于C# EMGU 3.1 图像拼接方法参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39053940/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com