• 大小: 2.16M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2024-06-19
  • 语言: C#
  • 标签: BASLER  sdk  sd  图像  C#  

资源简介

C#利用baslerSDK实现相机采集图像

 采集图像,设置参数

资源截图

代码片段和文件信息

/*
 * Target:此Demo是基于Pylon5版本的开发库basler.pylon.dll所写,支持黑白/彩色的Gige/USB3.0相机。
 * Author:Jogan (MVLZ)
 * Update:2017.12.27
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Basler.Pylon;
using HalconDotNet;

namespace PylonLiveViewer
{
    public class BaslerCam
    {
        private Camera camera = null;
        private PixelDataConverter converter = new PixelDataConverter();
        private String strUserID = null;

        public long imageWidth = 0;         // 图像宽
        public long imageHeight = 0;        // 图像高
        public long minExposureTime = 0;    // 最小曝光时间
        public long maxExposureTime = 0;    // 最大曝光时间
        public long minGain = 0;            // 最小增益
        public long maxGain = 0;            // 最大增益

        private long grabTime = 0;          // 采集图像时间

        private Hobject hPylonImage = null;
        private IntPtr latestframeAddress = IntPtr.Zero;
        private Stopwatch stopWatch = new Stopwatch();

        /// 
        /// 计算采集图像时间自定义委托
        /// 

        /// 采集图像时间
        public delegate void delegateComputeGrabTime(long time);
        /// 
        /// 计算采集图像时间委托事件
        /// 

        public event delegateComputeGrabTime eventComputeGrabTime;

        /// 
        /// 图像处理自定义委托
        /// 

        /// halcon图像变量
        public delegate void delegateProcessHImage(Hobject hImage);  
        /// 
        /// 图像处理委托事件
        /// 

        public event delegateProcessHImage eventProcessImage;

        /// 
        /// if >= Sfnc2_0_0说明是USB3的相机
        /// 

        static Version Sfnc2_0_0 = new Version(2 0 0);


/******************    实例化相机    ******************/
        /// 
        /// 实例化第一个找到的相机
        /// 

        public BaslerCam()
        {
            try
            {
                camera = new Camera();
            }
            catch (Exception e)
            {
                ShowException(e);
            }
        }

        /// 
        /// 根据相机序列号实例化相机
        /// 

        /// 
        //public BaslerCam(string SN)
        //{
        //    camera = new Camera(SN);
        //}

        /// 
        /// 根据相机UserID实例化相机
        /// 

        /// 
        public BaslerCam(string UserID)
        {
            try
            {
                strUserID = UserID;     //掉线重连用

                // 枚举相机列表
                List allCameraInfos = CameraFinder.Enumerate();

                foreach (ICameraInfo cameraInfo in allCameraInfos)
    

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-11-20 09:35  采集\PylonLiveViewer\
     目录           0  2018-11-20 09:35  采集\PylonLiveViewer\.vs\
     目录           0  2021-12-01 10:45  采集\PylonLiveViewer\.vs\PylonLiveViewer\
     目录           0  2018-11-20 09:35  采集\PylonLiveViewer\.vs\PylonLiveViewer\v14\
     文件      146944  2018-12-25 15:44  采集\PylonLiveViewer\.vs\PylonLiveViewer\v14\.suo
     目录           0  2021-12-01 10:45  采集\PylonLiveViewer\.vs\PylonLiveViewer\v16\
     文件      141824  2021-12-01 10:52  采集\PylonLiveViewer\.vs\PylonLiveViewer\v16\.suo
     文件        1241  2017-08-12 10:04  采集\PylonLiveViewer\PylonLiveViewer.sln
     文件       38912  2017-12-27 17:41  采集\PylonLiveViewer\PylonLiveViewer.suo
     文件       72192  2018-10-19 09:18  采集\PylonLiveViewer\PylonLiveViewer.v11.suo
     文件       83456  2018-10-11 15:40  采集\PylonLiveViewer\PylonLiveViewer.v12.suo
     目录           0  2018-11-20 15:13  采集\PylonLiveViewer\PylonLiveViewer\
     文件         144  2017-11-24 14:03  采集\PylonLiveViewer\PylonLiveViewer\app.config
     文件       32038  2016-07-20 14:59  采集\PylonLiveViewer\PylonLiveViewer\Basler.ico
     文件       33880  2018-11-20 11:32  采集\PylonLiveViewer\PylonLiveViewer\BaslerCam.cs
     目录           0  2018-11-20 09:35  采集\PylonLiveViewer\PylonLiveViewer\bin\
     目录           0  2018-11-20 10:00  采集\PylonLiveViewer\PylonLiveViewer\bin\Debug\
     文件      986056  2018-04-03 11:45  采集\PylonLiveViewer\PylonLiveViewer\bin\Debug\Basler.Pylon.dll
     文件     2231283  2018-04-03 11:39  采集\PylonLiveViewer\PylonLiveViewer\bin\Debug\Basler.Pylon.xml
     文件     1413776  2017-05-25 20:27  采集\PylonLiveViewer\PylonLiveViewer\bin\Debug\halcondotnet.dll
     文件       68608  2018-11-28 16:04  采集\PylonLiveViewer\PylonLiveViewer\bin\Debug\PylonLiveViewer.exe
     文件         144  2017-11-24 14:03  采集\PylonLiveViewer\PylonLiveViewer\bin\Debug\PylonLiveViewer.exe.config
     文件       52736  2018-11-28 16:04  采集\PylonLiveViewer\PylonLiveViewer\bin\Debug\PylonLiveViewer.pdb
     文件       22696  2018-12-25 10:27  采集\PylonLiveViewer\PylonLiveViewer\bin\Debug\PylonLiveViewer.vshost.exe
     文件         144  2017-11-24 14:03  采集\PylonLiveViewer\PylonLiveViewer\bin\Debug\PylonLiveViewer.vshost.exe.config
     文件         490  2018-04-12 07:35  采集\PylonLiveViewer\PylonLiveViewer\bin\Debug\PylonLiveViewer.vshost.exe.manifest
     目录           0  2018-12-28 13:29  采集\PylonLiveViewer\PylonLiveViewer\bin\Release\
     目录           0  2018-11-20 09:35  采集\PylonLiveViewer\PylonLiveViewer\bin\x64\
     目录           0  2018-11-20 10:03  采集\PylonLiveViewer\PylonLiveViewer\bin\x64\Debug\
     文件      986056  2018-04-03 11:45  采集\PylonLiveViewer\PylonLiveViewer\bin\x64\Debug\Basler.Pylon.dll
     文件     1440400  2017-12-02 17:26  采集\PylonLiveViewer\PylonLiveViewer\bin\x64\Debug\halcondotnet.dll
............此处省略67个文件信息

评论

共有 条评论