using MvCodeReaderSDKNet; using LB_VisionProcesses; using LB_VisionProcesses.Cameras; using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Reflection; namespace LB_VisionProcesses.Cameras { public class Total { public int iImageCount { get; set; } = 0; public int iScanCount { get; set; } = 0; public Total() { } public Total(int iImageCount, int iScanCount) { this.iImageCount = iImageCount; this.iScanCount = iScanCount; } public void Clear() { iImageCount = 0; iScanCount = 0; } } public interface ICamera : IDisposable { #region operate /// /// 获取相机SN枚举 /// /// List GetListEnum(); /// /// 初始化相机 /// /// /// bool InitDevice(string SN, object Handle); /// /// 注销相机 /// bool CloseDevice(); /// /// 软触发模式 启动相机 /// /// bool StartWith_SoftTriggerModel(); /// /// 硬触发模式 启动相机 /// /// /// bool StartWith_HardTriggerModel(TriggerSource hardtriggeritem = TriggerSource.Line0); /// /// 等待硬触发获取图像 /// /// /// /// bool GetImage(out Bitmap bitmap, int outtime = 3000); /// /// 软触发获取图像 /// /// /// /// bool GetImageWithSoftTrigger(out Bitmap bitmap, int outtime = 3000); /// /// 软触发 /// /// bool SoftTrigger(); #endregion #region SettingConfig /// /// 设置相机参数 /// /// void SetCamConfig(CameraConfig config); /// /// 获取相机参数 /// /// void GetCamConfig(out CameraConfig config); /// /// 设置触发模式及触发源 /// /// /// /// bool SetTriggerMode(TriggerMode mode, TriggerSource source = TriggerSource.Line0); /// /// 获取触发模式及触发源 /// /// /// /// bool GetTriggerMode(out TriggerMode mode, out TriggerSource source); /// /// 设置曝光时长 /// /// /// bool SetExpouseTime(double value); /// /// 获取曝光时长 /// /// /// bool GetExpouseTime(out double value); /// /// 设置硬触发极性 /// /// /// bool SetTriggerPolarity(TriggerPolarity polarity); /// /// 获取硬触发极性 /// /// /// bool GetTriggerPolarity(out TriggerPolarity polarity); /// /// 设置触发滤波时间 (us) /// /// /// bool SetTriggerFliter(double flitertime); /// /// 获取触发滤波时间 (us) /// /// /// bool GetTriggerFliter(out double flitertime); /// /// 设置触发延时 /// /// /// bool SetTriggerDelay(double delay); /// /// 获取触发延时 /// /// /// bool GetTriggerDelay(out double delay); /// /// 设置增益 /// /// /// bool SetGain(double gain); /// /// 获取增益值 /// /// /// bool GetGain(out double gain); /// /// 设置信号线模式 /// /// /// /// bool SetLineMode(IOLines line, LineMode mode); /// /// 设置信号线电平状态 /// /// /// /// bool SetLineStatus(IOLines line, LineStatus linestatus); /// /// 获取信号线电平状态 /// /// /// /// bool GetLineStatus(IOLines line, out LineStatus lineStatus); /// /// 自动白平衡 /// /// bool AutoBalanceWhite(); /// /// 开始采图 /// /// bool StartGrabbing(); /// /// 停止采图 /// /// bool StopGrabbing(); #endregion } public enum CameraBrand { /// /// 华睿工业相机 /// HRCamera, /// /// 兰宝工业相机 /// LBCamera, /// /// 海康工业相机 /// HikCamera, /// /// 海康读码相机 /// HikCodeReader, /// /// 迈德工业相机 /// MindCamera, /// /// 维视工业相机 /// MicroCamera, /// /// 本地相机 /// LocalCamera, /// /// 暂不支持 /// UNSUPPORTED } public enum IOLines { Line0, Line1, Line2, Line3, Line4, Line5 } public enum LineMode { Input, Output } public enum LineStatus { Hight, Low } public enum TriggerMode { Off, On } public enum TriggerPolarity { RisingEdge, FallingEdge, HighLevel, LowLevel } public enum TriggerSource { Software, Line0, Line1, Line2, Line3, Line4, Line5, None } public class HikCodeReaderEventArgs { public bool IsColor { get; set; } public ulong Width { get; set; } public ulong Height { get; set; } public IntPtr frameAddr { get; set; } public string SN { get; set; } public Bitmap Bitmap { get; set; } public Image Image { get; set; } public HikCodeReaderEventArgs.PixelType pixelType { get; set; } public MvCodeReader.MV_CODEREADER_RESULT_BCR_EX BCResult { get; set; } public HikCodeReaderEventArgs() { } public HikCodeReaderEventArgs(string sN, IntPtr frameAddr, ulong width, ulong height) { this.SN = sN; this.Width = width; this.Height = height; this.frameAddr = frameAddr; } public HikCodeReaderEventArgs( string sN, Bitmap bitmap, HikCodeReaderEventArgs.PixelType pixelType) { this.SN = sN; this.Bitmap = bitmap; this.pixelType = pixelType; } public HikCodeReaderEventArgs( string sN, Bitmap bitmap, HikCodeReaderEventArgs.PixelType pixelType, MvCodeReader.MV_CODEREADER_RESULT_BCR_EX bcResult, ulong width, ulong height) { this.SN = sN; this.Bitmap = bitmap; this.pixelType = pixelType; this.BCResult = bcResult; this.Width = width; this.Height = height; } public HikCodeReaderEventArgs( string sN, Image image, HikCodeReaderEventArgs.PixelType pixelType, MvCodeReader.MV_CODEREADER_RESULT_BCR_EX bcResult, ulong width, ulong height) { this.SN = sN; this.Image = image; if (this.Image == null) { Debug.WriteLine($"【{DateTime.Now:HH:mm:ss.fff}】图片为空!"); } this.pixelType = pixelType; this.BCResult = bcResult; this.Width = width; this.Height = height; } public enum PixelType { Mono8, Jpeg, } } public class CameraEventArgs { public string SN { get; set; } public Bitmap Bitmap { get; set; } public string[] arrResult; public CameraEventArgs() { } public CameraEventArgs(string sn, Bitmap bitmap, string[] arrResult = null) { this.SN = sn; this.Bitmap = bitmap; this.arrResult = arrResult; } } }