提交
This commit is contained in:
parent
bc0ed5d574
commit
95bc9ce3b3
@ -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);
|
||||||
|
@ -32,13 +32,21 @@ namespace DH.Devices.Vision
|
|||||||
|
|
||||||
public void Init()
|
public void Init()
|
||||||
{
|
{
|
||||||
//InitialQueue();
|
try
|
||||||
InitialHalconTools();
|
{
|
||||||
InitialSimboMLEnginesAsync();
|
//InitialQueue();
|
||||||
|
InitialHalconTools();
|
||||||
|
InitialSimboMLEnginesAsync();
|
||||||
|
|
||||||
|
// ImageSaveHelper.OnImageSaveExceptionRaised -= ImageSaveHelper_OnImageSaveExceptionRaised;
|
||||||
|
// ImageSaveHelper.OnImageSaveExceptionRaised += ImageSaveHelper_OnImageSaveExceptionRaised;
|
||||||
|
// base.Init();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new Exception(ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
// ImageSaveHelper.OnImageSaveExceptionRaised -= ImageSaveHelper_OnImageSaveExceptionRaised;
|
|
||||||
// ImageSaveHelper.OnImageSaveExceptionRaised += ImageSaveHelper_OnImageSaveExceptionRaised;
|
|
||||||
// base.Init();
|
|
||||||
}
|
}
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
@ -292,9 +300,16 @@ namespace DH.Devices.Vision
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private bool InitialSimboMLEnginesAsync()
|
private bool InitialSimboMLEnginesAsync()
|
||||||
{
|
{
|
||||||
//深度学习 模型加载
|
try
|
||||||
var resultOK = MLLoadModel();
|
{
|
||||||
return resultOK;
|
//深度学习 模型加载
|
||||||
|
var resultOK = MLLoadModel();
|
||||||
|
return resultOK;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new Exception(ex.Message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// <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;
|
||||||
}
|
}
|
||||||
|
@ -634,66 +634,73 @@ namespace DHSoftware
|
|||||||
FrmLog frmLog;
|
FrmLog frmLog;
|
||||||
public void InitModel()
|
public void InitModel()
|
||||||
{
|
{
|
||||||
Dectection.Clear();
|
try
|
||||||
_cameraRelatedDetectionDict = new();
|
|
||||||
|
|
||||||
if (ConfigModel.DetectionList.Count > 0)
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i < ConfigModel.DetectionList.Count; i++)
|
Dectection.Clear();
|
||||||
{
|
_cameraRelatedDetectionDict = new();
|
||||||
DetectionConfig detectionConfig = ConfigModel.DetectionList[i];
|
|
||||||
var detection = ConfigModel.DetectionList[i];
|
|
||||||
detectionConfig.CameraCollects = detection.CameraCollects;
|
|
||||||
detectionConfig.ModelconfThreshold = detection.ModelconfThreshold;
|
|
||||||
detectionConfig.ModelWidth = detection.ModelWidth;
|
|
||||||
detectionConfig.ModelHeight = detection.ModelHeight;
|
|
||||||
detectionConfig.In_lable_path = detection.In_lable_path;
|
|
||||||
detectionConfig.IsEnabled = detection.IsEnabled;
|
|
||||||
detectionConfig.ImageSaveDirectory = "D://Projects//Images";
|
|
||||||
|
|
||||||
detectionConfig.ShowLocation.X = (i + 1) % 5 + (i + 1) / 5;
|
if (ConfigModel.DetectionList.Count > 0)
|
||||||
// detectionConfig.ShowLocation.X = detection.ShowLocation.X;
|
{
|
||||||
detectionConfig.ShowLocation.Y = (i + 1) / 5 + 1;
|
for (int i = 0; i < ConfigModel.DetectionList.Count; i++)
|
||||||
// detectionConfig.ShowLocation.Y = detection.ShowLocation.Y;
|
{
|
||||||
DetectionConfigs.Add(detectionConfig);
|
DetectionConfig detectionConfig = ConfigModel.DetectionList[i];
|
||||||
|
var detection = ConfigModel.DetectionList[i];
|
||||||
|
detectionConfig.CameraCollects = detection.CameraCollects;
|
||||||
|
detectionConfig.ModelconfThreshold = detection.ModelconfThreshold;
|
||||||
|
detectionConfig.ModelWidth = detection.ModelWidth;
|
||||||
|
detectionConfig.ModelHeight = detection.ModelHeight;
|
||||||
|
detectionConfig.In_lable_path = detection.In_lable_path;
|
||||||
|
detectionConfig.IsEnabled = detection.IsEnabled;
|
||||||
|
detectionConfig.ImageSaveDirectory = "D://Projects//Images";
|
||||||
|
|
||||||
|
detectionConfig.ShowLocation.X = (i + 1) % 5 + (i + 1) / 5;
|
||||||
|
// detectionConfig.ShowLocation.X = detection.ShowLocation.X;
|
||||||
|
detectionConfig.ShowLocation.Y = (i + 1) / 5 + 1;
|
||||||
|
// detectionConfig.ShowLocation.Y = detection.ShowLocation.Y;
|
||||||
|
DetectionConfigs.Add(detectionConfig);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
DetectionConfigs.ForEach(detection =>
|
||||||
DetectionConfigs.ForEach(detection =>
|
|
||||||
{
|
|
||||||
detection.CameraCollects.ForEach(cam =>
|
|
||||||
{
|
{
|
||||||
List<string> Dets = new List<string>
|
detection.CameraCollects.ForEach(cam =>
|
||||||
|
{
|
||||||
|
List<string> Dets = new List<string>
|
||||||
{
|
{
|
||||||
detection.Id
|
detection.Id
|
||||||
};
|
};
|
||||||
if (!_cameraRelatedDetectionDict.ContainsKey(cam.CameraSourceId))
|
if (!_cameraRelatedDetectionDict.ContainsKey(cam.CameraSourceId))
|
||||||
{
|
{
|
||||||
_cameraRelatedDetectionDict.Add(cam.CameraSourceId, Dets);
|
_cameraRelatedDetectionDict.Add(cam.CameraSourceId, Dets);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_cameraRelatedDetectionDict[cam.CameraSourceId].Add(detection.Id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
);
|
||||||
{
|
});
|
||||||
_cameraRelatedDetectionDict[cam.CameraSourceId].Add(detection.Id);
|
string inferenceDevice = "CPU";
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
string inferenceDevice = "CPU";
|
|
||||||
|
|
||||||
frmLog = new FrmLog();
|
frmLog = new FrmLog();
|
||||||
frmLog.Dock = DockStyle.Fill;
|
frmLog.Dock = DockStyle.Fill;
|
||||||
pnlLog.Controls.Add(frmLog);
|
pnlLog.Controls.Add(frmLog);
|
||||||
//
|
//
|
||||||
_visionEngine = new SimboVisionDriver();
|
_visionEngine = new SimboVisionDriver();
|
||||||
_visionEngine.DetectionConfigs = DetectionConfigs;
|
_visionEngine.DetectionConfigs = DetectionConfigs;
|
||||||
_visionEngine.LoggerHelper.LogPath = "D://PROJECTS//Logs//";
|
_visionEngine.LoggerHelper.LogPath = "D://PROJECTS//Logs//";
|
||||||
_visionEngine.LoggerHelper.LogPrefix = "Vision";
|
_visionEngine.LoggerHelper.LogPrefix = "Vision";
|
||||||
_visionEngine.OnLog += _visionEngine_OnLog;
|
_visionEngine.OnLog += _visionEngine_OnLog;
|
||||||
//初始化模型 加载模型
|
//初始化模型 加载模型
|
||||||
_visionEngine.Init();
|
_visionEngine.Init();
|
||||||
|
|
||||||
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user