| | |
| | | return res; |
| | | } |
| | | |
| | | public bool GetImage(Layout layout, out HImage InputImage, out HObject RecordImage) |
| | | public bool GetImage(Layout layout, out HImage InputImage, out HImage RecordImage) |
| | | { |
| | | InputImage = null; RecordImage = null; |
| | | try |
| | |
| | | else if (o_InputImage != null && o_InputImage is Bitmap) |
| | | { |
| | | //将Mat转换为HObject |
| | | using (HImage ho_RecordImage = TAlgorithm.Bitmap2HObject((Bitmap)o_InputImage)) |
| | | using (HImage ho_RecordImage = TAlgorithm.Bitmap2HImage((Bitmap)o_InputImage)) |
| | | { |
| | | if (ho_RecordImage != null) |
| | | if (ho_RecordImage != null && ho_RecordImage.Key != IntPtr.Zero) |
| | | { |
| | | InputImage = ho_RecordImage.Clone(); |
| | | } |
| | |
| | | else if (o_InputImage != null && o_InputImage is Mat) |
| | | { |
| | | //将Mat转换为HObject |
| | | using (HImage ho_RecordImage = TAlgorithm.Mat2HObject((Mat)o_InputImage)) |
| | | using (HImage ho_RecordImage = TAlgorithm.Mat2HImage((Mat)o_InputImage)) |
| | | { |
| | | if (ho_RecordImage != null) |
| | | if (ho_RecordImage != null && ho_RecordImage.Key != IntPtr.Zero) |
| | | { |
| | | InputImage = ho_RecordImage.Clone(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (InputImage != null && InputImage.IsInitialized()) |
| | | if (InputImage != null && InputImage.Key != IntPtr.Zero && InputImage.IsInitialized()) |
| | | { |
| | | InputImage.GetImageSize(out ho_ImageWidth, out ho_ImageHeight); |
| | | |
| | |
| | | |
| | | if (dicContext.ContainsKey(IndexProcessName)) |
| | | { |
| | | ObjectRecord objectRecord1 = ((IProcess)dicContext[IndexProcessName]).Record; |
| | | if (objectRecord1 != null) |
| | | using (ObjectRecord objectRecord1 = ((IProcess)dicContext[IndexProcessName]).Record) |
| | | { |
| | | objectRecord1.Display(hWindowControl.HalconWindow); |
| | | objectRecord1.Dispose(); |
| | | if (objectRecord1 != null) |
| | | { |
| | | objectRecord1.Display(hWindowControl.HalconWindow); |
| | | objectRecord1.Dispose(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | if (dicContext.ContainsKey(IndexProcessName)) |
| | | { |
| | | ObjectRecord objectRecord2 = ((IProcess)dicContext[IndexProcessName]).Record; |
| | | if (objectRecord2 != null) |
| | | using (ObjectRecord objectRecord2 = ((IProcess)dicContext[IndexProcessName]).Record) |
| | | { |
| | | objectRecord2.Display(hWindowControl.HalconWindow); |
| | | objectRecord2.Dispose(); |
| | | if (objectRecord2 != null) |
| | | { |
| | | objectRecord2.Display(hWindowControl.HalconWindow); |
| | | objectRecord2.Dispose(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | if (dicContext.ContainsKey(IndexProcessName)) |
| | | { |
| | | ObjectRecord objectRecord3 = ((IProcess)dicContext[IndexProcessName]).Record; |
| | | if (objectRecord3 != null) |
| | | using (ObjectRecord objectRecord3 = ((IProcess)dicContext[IndexProcessName]).Record) |
| | | { |
| | | objectRecord3.Display(hWindowControl.HalconWindow); |
| | | objectRecord3.Dispose(); |
| | | if (objectRecord3 != null) |
| | | { |
| | | objectRecord3.Display(hWindowControl.HalconWindow); |
| | | objectRecord3.Dispose(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | if (Result) |
| | | { |
| | | Msg = "运行成功"; |
| | | HOperatorSet.SetColor(hWindowControl.HalconWindow, "green"); |
| | | hWindowControl.HalconWindow.SetColor("green"); |
| | | } |
| | | else |
| | | HOperatorSet.SetColor(hWindowControl.HalconWindow, "red"); |
| | | hWindowControl.HalconWindow.SetColor("red"); |
| | | |
| | | TAlgorithm.DispMsg(Msg, hWindowControl.HalconWindow, Result ? "green" : "red", 0, 0); |
| | | HOperatorSet.DumpWindowImage(out RecordImage, hWindowControl.HalconWindow); |
| | | RecordImage = hWindowControl.HalconWindow.DumpWindowImage(); |
| | | #endregion |
| | | |
| | | return true; |