/// <summary> /// Compute the panoramic images given the images /// </summary> /// <param name="images">The input images</param> /// <returns>The panoramic image</returns> public Image <Bgr, Byte> Stitch(Image <Bgr, Byte>[] images) { IntPtr[] ptrs = new IntPtr[images.Length]; for (int i = 0; i < images.Length; ++i) { ptrs[i] = images[i].Ptr; } GCHandle handle = GCHandle.Alloc(ptrs, GCHandleType.Pinned); IntPtr resultIplImage = StitchingInvoke.CvStitcherStitch(_ptr, handle.AddrOfPinnedObject(), images.Length); handle.Free(); if (resultIplImage == IntPtr.Zero) { throw new ArgumentException("Requires more images"); } MIplImage tmp = (MIplImage)Marshal.PtrToStructure(resultIplImage, typeof(MIplImage)); Image <Bgr, Byte> result = new Image <Bgr, byte>(tmp.width, tmp.height); CvInvoke.cvCopy(resultIplImage, result, IntPtr.Zero); CvInvoke.cvReleaseImage(ref resultIplImage); return(result); }
/// <summary> /// Compute the panoramic images given the images /// </summary> /// <param name="images">The input images. This can be, for example, a VectorOfMat</param> /// <param name="pano">The panoramic image</param> /// <returns>true if successful</returns> public bool Stitch(IInputArray images, IOutputArray pano) { using (InputArray iaImages = images.GetInputArray()) using (OutputArray oaPano = pano.GetOutputArray()) return(StitchingInvoke.CvStitcherStitch(_ptr, iaImages, oaPano)); }