This commit is contained in:
Admin 2025-04-28 11:30:29 +08:00
parent bc0ed5d574
commit 95bc9ce3b3
3 changed files with 87 additions and 60 deletions

View File

@ -32,6 +32,10 @@ namespace DH.Devices.Vision
bool res = false; bool res = false;
try try
{ {
if (!Path.GetExtension(mLInit.ModelFile).Equals(".trt", StringComparison.OrdinalIgnoreCase))
{
throw new Exception("选择的模型不是trt格式");
}
Model = MLGPUEngine.InitModel(mLInit.ModelFile, 1, mLInit.Score_thre, mLInit.GPUId, 3, 8); Model = MLGPUEngine.InitModel(mLInit.ModelFile, 1, mLInit.Score_thre, mLInit.GPUId, 3, 8);
//Model = MLEngine.InitModel(mLInit.ModelFile, 1, 0.45f, 0, 3); //Model = MLEngine.InitModel(mLInit.ModelFile, 1, 0.45f, 0, 3);

View File

@ -31,6 +31,8 @@ namespace DH.Devices.Vision
public List<SimboStationMLEngineSet> SimboStationMLEngineList = new List<SimboStationMLEngineSet>(); public List<SimboStationMLEngineSet> SimboStationMLEngineList = new List<SimboStationMLEngineSet>();
public void Init() public void Init()
{
try
{ {
//InitialQueue(); //InitialQueue();
InitialHalconTools(); InitialHalconTools();
@ -40,6 +42,12 @@ namespace DH.Devices.Vision
// ImageSaveHelper.OnImageSaveExceptionRaised += ImageSaveHelper_OnImageSaveExceptionRaised; // ImageSaveHelper.OnImageSaveExceptionRaised += ImageSaveHelper_OnImageSaveExceptionRaised;
// base.Init(); // base.Init();
} }
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public void Stop() public void Stop()
{ {
SimboStationMLEngineList.ToList().ForEach(sm => SimboStationMLEngineList.ToList().ForEach(sm =>
@ -291,11 +299,18 @@ namespace DH.Devices.Vision
/// 初始化深度学习工具 /// 初始化深度学习工具
/// </summary> /// </summary>
private bool InitialSimboMLEnginesAsync() private bool InitialSimboMLEnginesAsync()
{
try
{ {
//深度学习 模型加载 //深度学习 模型加载
var resultOK = MLLoadModel(); var resultOK = MLLoadModel();
return resultOK; return resultOK;
} }
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
/// <summary> /// <summary>
/// 深度学习 模型加载 /// 深度学习 模型加载
/// </summary> /// </summary>
@ -358,6 +373,7 @@ namespace DH.Devices.Vision
{ {
// LogAsync(DateTime.Now, LogLevel.Exception, $"异常:模型并发加载异常:{ex.GetExceptionMessage()}"); // LogAsync(DateTime.Now, LogLevel.Exception, $"异常:模型并发加载异常:{ex.GetExceptionMessage()}");
resultOK = false; resultOK = false;
throw new Exception(ex.Message);
} }
return resultOK; return resultOK;
@ -432,7 +448,7 @@ namespace DH.Devices.Vision
{ {
// LogAsync(DateTime.Now, LogLevel.Error, $"模型加载成功是否GPU:{isGPU} CoreInx:{coreInx} - {dc.Name}" + $" {dc.ModelType.GetEnumDescription()}:{dc.ModelPath}"); // LogAsync(DateTime.Now, LogLevel.Error, $"模型加载成功是否GPU:{isGPU} CoreInx:{coreInx} - {dc.Name}" + $" {dc.ModelType.GetEnumDescription()}:{dc.ModelPath}");
throw new ProcessException($"异常是否GPU:{isGPU} CoreInx:{coreInx} - {dc.Name}模型加载异常:{ex.GetExceptionMessage()}"); throw new Exception($"异常是否GPU:{isGPU} CoreInx:{coreInx} - {dc.Name}模型加载异常:{ex.Message}");
} }
return mLEngineSet; return mLEngineSet;
} }

View File

@ -633,6 +633,8 @@ namespace DHSoftware
} }
FrmLog frmLog; FrmLog frmLog;
public void InitModel() public void InitModel()
{
try
{ {
Dectection.Clear(); Dectection.Clear();
_cameraRelatedDetectionDict = new(); _cameraRelatedDetectionDict = new();
@ -694,6 +696,11 @@ namespace DHSoftware
CtrlVisionRunBase ctrlVisionRun = new CtrlVisionRunBase(_visionEngine); CtrlVisionRunBase ctrlVisionRun = new CtrlVisionRunBase(_visionEngine);
ctrlVisionRun.Dock = DockStyle.Fill; ctrlVisionRun.Dock = DockStyle.Fill;
tabImgDisplay.Controls.Add(ctrlVisionRun); tabImgDisplay.Controls.Add(ctrlVisionRun);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
} }