| | |
| | | |
| | | if (Subject.InputImage != null && Subject.InputImage is Mat) |
| | | { |
| | | using (HImage image = TAlgorithm.Mat2HImage((Mat)Subject.InputImage)) |
| | | { |
| | | TAlgorithm.Mat2HObject((Mat)Subject.InputImage, out HObject image); |
| | | inputImageHSmartWindowControl.ShowHoImage(image); |
| | | } |
| | | |
| | | Type type = Subject.Params.ROI?.GetType(); |
| | | if (Subject.Params.ROI != null) |
| | | { |
| | |
| | | } |
| | | |
| | | ShowModel(((FindModelTool)Subject).ModelID); |
| | | |
| | | } |
| | | } |
| | | })); |
| | | } |
| | | |
| | |
| | | |
| | | if (Subject.InputImage != null && Subject.InputImage is Mat) |
| | | { |
| | | using (HImage image = TAlgorithm.Mat2HImage((Mat)Subject.InputImage)) |
| | | { |
| | | image.GetImageSize(out HTuple ho_ImageWidth, out HTuple ho_ImageHeight); |
| | | TAlgorithm.Mat2HObject((Mat)Subject.InputImage, out HObject image); |
| | | HOperatorSet.GetImageSize(image, out HTuple ho_ImageWidth, out HTuple ho_ImageHeight); |
| | | recordImageHSmartWindowControl.ShowHoImage(image); |
| | | } |
| | | |
| | | //先判断子类再判断父类 |
| | | if (Subject.Record != null && Subject.Record is MsgRecord msgRecord) |
| | | { |
| | |
| | | { |
| | | recordImageHSmartWindowControl.DispObj(objRecord.RecordObject_OK, true); |
| | | recordImageHSmartWindowControl.DispObj(objRecord.RecordObject_NG, false); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | GC.Collect(); |
| | |
| | | HTuple hv_imageHeight = 0; |
| | | if (InputImage != null && InputImage is Mat) |
| | | { |
| | | using (HImage image = TAlgorithm.Mat2HImage((Mat)InputImage)) |
| | | { |
| | | TAlgorithm.Mat2HObject((Mat)InputImage, out HObject image); |
| | | HOperatorSet.GetImageSize(image, out hv_imageWidth, out hv_imageHeight); |
| | | } |
| | | switch (type) |
| | | { |
| | | case RoiType.Rectangle2: |
| | |
| | | default: |
| | | inputImageHSmartWindowControl.oRoi = null; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | if (InputImage != null && InputImage is Mat) |
| | | { |
| | | imgTabControl.SelectedTab = tabPageModelImage; |
| | | using (HImage hoDomainImage = TAlgorithm.Mat2HImage((Mat)InputImage)) |
| | | { |
| | | TAlgorithm.Mat2HObject((Mat)InputImage, out HObject hoDomainImage); |
| | | |
| | | HOperatorSet.GetImageSize(hoDomainImage, out HTuple hv_imageWidth, out HTuple hv_imageHeight); |
| | | createModelImageHSmartWindowControl.ShowHoImage(hoDomainImage); |
| | | createModelImageHSmartWindowControl.ShowHoImage((HObject)hoDomainImage); |
| | | createModelImageHSmartWindowControl.bAollowDraw = true; |
| | | createModelImageHSmartWindowControl.oRoi = new HRectangle2(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2 |
| | | , 0, hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | if (InputImage != null && InputImage is Mat) |
| | | { |
| | | double result = 0; |
| | | |
| | | if (Enum.TryParse(cmbModelType.Text, out ModelType modelType)) |
| | | { |
| | | string NumLevels = this.dtxtModelParam1.Text; |
| | |
| | | string Contrast = this.dtxtModelParam11.Text; |
| | | int MinContrast = Convert.ToInt16(this.dtxtModelParam12.Text); |
| | | HRectangle2 ROI = (HRectangle2)createModelImageHSmartWindowControl.oRoi; |
| | | using (HRegion hRectangle = new HRegion()) |
| | | { |
| | | hRectangle.GenRectangle2(ROI.Row, ROI.Column, ROI.Phi, ROI.SemiLength1, ROI.SemiLength2); |
| | | using (HImage hoDomainImage = TAlgorithm.Mat2HImage((Mat)InputImage)) |
| | | { |
| | | |
| | | HOperatorSet.GenRectangle2(out HObject hRectangle, ROI.Row, ROI.Column, ROI.Phi, ROI.SemiLength1, ROI.SemiLength2); |
| | | TAlgorithm.Mat2HObject((Mat)InputImage, out HObject hoDomainImage); |
| | | HTuple hv_Channels = new HTuple(); |
| | | //判断是否为灰度图 |
| | | using (HDevDisposeHelper dh = new HDevDisposeHelper()) |
| | | { |
| | | try |
| | | { |
| | | //hv_Channels = hoDomainImage.CountChannels(); |
| | | //if (hv_Channels.TupleInt() != 1) |
| | | // HOperatorSet.Rgb1ToGray(hoDomainImage, out hoDomainImage); |
| | | HOperatorSet.CountChannels(hoDomainImage, out hv_Channels); |
| | | if (hv_Channels.TupleInt() != 1) |
| | | HOperatorSet.Rgb1ToGray(hoDomainImage, out hoDomainImage); |
| | | |
| | | ////转换后再次检查是否为灰度图 |
| | | //HOperatorSet.CountChannels(hoDomainImage, out hv_Channels); |
| | | //if (hv_Channels.TupleInt() != 1) |
| | | // HOperatorSet.Rgb1ToGray(hoDomainImage, out hoDomainImage); |
| | | //转换后再次检查是否为灰度图 |
| | | HOperatorSet.CountChannels(hoDomainImage, out hv_Channels); |
| | | if (hv_Channels.TupleInt() != 1) |
| | | HOperatorSet.Rgb1ToGray(hoDomainImage, out hoDomainImage); |
| | | } |
| | | catch { } |
| | | } |
| | | HObject hoImageReduced = hoDomainImage.Rgb1ToGray().ReduceDomain(hRectangle); |
| | | HOperatorSet.ReduceDomain(hoDomainImage, hRectangle, out HObject hoImageReduced); |
| | | HOperatorSet.CropDomain(hoImageReduced, out hoImageReduced); |
| | | TAlgorithm.HObject2Mat(hoImageReduced, out Mat hoModelImage); |
| | | bool bCreateModel = false; |
| | |
| | | |
| | | if (bCreateModel) |
| | | { |
| | | using (HObject ho_ModelContours = new HObject()) |
| | | { |
| | | HObject ho_ModelContours = new HObject(); |
| | | //switch (((FindModelTool)Subject).ModelID.Type) |
| | | //{ |
| | | // case ModelType.局部变形模板: |
| | |
| | | //建模成功导航到子页 |
| | | parasTabControl.SelectedTab = tabPageRunParas; |
| | | //modelImageHSmartWindowControl.ShowHoImage(((HFindModelTool)Subject).ModelID.hoImage); |
| | | using (HImage modelImage = TAlgorithm.Mat2HImage(((FindModelTool)Subject).ModelID.hoImage)) |
| | | { |
| | | TAlgorithm.Mat2HObject(((FindModelTool)Subject).ModelID.hoImage, out HObject modelImage); |
| | | modelImageHSmartWindowControl.ShowHoImage(modelImage); |
| | | modelImageHSmartWindowControl.DispObj(ho_ModelContours, false); |
| | | modelImageHSmartWindowControl.ShowMsg("创建模板成功", true); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | if (ModelID != null && ModelID.Width > 0) |
| | | { |
| | | //HOperatorSet.GenEmptyObj(out HObject ho_ModelContours); |
| | | using (HRegion ho_ModelContours = new HRegion()) |
| | | { |
| | | HOperatorSet.GenEmptyObj(out HObject ho_ModelContours); |
| | | //switch (ModelID.Type) |
| | | //{ |
| | | // case ModelType.各向异形模板: |
| | |
| | | //HOperatorSet.AffineTransContourXld(ho_ModelContours, out ho_ModelContours, hv_HomMat2D); |
| | | |
| | | modelImageHSmartWindowControl.ClearObj(); |
| | | using (HImage hoImage = TAlgorithm.Mat2HImage(ModelID.hoImage)) |
| | | { |
| | | TAlgorithm.Mat2HObject(ModelID.hoImage, out HObject hoImage); |
| | | //modelImageHSmartWindowControl.ShowHoImage(ModelID.hoImage); |
| | | modelImageHSmartWindowControl.ShowHoImage(hoImage); |
| | | modelImageHSmartWindowControl.DispObj(ho_ModelContours, false); |
| | | modelImageHSmartWindowControl.ShowMsg("创建模板成功", true); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | catch { } |