提交
This commit is contained in:
300
DH.Commons/Base/CameraBase.cs
Normal file
300
DH.Commons/Base/CameraBase.cs
Normal file
@ -0,0 +1,300 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Imaging;
|
||||
using AntdUI;
|
||||
using OpenCvSharp;
|
||||
|
||||
namespace DH.Commons.Base
|
||||
{
|
||||
public class CameraBase : NotifyProperty
|
||||
{
|
||||
// 私有字段 + 带通知的属性(与DetectionLabel风格一致)
|
||||
private bool _isEnabled = false;
|
||||
private bool _isContinueMode = false;
|
||||
private bool _isSavePicEnabled = false;
|
||||
private string _imageSaveDirectory;
|
||||
private ImageFormat _imageFormat = ImageFormat.Jpeg;
|
||||
private bool _isHardwareTrigger = false;
|
||||
private string _serialNumber = string.Empty;
|
||||
private string _cameraName = string.Empty;
|
||||
private string _cameraIP = string.Empty;
|
||||
private string _computerIP = string.Empty;
|
||||
private bool _isDirectHardwareTrigger = false;
|
||||
private float _gain = -1;
|
||||
private float _rotateImage = 0;
|
||||
private float _exposure = 200;
|
||||
private float _triggerDelay = 0;
|
||||
private decimal _roiX = 0;
|
||||
private decimal _roiY = 0;
|
||||
private decimal _roiW = 0;
|
||||
private decimal _roiH = 0;
|
||||
private int _lineDebouncerTime = 0;
|
||||
|
||||
public volatile int SnapshotCount = 0;
|
||||
|
||||
[Category("采图模式")]
|
||||
[DisplayName("连续模式")]
|
||||
[Description("是否连续模式。true:连续模式采图;false:触发模式采图")]
|
||||
public bool IsContinueMode
|
||||
{
|
||||
get => _isContinueMode;
|
||||
set
|
||||
{
|
||||
if (_isContinueMode == value) return;
|
||||
_isContinueMode = value;
|
||||
OnPropertyChanged(nameof(IsContinueMode));
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool IsEnabled
|
||||
{
|
||||
get => _isEnabled;
|
||||
set
|
||||
{
|
||||
if (_isEnabled == value) return;
|
||||
_isEnabled = value;
|
||||
OnPropertyChanged(nameof(IsEnabled));
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool IsSavePicEnabled
|
||||
{
|
||||
get => _isSavePicEnabled;
|
||||
set
|
||||
{
|
||||
if (_isSavePicEnabled == value) return;
|
||||
_isSavePicEnabled = value;
|
||||
OnPropertyChanged(nameof(IsSavePicEnabled));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("图片保存")]
|
||||
[DisplayName("图片保存文件夹")]
|
||||
[Description("图片保存文件夹")]
|
||||
public virtual string ImageSaveDirectory
|
||||
{
|
||||
get => _imageSaveDirectory;
|
||||
set
|
||||
{
|
||||
if (_imageSaveDirectory == value) return;
|
||||
_imageSaveDirectory = value;
|
||||
OnPropertyChanged(nameof(ImageSaveDirectory));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("图片保存")]
|
||||
[DisplayName("图片保存格式")]
|
||||
[Description("图片保存格式")]
|
||||
public ImageFormat ImageFormat
|
||||
{
|
||||
get => _imageFormat;
|
||||
set
|
||||
{
|
||||
if (_imageFormat == value) return;
|
||||
_imageFormat = value;
|
||||
OnPropertyChanged(nameof(ImageFormat));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("采图模式")]
|
||||
[DisplayName("硬触发")]
|
||||
[Description("是否硬触发模式。true:硬触发;false:软触发")]
|
||||
public bool IsHardwareTrigger
|
||||
{
|
||||
get => _isHardwareTrigger;
|
||||
set
|
||||
{
|
||||
if (_isHardwareTrigger == value) return;
|
||||
_isHardwareTrigger = value;
|
||||
OnPropertyChanged(nameof(IsHardwareTrigger));
|
||||
}
|
||||
}
|
||||
|
||||
public string SerialNumber
|
||||
{
|
||||
get => _serialNumber;
|
||||
set
|
||||
{
|
||||
if (_serialNumber == value) return;
|
||||
_serialNumber = value;
|
||||
OnPropertyChanged(nameof(SerialNumber));
|
||||
}
|
||||
}
|
||||
|
||||
public string CameraName
|
||||
{
|
||||
get => _cameraName;
|
||||
set
|
||||
{
|
||||
if (_cameraName == value) return;
|
||||
_cameraName = value;
|
||||
OnPropertyChanged(nameof(CameraName));
|
||||
}
|
||||
}
|
||||
|
||||
public string CameraIP
|
||||
{
|
||||
get => _cameraIP;
|
||||
set
|
||||
{
|
||||
if (_cameraIP == value) return;
|
||||
_cameraIP = value;
|
||||
OnPropertyChanged(nameof(CameraIP));
|
||||
}
|
||||
}
|
||||
|
||||
public string ComputerIP
|
||||
{
|
||||
get => _computerIP;
|
||||
set
|
||||
{
|
||||
if (_computerIP == value) return;
|
||||
_computerIP = value;
|
||||
OnPropertyChanged(nameof(ComputerIP));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("采图模式")]
|
||||
[DisplayName("是否传感器直接硬触发")]
|
||||
[Description("是否传感器直接硬触发。true:传感器硬触发,不通过软件触发;false:通过软件触发IO 的硬触发模式")]
|
||||
public bool IsDirectHardwareTrigger
|
||||
{
|
||||
get => _isDirectHardwareTrigger;
|
||||
set
|
||||
{
|
||||
if (_isDirectHardwareTrigger == value) return;
|
||||
_isDirectHardwareTrigger = value;
|
||||
OnPropertyChanged(nameof(IsDirectHardwareTrigger));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("相机设置")]
|
||||
[DisplayName("增益")]
|
||||
[Description("Gain:增益,-1:不设置,不同型号相机的增益,请参考mvs")]
|
||||
public float Gain
|
||||
{
|
||||
get => _gain;
|
||||
set
|
||||
{
|
||||
if (_gain.Equals(value)) return;
|
||||
_gain = value;
|
||||
OnPropertyChanged(nameof(Gain));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("图像旋转")]
|
||||
[DisplayName("默认旋转")]
|
||||
[Description("默认旋转,相机开启后默认不旋转")]
|
||||
public virtual float RotateImage
|
||||
{
|
||||
get => _rotateImage;
|
||||
set
|
||||
{
|
||||
if (_rotateImage.Equals(value)) return;
|
||||
_rotateImage = value;
|
||||
OnPropertyChanged(nameof(RotateImage));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("取像配置")]
|
||||
[DisplayName("曝光")]
|
||||
[Description("曝光")]
|
||||
public virtual float Exposure
|
||||
{
|
||||
get => _exposure;
|
||||
set
|
||||
{
|
||||
if (_exposure.Equals(value)) return;
|
||||
_exposure = value;
|
||||
OnPropertyChanged(nameof(Exposure));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("相机设置")]
|
||||
[DisplayName("硬触发后的延迟")]
|
||||
[Description("TriggerDelay:硬触发后的延迟,单位:us 微秒")]
|
||||
public float TriggerDelay
|
||||
{
|
||||
get => _triggerDelay;
|
||||
set
|
||||
{
|
||||
if (_triggerDelay.Equals(value)) return;
|
||||
_triggerDelay = value;
|
||||
OnPropertyChanged(nameof(TriggerDelay));
|
||||
}
|
||||
}
|
||||
|
||||
public decimal ROIX
|
||||
{
|
||||
get => _roiX;
|
||||
set
|
||||
{
|
||||
if (_roiX == value) return;
|
||||
_roiX = value;
|
||||
OnPropertyChanged(nameof(ROIX));
|
||||
}
|
||||
}
|
||||
|
||||
public decimal ROIY
|
||||
{
|
||||
get => _roiY;
|
||||
set
|
||||
{
|
||||
if (_roiY == value) return;
|
||||
_roiY = value;
|
||||
OnPropertyChanged(nameof(ROIY));
|
||||
}
|
||||
}
|
||||
|
||||
public decimal ROIW
|
||||
{
|
||||
get => _roiW;
|
||||
set
|
||||
{
|
||||
if (_roiW == value) return;
|
||||
_roiW = value;
|
||||
OnPropertyChanged(nameof(ROIW));
|
||||
}
|
||||
}
|
||||
|
||||
public decimal ROIH
|
||||
{
|
||||
get => _roiH;
|
||||
set
|
||||
{
|
||||
if (_roiH == value) return;
|
||||
_roiH = value;
|
||||
OnPropertyChanged(nameof(ROIH));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("相机设置")]
|
||||
[DisplayName("滤波时间")]
|
||||
[Description("LineDebouncerTime:I/O去抖时间 单位:us")]
|
||||
public int LineDebouncerTime
|
||||
{
|
||||
get => _lineDebouncerTime;
|
||||
set
|
||||
{
|
||||
if (_lineDebouncerTime == value) return;
|
||||
_lineDebouncerTime = value;
|
||||
OnPropertyChanged(nameof(LineDebouncerTime));
|
||||
}
|
||||
}
|
||||
|
||||
// 其他方法保持原有逻辑
|
||||
public Action<DateTime, CameraBase, Mat> OnHImageOutput { get; set; }
|
||||
|
||||
public virtual bool CameraConnect() { return false; }
|
||||
|
||||
public virtual bool CameraDisConnect() { return false; }
|
||||
|
||||
public virtual void SetExposure(int exposureTime, string cameraName) { }
|
||||
|
||||
public virtual void SetGain(int gain, string cameraName) { }
|
||||
|
||||
internal virtual void SetAcquisitionMode(int mode) { }
|
||||
|
||||
internal virtual void SetAcqRegion(int offsetV, int offsetH, int imageH, int imageW, string cameraName) { }
|
||||
}
|
||||
}
|
1435
DH.Commons/Base/DetectionConfig.cs
Normal file
1435
DH.Commons/Base/DetectionConfig.cs
Normal file
File diff suppressed because it is too large
Load Diff
408
DH.Commons/Base/PLCBase.cs
Normal file
408
DH.Commons/Base/PLCBase.cs
Normal file
@ -0,0 +1,408 @@
|
||||
using System.ComponentModel;
|
||||
using System.IO.Ports;
|
||||
using System.Text.Json.Serialization;
|
||||
using AntdUI;
|
||||
using DH.Commons.Enums; // 请确保此命名空间包含EnumPLCType
|
||||
|
||||
namespace DH.Commons.Base
|
||||
{
|
||||
public class PLCBase : NotifyProperty
|
||||
{
|
||||
// 私有字段
|
||||
private bool _enable;
|
||||
private bool _connected;
|
||||
private string _plcName;
|
||||
private EnumPLCType _plcType;
|
||||
private string _com = "COM1";
|
||||
private int _baudRate = 9600;
|
||||
private int _dataBit = 8;
|
||||
private StopBits _stopBit = StopBits.One;
|
||||
private Parity _parity = Parity.None;
|
||||
private string _ip = "192.168.6.6";
|
||||
private int _port = 502;
|
||||
private AntList<PLCItem> _PLCItemList = new AntList<PLCItem>();
|
||||
[Category("设备配置")]
|
||||
[DisplayName("是否启用")]
|
||||
[Description("是否启用")]
|
||||
public bool Enable
|
||||
{
|
||||
get => _enable;
|
||||
set
|
||||
{
|
||||
if (_enable == value) return;
|
||||
_enable = value;
|
||||
OnPropertyChanged(nameof(Enable));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Category("状态监控")]
|
||||
[DisplayName("连接状态")]
|
||||
[Description("PLC连接状态")]
|
||||
public bool Connected
|
||||
{
|
||||
get => _connected;
|
||||
set
|
||||
{
|
||||
if (_connected == value) return;
|
||||
_connected = value;
|
||||
OnPropertyChanged(nameof(Connected));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("设备配置")]
|
||||
[DisplayName("PLC名称")]
|
||||
[Description("PLC设备名称")]
|
||||
public string PLCName
|
||||
{
|
||||
get => _plcName;
|
||||
set
|
||||
{
|
||||
if (_plcName == value) return;
|
||||
_plcName = value;
|
||||
OnPropertyChanged(nameof(PLCName));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("设备配置")]
|
||||
[DisplayName("PLC类型")]
|
||||
[Description("PLC通信协议类型")]
|
||||
public EnumPLCType PLCType
|
||||
{
|
||||
get => _plcType;
|
||||
set
|
||||
{
|
||||
if (_plcType == value) return;
|
||||
_plcType = value;
|
||||
OnPropertyChanged(nameof(PLCType));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("串口配置")]
|
||||
[DisplayName("COM端口")]
|
||||
[Description("串口号,如COM1")]
|
||||
public string COM
|
||||
{
|
||||
get => _com;
|
||||
set
|
||||
{
|
||||
if (_com == value) return;
|
||||
_com = value;
|
||||
OnPropertyChanged(nameof(COM));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("串口配置")]
|
||||
[DisplayName("波特率")]
|
||||
[Description("串口通信波特率")]
|
||||
public int BaudRate
|
||||
{
|
||||
get => _baudRate;
|
||||
set
|
||||
{
|
||||
if (_baudRate == value) return;
|
||||
_baudRate = value;
|
||||
OnPropertyChanged(nameof(BaudRate));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("串口配置")]
|
||||
[DisplayName("数据位")]
|
||||
[Description("数据位长度(5/6/7/8)")]
|
||||
public int DataBit
|
||||
{
|
||||
get => _dataBit;
|
||||
set
|
||||
{
|
||||
if (_dataBit == value) return;
|
||||
_dataBit = value;
|
||||
OnPropertyChanged(nameof(DataBit));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("串口配置")]
|
||||
[DisplayName("停止位")]
|
||||
[Description("停止位设置")]
|
||||
public StopBits StopBit
|
||||
{
|
||||
get => _stopBit;
|
||||
set
|
||||
{
|
||||
if (_stopBit == value) return;
|
||||
_stopBit = value;
|
||||
OnPropertyChanged(nameof(StopBit));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("串口配置")]
|
||||
[DisplayName("校验位")]
|
||||
[Description("奇偶校验方式")]
|
||||
public Parity Parity
|
||||
{
|
||||
get => _parity;
|
||||
set
|
||||
{
|
||||
if (_parity == value) return;
|
||||
_parity = value;
|
||||
OnPropertyChanged(nameof(Parity));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("网络配置")]
|
||||
[DisplayName("IP地址")]
|
||||
[Description("PLC网络地址")]
|
||||
public string IP
|
||||
{
|
||||
get => _ip;
|
||||
set
|
||||
{
|
||||
if (_ip == value) return;
|
||||
_ip = value;
|
||||
OnPropertyChanged(nameof(IP));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("网络配置")]
|
||||
[DisplayName("端口号")]
|
||||
[Description("网络通信端口")]
|
||||
public int Port
|
||||
{
|
||||
get => _port;
|
||||
set
|
||||
{
|
||||
if (_port == value) return;
|
||||
_port = value;
|
||||
OnPropertyChanged(nameof(Port));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("点位配置")]
|
||||
[DisplayName("点位配置")]
|
||||
[Description("点位配置")]
|
||||
public AntList<PLCItem> PLCItemList
|
||||
{
|
||||
get => _PLCItemList;
|
||||
set
|
||||
{
|
||||
if (_PLCItemList == value) return;
|
||||
_PLCItemList = value;
|
||||
OnPropertyChanged(nameof(PLCItemList));
|
||||
}
|
||||
}
|
||||
public virtual bool PLCConnect()
|
||||
{
|
||||
Connected = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual bool PLCDisConnect()
|
||||
{
|
||||
Connected = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public virtual ushort ReadShort(string address) { return 0; }
|
||||
public virtual int ReadInt(string address) { return 0; }
|
||||
public virtual float ReadFloat(string address) { return 0; }
|
||||
public virtual bool ReadBool(string address) { return false; }
|
||||
public virtual bool WriteShort(string address, short value, bool waitForReply = true) { return false; }
|
||||
public virtual bool WriteInt(string address, int value, bool waitForReply = true) { return false; }
|
||||
public virtual bool WriteDInt(string address, int value, bool waitForReply = true) { return false; }
|
||||
public virtual bool WriteFloat(string address, float value, bool waitForReply = true) { return false; }
|
||||
public virtual bool WriteBool(string address, bool value, bool waitForReply = true) { return false; }
|
||||
}
|
||||
|
||||
|
||||
public class PLCItem : NotifyProperty
|
||||
{
|
||||
private bool _selected;
|
||||
private string _name = string.Empty;
|
||||
private string _type = string.Empty;
|
||||
private string _value = string.Empty;
|
||||
private bool _startexecute;
|
||||
private bool _endexecute;
|
||||
private int _startindex;
|
||||
private int _endindex;
|
||||
private string _numtype;
|
||||
private string _address;
|
||||
/// <summary>
|
||||
/// 是否选中
|
||||
/// </summary>
|
||||
public bool Selected
|
||||
{
|
||||
get => _selected;
|
||||
set
|
||||
{
|
||||
if (_selected != value)
|
||||
{
|
||||
_selected = value;
|
||||
OnPropertyChanged(nameof(Selected));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 参数名称
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set
|
||||
{
|
||||
if (_name != value)
|
||||
{
|
||||
_name = value;
|
||||
OnPropertyChanged(nameof(Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
public string Type
|
||||
{
|
||||
get => _type;
|
||||
set
|
||||
{
|
||||
if (_type != value)
|
||||
{
|
||||
_type = value;
|
||||
OnPropertyChanged(nameof(Type));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 参数类型
|
||||
/// </summary>
|
||||
public string Address
|
||||
{
|
||||
get => _address;
|
||||
set
|
||||
{
|
||||
if (_address != value)
|
||||
{
|
||||
_address = value;
|
||||
OnPropertyChanged(nameof(Address));
|
||||
}
|
||||
}
|
||||
}
|
||||
public string NumTpye
|
||||
{
|
||||
get => _numtype;
|
||||
set
|
||||
{
|
||||
if (_numtype != value)
|
||||
{
|
||||
_numtype = value;
|
||||
OnPropertyChanged(nameof(NumTpye));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 参数值
|
||||
/// </summary>
|
||||
public string Value
|
||||
{
|
||||
get => _value;
|
||||
set
|
||||
{
|
||||
if (_value != value)
|
||||
{
|
||||
_value = value;
|
||||
OnPropertyChanged(nameof(Value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 流程开启执行状态
|
||||
/// </summary>
|
||||
public bool StartExecute
|
||||
{
|
||||
get => _startexecute;
|
||||
set
|
||||
{
|
||||
if (_startexecute != value)
|
||||
{
|
||||
_startexecute = value;
|
||||
OnPropertyChanged(nameof(StartExecute));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 流程结束执行状态
|
||||
/// </summary>
|
||||
public bool EndExecute
|
||||
{
|
||||
get => _endexecute;
|
||||
set
|
||||
{
|
||||
if (_endexecute != value)
|
||||
{
|
||||
_endexecute = value;
|
||||
OnPropertyChanged(nameof(EndExecute));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 流程开启顺序
|
||||
/// </summary>
|
||||
public int StartIndex
|
||||
{
|
||||
get => _startindex;
|
||||
set
|
||||
{
|
||||
if (_startindex != value)
|
||||
{
|
||||
_startindex = value;
|
||||
OnPropertyChanged(nameof(StartIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 流程结束顺序
|
||||
/// </summary>
|
||||
public int EndIndex
|
||||
{
|
||||
get => _endindex;
|
||||
set
|
||||
{
|
||||
if (_endindex != value)
|
||||
{
|
||||
_endindex = value;
|
||||
OnPropertyChanged(nameof(EndIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private CellLink[] cellLinks;
|
||||
[JsonIgnore]
|
||||
public CellLink[] CellLinks
|
||||
{
|
||||
get { return cellLinks; }
|
||||
set
|
||||
{
|
||||
if (cellLinks == value) return;
|
||||
cellLinks = value;
|
||||
OnPropertyChanged(nameof(CellLinks));
|
||||
}
|
||||
}
|
||||
|
||||
private CellTag[] cellTags;
|
||||
[JsonIgnore]
|
||||
public CellTag[] CellTags
|
||||
{
|
||||
get { return cellTags; }
|
||||
set
|
||||
{
|
||||
if (cellTags == value) return;
|
||||
cellTags = value;
|
||||
OnPropertyChanged(nameof(CellTags));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
186
DH.Commons/Base/VisionEngineBase.cs
Normal file
186
DH.Commons/Base/VisionEngineBase.cs
Normal file
@ -0,0 +1,186 @@
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using DH.Commons.Enums;
|
||||
using HalconDotNet;
|
||||
using OpenCvSharp;
|
||||
|
||||
|
||||
|
||||
namespace DH.Commons.Base
|
||||
{
|
||||
/// <summary>
|
||||
/// 视觉处理引擎:1.传统视觉 2.深度学习
|
||||
/// CV深度学习 四大领域
|
||||
/// Image Classification 图像分类:判别图中物体是什么,比如是猫还是狗;
|
||||
/// Semantic Segmentation 语义分割:对图像进行像素级分类,预测每个像素属于的类别,不区分个体;
|
||||
/// Object Detection 目标检测:寻找图像中的物体并进行定位;
|
||||
/// Instance Segmentation 实例分割:定位图中每个物体,并进行像素级标注,区分不同个体;
|
||||
/// </summary>
|
||||
public abstract class VisionEngineBase
|
||||
{
|
||||
public List<DetectionConfig> DetectionConfigs = new List<DetectionConfig>();
|
||||
#region event
|
||||
public event Action<string, List<double>> OnCropParamsOutput;
|
||||
public event Action<string, Bitmap, List<IShapeElement>> OnDetectionDone;
|
||||
public event Action<string> OnDetectionWarningStop;//有无检测 需要报警停机
|
||||
#endregion
|
||||
//public VisionEngineInitialConfigBase IConfig
|
||||
//{
|
||||
// get => InitialConfig as VisionEngineInitialConfigBase;
|
||||
//}
|
||||
// public ImageSaveHelper ImageSaveHelper { get; set; } = new ImageSaveHelper();
|
||||
public string BatchNO { get; set; }
|
||||
|
||||
public HTuple hv_ModelID;
|
||||
|
||||
public abstract DetectStationResult RunInference(Mat originImgSet, string detectionId = null);
|
||||
|
||||
//public abstract void SaveDetectResultAsync(DetectStationResult detectResult);
|
||||
|
||||
|
||||
|
||||
public virtual void DetectionDone(string detectionId, Bitmap image, List<IShapeElement> detectionResults)
|
||||
{
|
||||
OnDetectionDone?.Invoke(detectionId, image, detectionResults);
|
||||
}
|
||||
|
||||
public virtual void DetectionWarningStop(string detectionDes)
|
||||
{
|
||||
OnDetectionWarningStop?.Invoke(detectionDes);
|
||||
}
|
||||
|
||||
public virtual void SaveImageAsync(string fullname, Bitmap saveMap, ImageFormat imageFormat)
|
||||
{
|
||||
if (saveMap != null)
|
||||
{
|
||||
//ImageSaveSet imageSaveSet = new ImageSaveSet()
|
||||
//{
|
||||
// FullName = fullname,
|
||||
// SaveImage = saveMap.CopyBitmap(),
|
||||
// ImageFormat = imageFormat.DeepSerializeClone()
|
||||
//};
|
||||
|
||||
//ImageSaveHelper.ImageSaveAsync(imageSaveSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
public class CamModuleXY
|
||||
{
|
||||
[Category("图片行")]
|
||||
[DisplayName("行")]
|
||||
[Description("行")]
|
||||
// [TypeConverter(typeof(DeviceIdSelectorConverter<CameraBase>))]
|
||||
//[TypeConverter(typeof(CollectionCountConvert))]
|
||||
public int PicRows { get; set; } = 1;
|
||||
|
||||
[Category("图片列")]
|
||||
[DisplayName("列")]
|
||||
[Description("列")]
|
||||
// [TypeConverter(typeof(DeviceIdSelectorConverter<CameraBase>))]
|
||||
//[TypeConverter(typeof(CollectionCountConvert))]
|
||||
public int PicCols { get; set; } = 1;
|
||||
|
||||
public string GetDisplayText()
|
||||
{
|
||||
return "行:" + PicRows.ToString() + "列:" + PicCols.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
//public class RelatedCamera
|
||||
//{
|
||||
|
||||
// [Category("关联相机")]
|
||||
// [DisplayName("关联相机")]
|
||||
// [Description("关联相机描述")]
|
||||
// //[TypeConverter(typeof(DeviceIdSelectorConverter<CameraBase>))]
|
||||
// //[TypeConverter(typeof(CollectionCountConvert))]
|
||||
// public string CameraSourceId { get; set; } = "";
|
||||
|
||||
|
||||
// //public string GetDisplayText()
|
||||
// //{
|
||||
// // using (var scope = GlobalVar.Container.BeginLifetimeScope())
|
||||
// // {
|
||||
// // List<IDevice> deviceList = scope.Resolve<List<IDevice>>();
|
||||
// // IDevice CameraDevice = deviceList.FirstOrDefault(dev => dev.Id.Equals(CameraSourceId));
|
||||
|
||||
// // if (CameraDevice != null && CameraDevice is CameraBase)
|
||||
// // {
|
||||
// // return CameraDevice.Name;
|
||||
// // }
|
||||
|
||||
// // }
|
||||
// // return CameraSourceId;
|
||||
// //}
|
||||
//}
|
||||
public class VisionEngineInitialConfigBase //: InitialConfigBase
|
||||
{
|
||||
[Category("深度学习检测配置")]
|
||||
[DisplayName("检测配置集合")]
|
||||
[Description("检测配置集合")]
|
||||
//[TypeConverter(typeof(CollectionCountConvert))]
|
||||
//[Editor(typeof(ComplexCollectionEditor<DetectionConfig>), typeof(UITypeEditor))]
|
||||
public List<DetectionConfig> DetectionConfigs { get; set; } = new List<DetectionConfig>();
|
||||
|
||||
[Category("深度学习检测配置")]
|
||||
[DisplayName("标签分类")]
|
||||
[Description("标签分类,A_NG,B_TBD...")]
|
||||
// [TypeConverter(typeof(CollectionCountConvert))]
|
||||
// [Editor(typeof(ComplexCollectionEditor<RecongnitionLabelCategory>), typeof(UITypeEditor))]
|
||||
public List<RecongnitionLabelCategory> RecongnitionLabelCategoryList { get; set; } = new List<RecongnitionLabelCategory>();
|
||||
|
||||
[Category("深度学习检测配置")]
|
||||
[DisplayName("检测标签定义集合")]
|
||||
[Description("定义检测标签的集合,例如:Seg/Detection模式:断裂、油污、划伤...;Class模式:ok、ng、上面、下面、套环、正常...")]
|
||||
// [TypeConverter(typeof(CollectionCountConvert))]
|
||||
// [Editor(typeof(ComplexCollectionEditor<RecongnitionLabel>), typeof(UITypeEditor))]
|
||||
public List<RecongnitionLabel> RecongnitionLabelList { get; set; } = new List<RecongnitionLabel>();
|
||||
|
||||
[Category("深度学习检测配置")]
|
||||
[DisplayName("标签置信度")]
|
||||
[Description("标签置信度,过滤小于改置信度的标签,大于该设置的标签才能识别")]
|
||||
public float Score { get; set; } = 0.5f;
|
||||
|
||||
[Category("深度学习检测配置")]
|
||||
[DisplayName("CPU线程数量")]
|
||||
[Description("用于深度学习的CPU线程数量,不要设置太大,会单独占用线程,影响其他程序运行")]
|
||||
public int CPUNums { get; set; } = 1;
|
||||
|
||||
//[Category("深度学习检测配置")]
|
||||
//[DisplayName("检测项GPU指定")]
|
||||
//[Description("将检测项指定到GPU")]
|
||||
// [TypeConverter(typeof(CollectionCountConvert))]
|
||||
// [Editor(typeof(ComplexCollectionEditor<DetectionGPUConfig>), typeof(UITypeEditor))]
|
||||
// public List<DetectionGPUConfig> DetectionGPUList { get; set; } = new List<DetectionGPUConfig>();
|
||||
|
||||
// [Category("数据保存配置")]
|
||||
//[DisplayName("是否保存检测明细CSV")]
|
||||
//[Description("是否保存 检测明细CSV")]
|
||||
//public override bool IsEnableCSV { get; set; } = true;
|
||||
|
||||
//[Category("数据保存配置")]
|
||||
//[DisplayName("是否保存检测图片")]
|
||||
//[Description("是否保存 检测图片,总开关")]
|
||||
//public bool IsSaveImage { get; set; } = true;
|
||||
|
||||
//[Category("数据保存配置")]
|
||||
//[Description("检测图片 保存文件夹")]
|
||||
//[DisplayName("检测图片保存文件夹")]
|
||||
//[Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))]
|
||||
//public string ImageSaveDirectory { get; set; } = "D:\\PROJECTS\\X017\\Images";
|
||||
|
||||
//[Category("数据保存配置")]
|
||||
//[Description("检测明细CSV文件夹")]
|
||||
//[DisplayName("检测明细CSV文件夹")]
|
||||
//[Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))]
|
||||
//public string CSVDataPath { get; set; } = "D:\\PROJECTS\\X017\\Images";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user