Emgucvopencv+C#例程集锦


C#是.net平台上的明星语言,可以很容易做出漂亮的界面。EmguCV是将opencv封装的一个.net库可以被VC++,VC#,VB.net调用。网上对于EmguCV的介绍很少,本人整理了一些资料Emgu和C#相结合的一些例子,对大家的学习一定会有帮助
资源截图
代码片段和文件信息
//----------------------------------------------------------------------------
//  Copyright (C) 2004-2018 by EMGU Corporation. All rights reserved.       
//----------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.Aruco;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using Emgu.CV.Util;

namespace Aruco
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();


            _detectorParameters = DetectorParameters.GetDefault();

            try
            {
                _capture = new VideoCapture();
                if (!_capture.IsOpened)
                {
                    _capture = null;
                    throw new NullReferenceException(“Unable to open video capture“);
                }
                else
                {
                    _capture.ImageGrabbed += Processframe;
                }
            }
            catch (NullReferenceException excpt)
            {
                MessageBox.Show(excpt.Message);
            }
            UpdateMessage(String.Empty);
        }

        private VideoCapture _capture = null;
        private bool _captureInProgress;
        private bool _useThisframe = false;

        int markersX = 4;
        int markersY = 4;
        int markersLength = 80;
        int markersSeparation = 30;

        private Dictionary _dict;

        private Dictionary ArucoDictionary
        {
            get
            {
                if (_dict == null)
                    _dict = new Dictionary(Dictionary.PredefinedDictionaryName.Dict4X4_100);
                return _dict;
            }

        }

        private GridBoard _gridBoard;
        private GridBoard ArucoBoard
        {
            get
            {
                if (_gridBoard == null)
                {
                    _gridBoard = new GridBoard(markersX markersY markersLength markersSeparation ArucoDictionary);
                }
                return _gridBoard;
            }
        }

        private void printArucoBoardButton_Click(object sender EventArgs e)
        {
            Size imageSize = new Size();

            int margins = markersSeparation;
            imageSize.Width = markersX * (markersLength + markersSeparation) - markersSeparation + 2 * margins;
            imageSize.Height = markersY * (markersLength + markersSeparation) - markersSeparation + 2 * margins;
            int borderBits = 1;

            Mat boardImage = new Mat();
            ArucoBoard.Draw(imageSize boardImage margins borderBits);
            bmIm = boardImage.Bitmap;
            PrintImage();

        }

        private void PrintImage()
        {
            PrintDocument pd = new PrintDocument();

            //pd.DefaultPageSettings.Margi

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

     文件        184  2018-07-11 21:37  Emgu.CV.ExampleArucoApp.config

     文件       4260  2018-07-11 21:37  Emgu.CV.ExampleArucoAruco.csproj

     文件       9580  2018-07-11 21:37  Emgu.CV.ExampleArucoMainForm.cs

     文件       4986  2018-07-11 21:37  Emgu.CV.ExampleArucoMainForm.Designer.cs

     文件       5698  2018-07-11 21:37  Emgu.CV.ExampleArucoMainForm.resx

     文件        483  2018-07-11 21:37  Emgu.CV.ExampleArucoProgram.cs

     文件       1386  2018-07-11 21:37  Emgu.CV.ExampleArucoPropertiesAssemblyInfo.cs

     文件       2653  2018-07-11 21:37  Emgu.CV.ExampleArucoPropertiesResources.Designer.cs

     文件       5496  2018-07-11 21:37  Emgu.CV.ExampleArucoPropertiesResources.resx

     文件       1036  2018-07-11 21:37  Emgu.CV.ExampleArucoPropertiesSettings.Designer.cs

     文件        242  2018-07-11 21:37  Emgu.CV.ExampleArucoPropertiesSettings.settings

     文件       2997  2018-07-11 21:37  Emgu.CV.ExampleCameraCaptureCameraCapture.cs

     文件       5029  2018-11-22 15:15  Emgu.CV.ExampleCameraCaptureCameraCapture.csproj

     文件      15900  2018-07-11 21:37  Emgu.CV.ExampleCameraCaptureCameraCapture.Designer.cs

     文件       5695  2018-07-11 21:37  Emgu.CV.ExampleCameraCaptureCameraCapture.resx

     文件       5632  2018-11-22 18:54  Emgu.CV.ExampleCameraCaptureCameraCapture.v11.suo

     文件        457  2018-11-22 15:12  Emgu.CV.ExampleCameraCaptureCommonAssemblyInfo.cs

     文件        180  2018-11-22 15:15  Emgu.CV.ExampleCameraCaptureobjDebugCameraCapture.CameraCapture.resources

     文件       1281  2018-11-22 18:54  Emgu.CV.ExampleCameraCaptureobjDebugCameraCapture.csproj.FileListAbsolute.txt

     文件        782  2018-11-22 15:14  Emgu.CV.ExampleCameraCaptureobjDebugCameraCapture.csproj.GenerateResource.Cache

     文件      19429  2018-11-22 14:57  Emgu.CV.ExampleCameraCaptureobjDebugDesignTimeResolveAssemblyReferences.cache

     文件       6970  2018-11-22 15:15  Emgu.CV.ExampleCameraCaptureobjDebugDesignTimeResolveAssemblyReferencesInput.cache

     文件      12800  2018-11-22 15:15  Emgu.CV.ExampleCameraCaptureobjDebugExample.CameraCapture.exe

     文件      19968  2018-11-22 15:15  Emgu.CV.ExampleCameraCaptureobjDebugExample.CameraCapture.pdb

     文件     331432  2018-01-14 01:32  Emgu.CV.ExampleCameraCaptureobjDebugx64concrt140.dll

     文件   31313920  2018-10-15 19:02  Emgu.CV.ExampleCameraCaptureobjDebugx64cvextern.dll

     文件    2429582  2018-10-15 19:02  Emgu.CV.ExampleCameraCaptureobjDebugx64cvextern.lib

     文件     641696  2018-01-14 01:32  Emgu.CV.ExampleCameraCaptureobjDebugx64msvcp140.dll

     文件   18054144  2018-10-15 18:27  Emgu.CV.ExampleCameraCaptureobjDebugx64opencv_ffmpeg343_64.dll

     文件      87728  2018-01-14 01:32  Emgu.CV.ExampleCameraCaptureobjDebugx64vcruntime140.dll

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

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)