| | |
| | | using LB_VisionProcesses.Processes.ScriptTool; |
| | | using OpenCvSharp; |
| | | using System.Collections.Concurrent; |
| | | using System.Windows.Media.Media3D; |
| | | |
| | | namespace LB_SmartVision.ProcessRun |
| | | { |
| | |
| | | return res; |
| | | } |
| | | |
| | | public bool GetImage(Layout layout, out HImage InputImage, out HObject RecordImage) |
| | | public bool GetImage(Layout layout, out HObject InputImage, out HObject RecordImage) |
| | | { |
| | | InputImage = null; RecordImage = null; |
| | | try |
| | |
| | | IndexValueName = arrOutputs[2]; |
| | | |
| | | object o_InputImage = ((IProcess)dicContext[IndexProcessName]).OutputImage; |
| | | if (o_InputImage != null && o_InputImage is HImage ho_image && ho_image.IsInitialized()) |
| | | { |
| | | InputImage = ho_image.Clone(); |
| | | ho_image.Dispose(); |
| | | } |
| | | else if (o_InputImage != null && o_InputImage is Bitmap) |
| | | if (o_InputImage is HObject ho_image && ho_image.IsInitialized()) |
| | | InputImage = ho_image; |
| | | else if (o_InputImage is Bitmap) |
| | | { |
| | | //将Mat转换为HObject |
| | | using (HImage ho_RecordImage = TAlgorithm.Bitmap2HObject((Bitmap)o_InputImage)) |
| | | { |
| | | if (ho_RecordImage != null) |
| | | { |
| | | InputImage = ho_RecordImage.Clone(); |
| | | } |
| | | } |
| | | TAlgorithm.Bitmap2HObject((Bitmap)o_InputImage, out HObject ho_RecordImage); |
| | | InputImage = ho_RecordImage; |
| | | } |
| | | else if (o_InputImage != null && o_InputImage is Mat) |
| | | else if (o_InputImage is Mat) |
| | | { |
| | | //将Mat转换为HObject |
| | | using (HImage ho_RecordImage = TAlgorithm.Mat2HObject((Mat)o_InputImage)) |
| | | { |
| | | if (ho_RecordImage != null) |
| | | { |
| | | InputImage = ho_RecordImage.Clone(); |
| | | } |
| | | } |
| | | TAlgorithm.Mat2HObject((Mat)o_InputImage, out HObject ho_RecordImage); |
| | | InputImage = ho_RecordImage; |
| | | } |
| | | |
| | | if (InputImage != null && InputImage.IsInitialized()) |
| | | { |
| | | InputImage.GetImageSize(out ho_ImageWidth, out ho_ImageHeight); |
| | | HOperatorSet.GetImageSize(InputImage, out ho_ImageWidth, out ho_ImageHeight); |
| | | |
| | | //图片尺寸变化才更新窗口尺寸[提高速度] |
| | | if ((ho_ImageWidth.Length > 0 && ho_ImageWidth.TupleInt() != hWindowControl.Size.Width) |
| | |
| | | if (dicContext.TryGetValue(ProcessName, out IProcess obj) |
| | | && obj is IProcess process) |
| | | { |
| | | //process.InputImage = null; |
| | | |
| | | if (process.InputImage != null) |
| | | { |
| | | if (process.InputImage is HObject) |
| | | { |
| | | ((HObject)process.InputImage).Dispose(); |
| | | } |
| | | else if (process.InputImage is Mat) |
| | | { |
| | | ((Mat)process.InputImage).Dispose(); |
| | | } |
| | | else if (process.InputImage is Bitmap) |
| | | { |
| | | ((Bitmap)process.InputImage).Dispose(); |
| | | } |
| | | |
| | | process.InputImage = null; |
| | | } |
| | | |
| | | if (process.OutputImage != null) |
| | | { |
| | | if (process.OutputImage is HObject) |
| | | { |
| | | ((HObject)process.OutputImage).Dispose(); |
| | | } |
| | | else if (process.OutputImage is Mat) |
| | | { |
| | | ((Mat)process.OutputImage).Dispose(); |
| | | } |
| | | else if (process.OutputImage is Bitmap) |
| | | { |
| | | ((Bitmap)process.OutputImage).Dispose(); |
| | | } |
| | | |
| | | process.OutputImage = null; |
| | | } |
| | | |
| | | if (process.Record != null) |
| | | { |
| | | process.Record.Dispose(); |
| | | process.Record = null; |
| | | } |
| | | UpdateInputs(process); |
| | | |
| | |
| | | [Node("相机取图", "取像工具", "Basic", "相机取图")] |
| | | public void 相机取图(FlowNode node) { RunNodeAsync(node); } |
| | | |
| | | [Node("Halcon2D斑点工具", "Halcon2D工具", "Basic", "Halcon2D斑点工具")] |
| | | [Node("Halcon2D斑点工具", "Haclon2D工具", "Basic", "Halcon2D斑点工具")] |
| | | public void Halcon2D斑点工具(FlowNode node) { RunNodeAsync(node); } |
| | | |
| | | [Node("通讯模块", "通讯工具", "Basic", "通讯模块")] |
| | | public void 通讯模块(FlowNode node) { RunNodeAsync(node); } |
| | | |
| | | #endregion |
| | | |
| | | |