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

C# EMGU 3.1 Image stitching method parameters

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

以下代码在 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例子,你可以在那里找到更多信息

抱歉,我没有 50 的声望,因此无法发表评论。否则我不会在这里发帖。 使用下面的代码,我遇到了这个错误信息:Argument 1 - cannot convert from 'System.Collections.Generic.List>'to 'Emgu.CV.Mat'。错误来自 "vm.Push(sourceImages);"

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
    }
}