public static bool addShapeModel(HObject image, ViewWindow.Model.ROI region, ref List <Model.MatchingConfig> matchingConfig, out HTuple modelID) { bool rct = false; if ((region != null) && (image != null)) { List <Model.CreatModelParameter> m_CreatModelParameter = new List <Model.CreatModelParameter>(); Model.CreatModelParameter m_CreatModel = new Model.CreatModelParameter(1, 0.0, 360.0, 3); m_CreatModelParameter.Add(m_CreatModel); List <Model.FindModelParameter> m_FindModelParameter = new List <Model.FindModelParameter>(); Model.FindModelParameter m_FindModel = new Model.FindModelParameter(1, 0.0, 360.0, 0.75, 1, 0.75, 3); m_FindModelParameter.Add(m_FindModel); List <ViewWindow.Model.RoiData> m_RoiData = new List <ViewWindow.Model.RoiData>(); m_RoiData.Add(new ViewWindow.Model.RoiData(0, region)); int id = 0; if (matchingConfig == null) { matchingConfig = new List <MatchingConfig>(); } else if (matchingConfig.Count > 0) { id = matchingConfig[matchingConfig.Count - 1].ID + 1; } Model.MatchingConfig m_matchingConfig = new Model.MatchingConfig(id, m_RoiData[0].Name, true, m_RoiData, m_CreatModelParameter, m_FindModelParameter); matchingConfig.Add(m_matchingConfig); rct = creatShapeModel(image, m_RoiData[0], m_CreatModelParameter, out modelID); } else { rct = false; modelID = null; } return(rct); }
public static bool creatShapeModel(HObject image, List <ViewWindow.Model.ROI> regions, ref List <Model.MatchingConfig> matchingConfig, out HTuple modleID) { bool m_flag = false; HObject ho_TemplateImage; HObject ho_RoiUnion; HOperatorSet.GenEmptyRegion(out ho_TemplateImage); HOperatorSet.GenEmptyRegion(out ho_RoiUnion); ho_TemplateImage.Dispose(); modleID = new HTuple(); List <ViewWindow.Model.RoiData> m_RoiData; try { creatModelRoi(regions, out m_RoiData, out ho_RoiUnion); int id = 0; if (matchingConfig == null) { matchingConfig = new List <MatchingConfig>(); } if (matchingConfig.Count == 0) { List <Model.CreatModelParameter> m_CreatModelParameter = new List <Model.CreatModelParameter>(); Model.CreatModelParameter m_CreatModel = new Model.CreatModelParameter(1, 0.0, 360.0, 3); m_CreatModelParameter.Add(m_CreatModel); List <Model.FindModelParameter> m_FindModelParameter = new List <Model.FindModelParameter>(); Model.FindModelParameter m_FindModel = new Model.FindModelParameter(1, 0.0, 360.0, 0.75, 1, 0.75, 3); m_FindModelParameter.Add(m_FindModel); Model.MatchingConfig m_matchingConfig = new Model.MatchingConfig(id, m_RoiData[0].Name, true, m_RoiData, m_CreatModelParameter, m_FindModelParameter); matchingConfig.Add(m_matchingConfig); } HOperatorSet.ReduceDomain(image, ho_RoiUnion, out ho_TemplateImage); //HObject ho_imagepart; //HOperatorSet.GenEmptyObj(out ho_imagepart); //ho_imagepart.Dispose(); //HOperatorSet.CropDomain(ho_TemplateImage, out ho_imagepart); //HOperatorSet.WriteRegion(ho_RoiUnion, "d:\\123.reg"); //HOperatorSet.WriteImage(ho_imagepart, "bmp", 0, "d:\\123.bmp"); HOperatorSet.CreateShapeModel(ho_TemplateImage, matchingConfig[0].CreatModelParameter[0].NumLevels, matchingConfig[0].CreatModelParameter[0].AngleStart, matchingConfig[0].CreatModelParameter[0].AngleExtent, "auto", "auto", "use_polarity", "auto", "auto", out modleID); m_flag = true; ho_RoiUnion.Dispose(); } catch (Exception) { m_flag = false; modleID = null; ho_TemplateImage.Dispose(); ho_RoiUnion.Dispose(); } return(m_flag); }