usingEmgu.CV;usingEmgu.CV.CvEnum;usingEmgu.CV.Features2D;usingEmgu.CV.Stitching;usingEmgu.CV.Structure;usingEmgu.CV.Util;usingSystem.Diagnostics;namespaceTools{publicclassImageStitcher{publicstaticvoidStitchImages(string[] imagePaths,string stitchedImagePath){Image<Bgr,byte>[] sourceImages =newImage<Bgr,byte>[imagePaths.Length];for(int i =0; i < sourceImages.Length; i++){sourceImages[i]=newImage<Bgr,byte>(imagePaths[i]);}try{//only use GPU if you have build the native binary from code and enabled "NON_FREE"using(Stitcher stitcher =newStitcher())using(Emgu.CV.Features2D.AKAZE finder =newEmgu.CV.Features2D.AKAZE())using(Emgu.CV.Stitching.WarperCreator warper =newSphericalWarper()){stitcher.SetFeaturesFinder(finder);stitcher.SetWarper(warper);using(VectorOfMat vm =newVectorOfMat()){Mat result =newMat();vm.Push(sourceImages);Stopwatch watch = Stopwatch.StartNew();Stitcher.Status stitchStatus = stitcher.Stitch(vm, result);watch.Stop();if(stitchStatus == Stitcher.Status.Ok){result.Save(stitchedImagePath);Console.WriteLine(string.Format("Stitched in {0} milliseconds.", watch.ElapsedMilliseconds));}else{Console.WriteLine(string.Format("Stiching Error: {0}", stitchStatus));}}}}finally{foreach(Image<Bgr, Byte> img in sourceImages){img.Dispose();}}}}}