C# EMGU 3.1 Image stitching method parameters

c# emgucv

1517 просмотра

2 ответа

I am trying to stitch multiple images to single(panorama) image.

Following code working fine in EMGU-2.4 but in EMGU-3.1 I have a problem in passing parameters in stitch method.

  // 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 documentation : stitch method contains new parameters like below

  //
        // 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);

How to pass this two parameters in my existing code and what is this parameters for?

Please I am pretty new to EMGU

Автор: Andi AR Источник Размещён: 08.11.2019 11:17

Ответы (2)


2 плюса

Решение

You could pass a Emgu.CV.Util.VectorOfMat as input and use a EMGU.CV.Mat to store the output, like this:

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

Note that the "resultImageBox" used above is a ImageBox from EMGU, but you could use a PictureBox to display result.Bitmap, for example.

This example was taken from the Stitching example provided by EMGU, you can find more information there

Автор: Gabriel Prá Размещён: 25.08.2016 07:47

1 плюс

Sorry, I did not have 50 reputation hence I could not comment. Otherwise I wouldn't be posting here. Using the below code, I encounter this error message: Argument 1 - cannot convert from 'System.Collections.Generic.List>'to 'Emgu.CV.Mat'. The error is from "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
    }
}
Автор: user8723553 Размещён: 13.12.2017 11:57
Вопросы из категории :
32x32