Ejemplo n.º 1
0
        /// <summary>
        /// Loads model from the file specified by <c>fileName</c>
        /// </summary>
        public bool loadShapeModel(string fileName)
        {
            onExternalModelID = false;

            try
            {
                ModelID.ReadShapeModel(fileName);
            }
            catch (HOperatorException e)
            {
                exceptionText = e.Message;
                NotifyIconObserver(MatchingAssistant.ERR_READ_SHAPEMODEL);
                return(false);
            }

            onExternalModelID = true;
            tResult.mContour  = ModelID.GetShapeModelContours(1);

            cacheModelParams();

            parameterSet.mNumLevel = ModelID.GetShapeModelParams(out parameterSet.mStartingAngle,
                                                                 out parameterSet.mAngleExtent,
                                                                 out parameterSet.mAngleStep,
                                                                 out parameterSet.mMinScale,
                                                                 out parameterSet.mMaxScale,
                                                                 out parameterSet.mScaleStep,
                                                                 out parameterSet.mMetric,
                                                                 out parameterSet.mMinContrast);
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads model from the file specified by <c>fileName</c>
        /// </summary>
        public bool loadShapeModel(string fileName)
        {
            onExternalModelID = false;
            Stopwatch sw = new Stopwatch();

            sw.Start();
            string str = "loadShapeModel ";

            try
            {
                string shapeName = fileName + "ShapeImage.shm";
                if (FileLib.FileEx.Exist(shapeName, false))
                {
                    ModelID.ReadShapeModel(shapeName);
                    onExternalModelID = true;
                }
                else
                {
                    Logger.PopError(shapeName + "Îļþ²»´æÔÚ");
                }

                str += shapeName + " ºÄʱ:" + sw.ElapsedMilliseconds + "ms£¬"; sw.Restart();
                string grayName = fileName + "GrayImage.shm";
                //if (FileLib.FileEx.Exist(grayName, false))
                //{
                //     GrayTemplate.ReadTemplate(grayName);
                //}
                //else
                //{
                //    Logger.PopError(grayName + "Îļþ²»´æÔÚ");
                //}
                str += shapeName + " ºÄʱ:" + sw.ElapsedMilliseconds + "ms£¬";
                //Console.WriteLine(str);
            }
            catch (HOperatorException e)
            {
                exceptionText = e.Message;
                NotifyIconObserver(MatchingAssistant.ERR_READ_SHAPEMODEL);
                return(false);
            }

            if (onExternalModelID)
            {
                tResult.mContour = ModelID.GetShapeModelContours(1);

                cacheModelParams();

                parameterSet.mNumLevel = ModelID.GetShapeModelParams(out parameterSet.mStartingAngle,
                                                                     out parameterSet.mAngleExtent,
                                                                     out parameterSet.mAngleStep,
                                                                     out parameterSet.mMinScale,
                                                                     out parameterSet.mMaxScale,
                                                                     out parameterSet.mScaleStep,
                                                                     out parameterSet.mMetric,
                                                                     out parameterSet.mMinContrast);
            }

            return(onExternalModelID);
        }
Ejemplo n.º 3
0
        private HShapeModel ReadModelFromFile(string toolName)
        {
            HShapeModel model = new HShapeModel();;

            try
            {
                if (File.Exists(@".//ModelMatchFile/" + toolName + ".shm"))
                {
                    model.ReadShapeModel(@".//ModelMatchFile/" + info.ToolName + ".shm");
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                WriteErrorLog("VisionTool", "模板读取失败");
            }
            return(model);
        }