【问题标题】:C# EMGU 3.1 Image stitching method parametersC# EMGU 3.1 图像拼接方法参数
【发布时间】:2017-12-13 19:57:07
【问题描述】:

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

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

  // 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 的新手

【问题讨论】:

    标签: c# emgucv


    【解决方案1】:

    您可以将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 示例,您可以在此处找到更多信息

    【讨论】:

    • 嗨,格拉布里尔。我遇到了一个从 open cv 抛出的错误,上面写着“OpenCV: (image.type() == (((0) & ((1
    • 对不起@RBK,我不明白那个错误信息。也许您可以创建一个包含更多上下文的问题?
    【解决方案2】:

    抱歉,我没有 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
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多