| | |
| | | using Newtonsoft.Json; |
| | | using HalconDotNet; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Serialization; |
| | | using OpenCvSharp; |
| | | using OpenCvSharp.Extensions; |
| | | using System; |
| | | using System.Collections.Concurrent; |
| | | using System.Diagnostics; |
| | | using System.Text; |
| | |
| | | |
| | | Params.Inputs.Add("超时时间", 1000); |
| | | Params.Inputs.Add("是否失败重新取图", false); |
| | | |
| | | // 2D轮胎计数配置(默认为1,表示3D模式;2D相机设置为n) |
| | | Params.Inputs.Add("ImagesPerTyre", 1); |
| | | Params.Inputs.Add("当前轮胎ID", 1); |
| | | Params.Inputs.Add("当前图像序号", 0); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | Mat src = Cv2.ImRead(SN); |
| | | if (src != null && !src.Empty()) |
| | | OutputImage = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(src); |
| | | OutputImage = src.ToBitmap(); |
| | | } |
| | | } |
| | | } |
| | |
| | | Msg = ""; |
| | | if (OutputImage != null) |
| | | { |
| | | if (OutputImage is Bitmap) |
| | | { |
| | | if (OutputImage is HObject) |
| | | ((HObject)OutputImage).Dispose(); |
| | | else if (OutputImage is Mat) |
| | | ((Mat)OutputImage).Dispose(); |
| | | else if (OutputImage is Bitmap) |
| | | ((Bitmap)OutputImage).Dispose(); |
| | | } |
| | | |
| | | OutputImage = null; |
| | | } |
| | | if (Record != null) |
| | | { |
| | | Record.Dispose(); |
| | | Record = null; |
| | | } |
| | | } |
| | | |
| | | public override void Dispose() |
| | | { |
| | | if (InputImage != null) |
| | | { |
| | | if (InputImage is HObject) |
| | | ((HObject)InputImage).Dispose(); |
| | | else if (InputImage is Mat) |
| | | ((Mat)InputImage).Dispose(); |
| | | else if (InputImage is Bitmap) |
| | | ((Bitmap)InputImage).Dispose(); |
| | | |
| | | InputImage = null; |
| | | } |
| | | |
| | | if (OutputImage != null) |
| | | { |
| | | if (OutputImage is HObject) |
| | | ((HObject)OutputImage).Dispose(); |
| | | else if (OutputImage is Mat) |
| | | ((Mat)OutputImage).Dispose(); |
| | | else if (OutputImage is Bitmap) |
| | | ((Bitmap)OutputImage).Dispose(); |
| | | |
| | | OutputImage = null; |
| | | } |
| | | return; |
| | | } |
| | | |