Exemplo n.º 1
0
        /// <summary>
        /// 查找模板
        /// </summary>
        /// <param name="numfind"> 要查找模板的个数</param>
        /// <returns></returns>
        public List <ModleFindResult> FindMuiltple(uint numfind)
        {
            List <ModleFindResult> resultlist = new List <ModleFindResult>();

            if (m_modleHandle != null)
            {
                try
                {
                    HTuple _column = new HTuple(), _angle = new HTuple(), _score = new HTuple();

                    HOperatorSet.FindShapeModel(m_image, m_modleHandle, m_paramFind.AngleStart, m_paramFind.AngleExtent, m_paramFind.MinScore,
                                                numfind, m_paramFind.MaxOverLap, m_paramFind.SubPixel, m_paramFind.NumLevels, m_paramFind.Greediness, out HTuple _row, out _column, out _angle, out _score);

                    if (_row.TupleLength() > 0)
                    {
                        for (int i = 0; i < _row.Length; i++)
                        {
                            HObject _modlecountor = new HObject();
                            HOperatorSet.GetShapeModelContours(out _modlecountor, m_modleHandle, 1);
                            HTuple _hommat2d;
                            HOperatorSet.VectorAngleToRigid(0, 0, 0, _row.DArr[i], _column.DArr[i], _angle.DArr[i], out _hommat2d);
                            HObject _transcountor;
                            HOperatorSet.AffineTransContourXld(_modlecountor, out _transcountor, _hommat2d);
                            ModleFindResult result = new ModleFindResult();
                            result.Row         = _row.DArr[i];
                            result.Column      = _column.DArr[i];
                            result.Score       = _score.DArr[i];
                            result.Angle       = _angle.DArr[i];
                            result.ModleRegion = _modlecountor;
                            resultlist.Add(result);
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(resultlist);
        }
Exemplo n.º 2
0
        public ModleFindResult FindSimple()
        {
            ModleFindResult result = new ModleFindResult();

            if (m_modleHandle != null)
            {
                try
                {
                    HTuple _column = new HTuple(), _angle = new HTuple(), _score = new HTuple();

                    HOperatorSet.FindShapeModel(m_image, m_modleHandle, m_paramFind.AngleStart, m_paramFind.AngleExtent, m_paramFind.MinScore,
                                                1, m_paramFind.MaxOverLap, m_paramFind.SubPixel, m_paramFind.NumLevels, m_paramFind.Greediness, out HTuple _row, out _column, out _angle, out _score);

                    if (_row.TupleLength() > 0)
                    {
                        HObject _modlecountor = new HObject();
                        HOperatorSet.GetShapeModelContours(out _modlecountor, m_modleHandle, 1);
                        HTuple _hommat2d;
                        HOperatorSet.VectorAngleToRigid(0, 0, 0, _row.D, _column.D, _angle.D, out _hommat2d);
                        HObject _transcountor;
                        HOperatorSet.AffineTransContourXld(_modlecountor, out _transcountor, _hommat2d);
                        result.Row         = _row.D;
                        result.Column      = _column.D;
                        result.Score       = _score.D;
                        result.Angle       = _angle.D;
                        result.ModleRegion = _modlecountor;
                        return(result);
                    }
                    else
                    {
                        return(null);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(result);
        }