Unable to achieve image stitching using OpenCV and Emgu

0

I am using Emgu wrapper over Open CV to stitch planar (Scan mode) images, as I am coding in c#. These images are screen captures of my chrome window etc, where I had scrolled the page down and taken multiple screenshots. I have gone through various questions already posted on Stackoverflow. Below is my code, and I am not able to get the desired result due to a few recurring exceptions.

My Code:

    private string StitchFirstNImages(List<Mat> matList, string result_name)
    {
        using (Stitcher stitcher = new Stitcher(Stitcher.Mode.Scans, true))
        using (AKAZEFeaturesFinder finder = new AKAZEFeaturesFinder())
        {
            stitcher.SetFeaturesFinder(finder);
            stitcher.WaveCorrection = false;
            stitcher.SetWarper(new PlaneWarper(1));
            using (VectorOfMat vm = new VectorOfMat())
            {
                Mat result = new Mat();
                for (int i = 0; i < matList.Count; i++)
                {
                    vm.Push(matList[i]);
                }

                Console.WriteLine("Started Stitching = "+ matList[0].ToString());
                Stitcher.Status status = stitcher.Stitch(vm, result);

                if (status != Stitcher.Status.Ok)
                {
                    Console.WriteLine("Can't stitch images, error code = " + status);
                    return String.Empty;
                }

                Emgu.CV.CvInvoke.Imwrite(result_name, result);
                Console.WriteLine("stitching completed successfully\n" + result_name + " saved!");
                return result_name;
            }
        }
    }

A few stackoverflow articles suggested turning WaveCorrection off, but it did not help me. I am trying to provide a set of 63 images here (my set might even contain 100s of images) and stitch them all at one go. I am not doing a pair-wise stitching. My set contains only png images.

Images set used: https://ankurqa.mangopulse.com/sf/MzYyNF8xMTIyMjg2

Facing below exceptions:

System.AccessViolationException
HResult=0x80004003
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=Cannot evaluate the exception source
StackTrace: Cannot evaluate the exception stack trace

Not able to allocate xxxxxx bytes

ERR_NEED_MORE_IMGS

I am new to stitching, and above code that I have written is by following multiple articles.

Can anyone please suggest, if I am doing it the right way? Please let me know, if I need to change the feature finder? (I tried OrbFeaturesFinder, but again, was getting the 1st exception sated above)

I have gone through multiple stackoverflow questions, and tried tweaking my code, but yet no positive results.

opencv
emgucv
image-stitching
asked on Stack Overflow Mar 28, 2019 by shruti singh

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0