Пример #1
0
        public void SetOutTime(int outtime)
        {
            if (outtime <= 0)
            {
                OutTime       = 0;
                TimeOutEnable = false;
            }
            else
            {
                OutTime       = outtime;
                TimeOutEnable = true;
            }

            if (shapeModel != null && shapeModel.IsInitialized())
            {
                if (TimeOutEnable)
                {
                    shapeModel.SetShapeModelParam("timeout", OutTime);
                }
                else
                {
                    shapeModel.SetShapeModelParam("timeout", "false");
                }
            }
        }
Пример #2
0
        public bool CreateModel()
        {
            try
            {
                if (ModelRegion == null || ModelRegion.IsInitialized() == false)
                {
                    return(false);
                }

                HImage modelImage = ModelImg.ReduceDomain(ModelRegion);

                HTuple contrast = "auto";
                if (!shapeParam.IsAuto(ShapeParam.AUTO_CONTRAST))
                {
                    contrast = shapeParam.mContrast;
                }

                HShapeModel model = new HShapeModel(modelImage,
                                                    (HTuple)shapeParam.mNumLevel,
                                                    (HTuple)shapeParam.mStartingAngle,
                                                    (HTuple)shapeParam.mAngleExtent,
                                                    (HTuple)shapeParam.mAngleStep,
                                                    (HTuple)shapeParam.mMinScale,
                                                    (HTuple)shapeParam.mMaxScale,
                                                    (HTuple)shapeParam.mScaleStep,
                                                    (HTuple)shapeParam.mOptimization,
                                                    (HTuple)shapeParam.mMetric,
                                                    (HTuple)contrast,
                                                    (HTuple)shapeParam.mMinContrast);
                modelImage.Dispose();

                if (shapeModel != null)
                {
                    shapeModel.Dispose();
                    shapeModel = null;
                }
                shapeModel = model;
                SetModelOrigin(ModelImgRow, ModelImgCol);

                if (TimeOutEnable)
                {
                    shapeModel.SetShapeModelParam("timeout", OutTime);
                }

                createNewModelID = false;
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #3
0
        public HXLDCont FindShapeModel(HImage img,
                                       HShapeModel model,
                                       FindModelParameter findModelParameter,
                                       out HTuple row,
                                       out HTuple column,
                                       out HTuple angle,
                                       out HTuple scale,
                                       out HTuple score)
        {
            var t1 = HSystem.CountSeconds();

            model.SetShapeModelParam("timeout", 10000);
            try
            {
                img.FindScaledShapeModel(
                    model,
                    findModelParameter.angleStart,
                    findModelParameter.angleExtent,
                    findModelParameter.scaleMin,
                    findModelParameter.scaleMax,
                    findModelParameter.minScore,
                    findModelParameter.numMatches,
                    findModelParameter.maxOverlap,
                    findModelParameter.subPixel,
                    findModelParameter.numLevels,
                    findModelParameter.greediness,
                    out row,
                    out column,
                    out angle,
                    out scale,
                    out score);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                row                   =
                    column            =
                        angle         =
                            scale     =
                                score = new HTuple();
            }

            var t2    = HSystem.CountSeconds();
            var mTime = 1000.0 * (t2 - t1);

            System.Diagnostics.Debug.WriteLine(mTime.ToString());

            var modelContours = Model.GetShapeModelContours(1);
            var homMat2D      = new HHomMat2D();

            //HTuple Width, Height;
            //Img.GetImageSize(out Width, out Height);

            if (score.Length <= 0)
            {
                return(null);
            }
            homMat2D.VectorAngleToRigid(0, 0, 0, row, column, angle);

            var contoursAffinTrans = modelContours.AffineTransContourXld(homMat2D);

            return(contoursAffinTrans);
        }