private void button5_Click(object sender, EventArgs e) { string[] paths = Directory.GetFiles(Basepath); List <Mat> matlist = new List <Mat>(); for (int i = 0; i < paths.Length; i++) { var tempmat = new Mat(paths[i], ImreadModes.Color); matlist.Add(tempmat); } using (VectorOfMat vmsrc = new VectorOfMat(matlist.ToArray())) { //Image<Bgr, byte> res = new Image<Bgr, byte>(28090, 27390); Mat result = new Mat(); Stitcher stitcher = new Stitcher(false); Stitcher.Status stitchStatus = stitcher.Stitch(vmsrc, result); ImageViewer.Show(result); //result.Save(Basepath + "testresult.png"); } }
private void selectImagesButton_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.CheckFileExists = true; dlg.Multiselect = true; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { sourceImageDataGridView.Rows.Clear(); Image <Bgr, byte>[] sourceImages = new Image <Bgr, byte> [dlg.FileNames.Length]; for (int i = 0; i < sourceImages.Length; i++) { sourceImages[i] = new Image <Bgr, byte>(dlg.FileNames[i]); using (Image <Bgr, byte> thumbnail = sourceImages[i].Resize(200, 200, Emgu.CV.CvEnum.Inter.Cubic, true)) { DataGridViewRow row = sourceImageDataGridView.Rows[sourceImageDataGridView.Rows.Add()]; row.Cells["FileNameColumn"].Value = dlg.FileNames[i]; row.Cells["ThumbnailColumn"].Value = thumbnail.ToBitmap(); row.Height = 200; } } try { //only use GPU if you have build the native binary from code and enabled "NON_FREE" using (Stitcher stitcher = new Stitcher(false)) using (AKAZEFeaturesFinder finder = new AKAZEFeaturesFinder()) { stitcher.SetFeaturesFinder(finder); using (VectorOfMat vm = new VectorOfMat()) { Mat result = new Mat(); vm.Push(sourceImages); Stitcher.Status stitchStatus = stitcher.Stitch(vm, result); if (stitchStatus == Stitcher.Status.Ok) { resultImageBox.Image = result; } else { MessageBox.Show(this, String.Format("Stiching Error: {0}", stitchStatus)); resultImageBox.Image = null; } } } } finally { foreach (Image <Bgr, Byte> img in sourceImages) { img.Dispose(); } } } }
private void selectImagesButton_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.CheckFileExists = true; dlg.Multiselect = true; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { sourceImageDataGridView.Rows.Clear(); Image <Bgr, Byte>[] sourceImages = new Image <Bgr, byte> [dlg.FileNames.Length]; for (int i = 0; i < sourceImages.Length; i++) { sourceImages[i] = new Image <Bgr, byte>(dlg.FileNames[i]); using (Image <Bgr, byte> thumbnail = sourceImages[i].Resize(200, 200, Emgu.CV.CvEnum.Inter.Cubic, true)) { DataGridViewRow row = sourceImageDataGridView.Rows[sourceImageDataGridView.Rows.Add()]; row.Cells["FileNameColumn"].Value = dlg.FileNames[i]; row.Cells["ThumbnailColumn"].Value = thumbnail.ToBitmap(); row.Height = 200; } } try { //using (Stitcher stitcher = new Stitcher(true)) //CUDA bruteforce matcher seems to cause issue in this release, not using CUDA for matching for this reason using (Stitcher stitcher = new Stitcher(false)) { using (VectorOfMat vm = new VectorOfMat()) { Mat result = new Mat(); vm.Push(sourceImages); Stitcher.Status stitchStatus = stitcher.Stitch(vm, result); if (stitchStatus == Stitcher.Status.Ok) { resultImageBox.Image = result; } else { MessageBox.Show(this, String.Format("Stiching Error: {0}", stitchStatus)); resultImageBox.Image = null; } } } } finally { foreach (Image <Bgr, Byte> img in sourceImages) { img.Dispose(); } } } }
private void button5_Click(object sender, EventArgs e) { Stitcher _sticher = new Stitcher(Stitcher.Mode.Scans); //创建一个 Sticher 类。 Mat result_image = new Mat(); //创建 Mat 存储输出全景图 VectorOfMat sti_image = new VectorOfMat(); //创建 VectorOfMat 类型, 输入图像拼接数组 // 添加图像到 sti_image 中, 不按照循序进行添加, 说明拼接图像与顺序无关*// sti_image.Push(image1); sti_image.Push(image2); sti_image.Push(image3); sti_image.Push(image4); Stitcher.Status status = _sticher.Stitch(sti_image, result_image);//进行图像拼接, 返回 bool 类型, 是否拼接成功。 if (status == Stitcher.Status.Ok) { imageBox5.Image = result_image;//显示图像。 } else { MessageBox.Show("拼接失败", "提示"); } }
private void open_Click(object sender, EventArgs e) { //MessageBox.Show(Convert.ToString(treshold)); if (KazeRadio.Checked) { descriptorTipus = AKAZE.DescriptorType.Kaze; } else if (KazeUpRadio.Checked) { descriptorTipus = AKAZE.DescriptorType.KazeUpright; } else if (MldbRadio.Checked) { descriptorTipus = AKAZE.DescriptorType.Mldb; } else if (MldbUpRadio.Checked) { descriptorTipus = AKAZE.DescriptorType.MldbUpright; } else { MldbRadio.Checked = true; } if (Channel1Radio.Checked) { channelNumber = 1; } else if (Channel2Radio.Checked) { channelNumber = 2; } else if (Channerl3Radio.Checked) { channelNumber = 3; } else { Channerl3Radio.Checked = true; } if (CharbonnierRadio.Checked) { difuzivitasi = KAZE.Diffusivity.Charbonnier; } else if (PmG1Radio.Checked) { difuzivitasi = KAZE.Diffusivity.PmG1; } else if (PmG2Radio.Checked) { difuzivitasi = KAZE.Diffusivity.PmG2; } else if (WeickerRadio.Checked) { difuzivitasi = KAZE.Diffusivity.Weickert; } else { PmG1Radio.Checked = true; } OpenFileDialog dlg = new OpenFileDialog(); dlg.Multiselect = true; dlg.Filter = "jpg files (*.jpg)|*.jpg"; if (dlg.ShowDialog() == DialogResult.OK) { dataGridViewKepek.Rows.Clear(); Image <Bgr, byte>[] forrasKepek = new Image <Bgr, byte> [dlg.FileNames.Length]; for (int i = 0; i < forrasKepek.Length; i++) { forrasKepek[i] = new Image <Bgr, byte>(dlg.FileNames[i]); using (Image <Bgr, byte> miniPicture = forrasKepek[i].Resize(200, 200, Emgu.CV.CvEnum.Inter.Cubic, true)) { DataGridViewRow sor = dataGridViewKepek.Rows[dataGridViewKepek.Rows.Add()]; sor.Cells["FileName"].Value = dlg.FileNames[i]; sor.Cells["View"].Value = miniPicture.ToBitmap(); sor.Height = 200; } } miniPicture = null; try { //0 - Panormáma; 1 - Szekkenlés //true - Try GPU; false - No using (Stitcher varras = new Stitcher(0, true)) { using (AKAZEFeaturesFinder kereso = new AKAZEFeaturesFinder(descriptorTipus, 0, channelNumber, treshold, 4, 4, difuzivitasi)) { varras.SetFeaturesFinder(kereso); using (VectorOfMat vm = new VectorOfMat()) { Mat result = new Mat(); vm.Push(forrasKepek); Stitcher.Status stitchStatus = varras.Stitch(vm, result); if (stitchStatus == Stitcher.Status.Ok) { resultImage.Image = result; forrasKepek = null; } else { MessageBox.Show(this, String.Format("Stiching Error: {0}", stitchStatus)); resultImage.Image = null; } } } } } catch (Exception ex) { } } }