• 大小: 16.2MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-07-20
  • 语言: C#
  • 标签: EmguCV  C#  

资源简介

C# 使用EmguCV 拼接图片(用于多张照片合成全景图) ,一个简单的应用程序,选择几张图片,拼接图片,并保存

资源截图

代码片段和文件信息

using System;
using System.Windows;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using Emgu.CV.CvEnum;
using Emgu.CV;
using Emgu.CV.Structure;
using Emgu.CV.Stitching;
using Emgu.CV.Util;
using System.IO;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            OpenFileDialog open = new OpenFileDialog();
            open.CheckFileExists = true;
            open.Multiselect = true;
            open.Filter = “打开图片|*.jpg“;
            open.ShowDialog();


            List listmat = new List();
            if (open.FileNames.Count() > 0)
            {
                for (int i = 0; i < open.FileNames.Count(); i++)
                {
                    Image a = new Image(open.FileNames[i]);
                    listmat.Add(a.Mat);
                }

                Stitcher stitcher = new Stitcher(false);
                Mat outimg = new Mat();

                stitcher.Stitch(new VectorOfMat(listmat.ToArray()) outimg);

                outimg.Bitmap.Save(@“F:\3.jpg“);
                 imageBox1.Image = outimg.Bitmap;           
            }


        }
        public byte[] GetByteImage(Image img)
        {
            byte[] bt = null;
            if (!img.Equals(null))
            {
                using (MemoryStream mostream = new MemoryStream())
                {
                    Bitmap bmp = new Bitmap(img);
                    bmp.Save(mostream System.Drawing.Imaging.ImageFormat.Bmp);//将图像以指定的格式存入缓存内存流
                    bt = new byte[mostream.Length];
                    mostream.Position = 0;//设置留的初始位置
                    mostream.Read(bt 0 Convert.ToInt32(bt.Length));
                }
            }
            return bt;
        }

        protected byte[] GetFileData(string fileUrl)
        {
            FileStream fs = new FileStream(fileUrl FileMode.Open FileAccess.Read);
            try
            {
                byte[] buffur = new byte[fs.Length];
                fs.Read(buffur 0 (int)fs.Length);

                return buffur;
            }
            catch (Exception ex)
            {
                //MessageBoxHelper.ShowPrompt(ex.Message);
                return null;
            }
            finally
            {
                if (fs != null)
                {

                    //关闭资源
                    fs.Close();
                }
            }
        }

        private bool writeFile(byte[] pReadByte string fileName)

        {
            FileStream pFileStream = null;
            try

            {
                pFileStream = new FileStream(fileName FileMode.OpenOrCreate);
                pFileStream.Write(pRea

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     50688  2017-10-25 17:36  WindowsFormsApp1\.vs\WindowsFormsApp1\v15\.suo

     文件        184  2017-10-16 18:45  WindowsFormsApp1\WindowsFormsApp1\App.config

     文件     109215  2004-10-21 17:25  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\1.jpg

     文件     118280  2004-10-21 17:25  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\2.jpg

     文件     133387  2004-10-21 17:25  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\3.jpg

     文件      70144  2015-06-30 05:23  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\Emgu.CV.Cuda.dll

     文件     144172  2015-06-30 05:22  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\Emgu.CV.Cuda.xml

     文件       8192  2015-06-24 03:20  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\Emgu.CV.DebuggerVisualizers.VS2010.dll

     文件       8192  2015-06-24 03:20  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\Emgu.CV.DebuggerVisualizers.VS2012.dll

     文件       8192  2015-06-24 03:20  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\Emgu.CV.DebuggerVisualizers.VS2015.dll

     文件     382464  2015-06-30 05:22  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\Emgu.CV.dll

     文件      29184  2015-06-30 05:22  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\Emgu.CV.ML.dll

     文件      57030  2015-06-30 05:22  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\Emgu.CV.ML.xml

     文件       7680  2015-06-30 05:22  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\Emgu.CV.Shape.dll

     文件       8021  2015-06-30 05:22  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\Emgu.CV.Shape.xml

     文件       6144  2015-06-30 05:23  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\Emgu.CV.Stitching.dll

     文件       6144  2015-06-30 05:23  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\Emgu.CV.Superres.dll

     文件       2913  2015-06-30 05:23  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\Emgu.CV.Superres.xml

     文件      29696  2015-06-30 05:23  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\Emgu.CV.UI.GL.dll

     文件       2242  2015-06-20 05:20  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\Emgu.CV.UI.GL.xml

     文件      19456  2015-06-30 05:22  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\Emgu.Util.dll

     文件       9728  2017-10-25 17:25  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\WindowsFormsApp1.exe

     文件       1209  2017-10-25 17:25  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\WindowsFormsApp1.exe.config

     文件      22016  2017-10-25 17:25  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\WindowsFormsApp1.pdb

     文件   13839360  2015-06-29 23:40  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\x64\cvextern.dll

     文件    1498624  2015-06-29 23:40  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\x64\cvextern_test.exe

     文件     660128  2013-10-05 12:58  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\x64\msvcp120.dll

     文件     963232  2013-10-05 12:58  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\x64\msvcr120.dll

     文件    9720042  2014-07-24 21:56  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\x64\opencv_ffmpeg300_64.dll

     文件   10999808  2015-06-24 02:51  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\x86\cvextern.dll

............此处省略45个文件信息

评论

共有 条评论