| | |
| | | return res; |
| | | } |
| | | |
| | | public bool GetImage(Layout layout, out HObject InputImage, out HObject RecordImage) |
| | | public bool GetImage(Layout layout, out HImage InputImage, out HObject RecordImage) |
| | | { |
| | | InputImage = null; RecordImage = null; |
| | | try |
| | |
| | | IndexValueName = arrOutputs[2]; |
| | | |
| | | object o_InputImage = ((IProcess)dicContext[IndexProcessName]).OutputImage; |
| | | if (o_InputImage is HObject ho_image && ho_image.IsInitialized()) |
| | | InputImage = ho_image; |
| | | else if (o_InputImage is Bitmap) |
| | | if (o_InputImage != null && o_InputImage is HImage ho_image && ho_image.IsInitialized()) |
| | | { |
| | | //将Mat转换为HObject |
| | | TAlgorithm.Bitmap2HObject((Bitmap)o_InputImage, out HObject ho_RecordImage); |
| | | InputImage = ho_RecordImage; |
| | | InputImage = ho_image.Clone(); |
| | | ho_image.Dispose(); |
| | | } |
| | | else if (o_InputImage is Mat) |
| | | else if (o_InputImage != null && o_InputImage is Bitmap) |
| | | { |
| | | //将Mat转换为HObject |
| | | TAlgorithm.Mat2HObject((Mat)o_InputImage, out HObject ho_RecordImage); |
| | | InputImage = ho_RecordImage; |
| | | using (HImage ho_RecordImage = TAlgorithm.Bitmap2HObject((Bitmap)o_InputImage)) |
| | | { |
| | | if (ho_RecordImage != null) |
| | | { |
| | | InputImage = ho_RecordImage.Clone(); |
| | | } |
| | | } |
| | | } |
| | | else if (o_InputImage != null && o_InputImage is Mat) |
| | | { |
| | | //将Mat转换为HObject |
| | | using (HImage ho_RecordImage = TAlgorithm.Mat2HObject((Mat)o_InputImage)) |
| | | { |
| | | if (ho_RecordImage != null) |
| | | { |
| | | InputImage = ho_RecordImage.Clone(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (InputImage != null && InputImage.IsInitialized()) |
| | | { |
| | | HOperatorSet.GetImageSize(InputImage, out ho_ImageWidth, out ho_ImageHeight); |
| | | InputImage.GetImageSize(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; |
| | | } |
| | | UpdateInputs(process); |
| | | |
| | | // 不同节点跳过的方式不同 |