资源简介

基于OpenCvSharp实现的,读取摄像头,实现多张图像拼接功能,vs2015

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenCvSharp;
namespace MediaLib
{
    public class Stitcher
    {
        #region OpencvSURF
        public bool OpencvSURF(List picNames int IsSURF string result_name out string msg)
        {
            msg = ““;
            if (picNames == null || picNames.Count < 2)
            {
                msg = “ 拼接图像数量不能少于2“;
                return false;
            }
            if (picNames.Count > 2)
            {
                var tempfile = “tempfile1.jpg“;
                var ret = OpencvSURF(picNames[0] picNames[1] IsSURF tempfile out msg);
                if (ret)
                {
                    for (int i = 2; i < picNames.Count; i++)
                    {
                        if (i + 1 == picNames.Count)
                            tempfile = result_name;
                        else
                            tempfile = “tempfile“ + i + “.jpg“;
                        ret = OpencvSURF(“tempfile“ + (i - 1) + “.jpg“ picNames[i] IsSURF tempfile out msg);
                        if (!ret) return ret;
                    }
                }
                return ret;
            }
            else
            {
                return OpencvSURF(picNames[0] picNames[1] IsSURF result_name out msg);
            }
        }
        public bool OpencvSURF(string pic1Name string pic2Name int IsSURF string result_name out string msg)
        {
            msg = ““;
            try
            {
                Mat image01 = OpenCvSharp.Cv2.ImRead(pic2Name);    //右图
                Mat image02 = OpenCvSharp.Cv2.ImRead(pic1Name);    //左图
                if (image01.Empty() || image02.Empty())
                {
                    msg = “ --(!) Error reading images “;
                    return false;
                }
                /*imshow(“p2“ image01);
                imshow(“p1“ image02);*/

                //灰度图转换  
                Mat image1 = new Mat() image2 = new Mat();
                OpenCvSharp.Cv2.CvtColor(image01 image1 (ColorConversionCodes)6);
                OpenCvSharp.Cv2.CvtColor(image02 image2 (ColorConversionCodes)6);

                //提取特征点    
                Feature2D Detector;
                if (IsSURF == 1)
                    Detector = OpenCvSharp.XFeatures2D.SURF.Create(image01.Step());
                else if (IsSURF == 2)
                    Detector = OpenCvSharp.XFeatures2D.SIFT.Create((int)image01.Step());
                else if (IsSURF == 3)
                    Detector = OpenCvSharp.ORB.Create((int)image01.Step());
                else
                    Detector = OpenCvSharp.XFeatures2D.SURF.Create(image01.Step());

                KeyPoint[] keyPoint1 keyPoint2;
                // Detector.Detect(image1 keyPoint1);
                // Detector.Detect(image2 keyPoint2);

                //特征点描述,

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

     文件       1498  2018-08-04 12:15  OpenCvSharp_FD_Sol.sln

     文件      17920  2013-07-17 23:15  MediaLib\bin\Debug\AForge.dll

     文件     262656  2013-07-17 23:19  MediaLib\bin\Debug\AForge.Imaging.dll

     文件     944046  2013-07-17 23:19  MediaLib\bin\Debug\AForge.Imaging.xml

     文件      61440  2013-07-17 23:20  MediaLib\bin\Debug\AForge.Video.DirectShow.dll

     文件     195287  2013-07-17 23:20  MediaLib\bin\Debug\AForge.Video.DirectShow.xml

     文件      20992  2013-07-17 23:20  MediaLib\bin\Debug\AForge.Video.dll

     文件      53275  2013-07-17 23:20  MediaLib\bin\Debug\AForge.Video.xml

     文件      78375  2013-07-17 23:15  MediaLib\bin\Debug\AForge.xml

     文件      41984  2018-08-07 14:43  MediaLib\bin\Debug\MediaLib.dll

     文件     101888  2018-08-07 14:43  MediaLib\bin\Debug\MediaLib.pdb

     文件     768000  2018-03-18 19:23  MediaLib\bin\Debug\OpenCvSharp.dll

     文件      25088  2018-03-18 19:23  MediaLib\bin\Debug\OpenCvSharp.Extensions.dll

     文件   50449408  2018-08-04 12:10  MediaLib\bin\Debug\OpenCvSharpExtern.dll

     文件      17920  2013-07-17 23:15  MediaLib\bin\Release\AForge.dll

     文件     262656  2013-07-17 23:19  MediaLib\bin\Release\AForge.Imaging.dll

     文件     944046  2013-07-17 23:19  MediaLib\bin\Release\AForge.Imaging.xml

     文件      61440  2013-07-17 23:20  MediaLib\bin\Release\AForge.Video.DirectShow.dll

     文件     195287  2013-07-17 23:20  MediaLib\bin\Release\AForge.Video.DirectShow.xml

     文件      20992  2013-07-17 23:20  MediaLib\bin\Release\AForge.Video.dll

     文件      53275  2013-07-17 23:20  MediaLib\bin\Release\AForge.Video.xml

     文件      78375  2013-07-17 23:15  MediaLib\bin\Release\AForge.xml

     文件      37888  2018-08-06 17:04  MediaLib\bin\Release\MediaLib.dll

     文件      89600  2018-08-06 17:04  MediaLib\bin\Release\MediaLib.pdb

     文件     768000  2018-03-18 19:23  MediaLib\bin\Release\OpenCvSharp.dll

     文件      25088  2018-03-18 19:23  MediaLib\bin\Release\OpenCvSharp.Extensions.dll

     文件   50449408  2018-08-04 12:10  MediaLib\bin\Release\OpenCvSharpExtern.dll

     文件      23124  2018-08-04 12:52  MediaLib\Common\BinaryUtil.cs

     文件      30255  2018-08-04 18:22  MediaLib\Common\Converts.cs

     文件       4281  2018-08-04 14:23  MediaLib\Common\IVideoSource.cs

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

评论

共有 条评论