/// <summary> /// Creates the shape-based model. If the region of interest /// <c>mROIModel</c> is missing or not well defined using the /// interactive ROIs, then an error message is returned. /// </summary> public bool createShapeModel(string filePath) { bool isSuccess = false; if (mReducedImage == null) { if (!onTimer) { NotifyIconObserver(MatchingAssistant.ERR_NO_MODEL_DEFINED); } return(false); } try { parameterSet.mMetric = "ignore_local_polarity"; //parameterSet.mOptimization = "auto"; //parameterSet.mAngleStep = "auto"; mReducedImage.WriteImage("bmp", 0, filePath + "template.bmp"); if (ModelID != null) { ModelID.Dispose(); } ModelID = mReducedImage.CreateShapeModel( parameterSet.mNumLevel, parameterSet.mStartingAngle, parameterSet.mAngleExtent, 0.0175 / 10, "auto",//parameterSet.mOptimization, parameterSet.mMetric, "auto_contrast", "auto" ); if (GrayTemplate != null) { GrayTemplate.Dispose(); } GrayTemplate = mReducedImage.CreateTemplate(255, parameterSet.mNumLevel, "none", "original"); isSuccess = true; } catch (HOperatorException e) { isSuccess = false; if (!onTimer) { exceptionText = e.Message; NotifyParamObserver(MatchingParam.H_ERR_MESSAGE); } return(false); } if (tResult.mContour != null) { tResult.mContour.Dispose(); } tResult.mContour = ModelID.GetShapeModelContours(1); createNewModelID = false; return(isSuccess); }