• 大小: 2.04MB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2023-11-17
  • 语言: C#
  • 标签: basler  halcon  

资源简介

主要功能包括:单张采集、连续采集、停止采集、切换软硬触发模式,设置曝光、增益,加载、保存图片,采集图像计数、计时等。 支持多相机,多线程,稳定好用 自己引用对应版本的halcon即可,默认是halcon10,64位程序 PS:资源仅供交流

资源截图

代码片段和文件信息

/*
 * 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-12-03 16:20  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\
     目录           0  2018-11-20 09:35  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\
     目录           0  2018-11-20 09:35  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\.vs\
     目录           0  2018-11-20 09:35  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\.vs\PylonLiveViewer\
     目录           0  2018-11-20 09:35  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\.vs\PylonLiveViewer\v14\
     文件      146944  2018-12-25 15:44  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\.vs\PylonLiveViewer\v14\.suo
     目录           0  2018-11-20 15:13  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\
     文件       32038  2016-07-20 14:59  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\Basler.ico
     文件       33880  2018-11-20 11:32  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\BaslerCam.cs
     文件       34558  2017-12-12 10:44  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\Form1.Designer.cs
     文件       12093  2018-11-20 15:13  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\Form1.cs
     文件       55764  2018-11-13 17:17  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\Form1.resx
     文件         496  2017-08-12 09:29  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\Program.cs
     目录           0  2018-11-20 09:35  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\Properties\
     文件        1362  2017-08-12 09:29  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\Properties\AssemblyInfo.cs
     文件        2870  2017-11-24 14:03  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\Properties\Resources.Designer.cs
     文件        5612  2017-08-12 09:29  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\Properties\Resources.resx
     文件        1115  2017-11-24 14:03  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\Properties\Settings.Designer.cs
     文件         249  2017-08-12 09:29  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\Properties\Settings.settings
     文件        6456  2018-11-20 09:45  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\PylonLiveViewer.csproj
     文件         387  2018-11-13 17:09  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\PylonLiveViewer.csproj.user
     文件         144  2017-11-24 14:03  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\app.config
     目录           0  2018-11-20 09:35  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\bin\
     目录           0  2018-11-20 10:00  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\bin\Debug\
     文件      986056  2018-04-03 11:45  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\bin\Debug\Basler.Pylon.dll
     文件     2231283  2018-04-03 11:39  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\bin\Debug\Basler.Pylon.xml
     文件       68608  2018-11-28 16:04  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\bin\Debug\PylonLiveViewer.exe
     文件         144  2017-11-24 14:03  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\bin\Debug\PylonLiveViewer.exe.config
     文件       52736  2018-11-28 16:04  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\bin\Debug\PylonLiveViewer.pdb
     文件       22696  2018-12-25 10:27  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\bin\Debug\PylonLiveViewer.vshost.exe
     文件         144  2017-11-24 14:03  C#_x64_Pylon5_Halcon10_VS2010_2CCD_V3.5.0 - 副本\PylonLiveViewer\PylonLiveViewer\bin\Debug\PylonLiveViewer.vshost.exe.config
............此处省略64个文件信息

评论

共有 条评论