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

@ -634,66 +634,73 @@ namespace DHSoftware
FrmLog frmLog;
public void InitModel()
{
Dectection.Clear();
_cameraRelatedDetectionDict = new();
if (ConfigModel.DetectionList.Count > 0)
try
{
for (int i = 0; i < ConfigModel.DetectionList.Count; i++)
{
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";
Dectection.Clear();
_cameraRelatedDetectionDict = new();
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);
if (ConfigModel.DetectionList.Count > 0)
{
for (int i = 0; i < ConfigModel.DetectionList.Count; i++)
{
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 =>
{
detection.CameraCollects.ForEach(cam =>
DetectionConfigs.ForEach(detection =>
{
List<string> Dets = new List<string>
detection.CameraCollects.ForEach(cam =>
{
List<string> Dets = new List<string>
{
detection.Id
};
if (!_cameraRelatedDetectionDict.ContainsKey(cam.CameraSourceId))
{
_cameraRelatedDetectionDict.Add(cam.CameraSourceId, Dets);
if (!_cameraRelatedDetectionDict.ContainsKey(cam.CameraSourceId))
{
_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.Dock = DockStyle.Fill;
pnlLog.Controls.Add(frmLog);
//
_visionEngine = new SimboVisionDriver();
_visionEngine.DetectionConfigs = DetectionConfigs;
_visionEngine.LoggerHelper.LogPath = "D://PROJECTS//Logs//";
_visionEngine.LoggerHelper.LogPrefix = "Vision";
_visionEngine.OnLog += _visionEngine_OnLog;
//初始化模型 加载模型
_visionEngine.Init();
frmLog = new FrmLog();
frmLog.Dock = DockStyle.Fill;
pnlLog.Controls.Add(frmLog);
//
_visionEngine = new SimboVisionDriver();
_visionEngine.DetectionConfigs = DetectionConfigs;
_visionEngine.LoggerHelper.LogPath = "D://PROJECTS//Logs//";
_visionEngine.LoggerHelper.LogPrefix = "Vision";
_visionEngine.OnLog += _visionEngine_OnLog;
//初始化模型 加载模型
_visionEngine.Init();
CtrlVisionRunBase ctrlVisionRun = new CtrlVisionRunBase(_visionEngine);
ctrlVisionRun.Dock = DockStyle.Fill;
tabImgDisplay.Controls.Add(ctrlVisionRun);
CtrlVisionRunBase ctrlVisionRun = new CtrlVisionRunBase(_visionEngine);
ctrlVisionRun.Dock = DockStyle.Fill;
tabImgDisplay.Controls.Add(ctrlVisionRun);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}