Ejemplo n.º 1
0
        public override List <Cloth> Search()
        {
            PicParam picParam = (PicParam)param;

            List <Cloth> clothes = null;

            if (wrappedSearcher != null)
            {
                clothes = wrappedSearcher.Search();
            }
            else if (clothDao != null)
            {
                if (picParam.ClothNum > 0)
                {
                    clothes = clothDao.FindByClothNum(picParam.ClothNum);
                }
                else
                {
                    clothes = clothDao.FindAll();
                }
            }

            if (null == clothes)
            {
                throw new NullReferenceException("Both wrappedSearcher and clothDao are null, or some error happened.");
            }

            float[] featureVector = picParam.Feature;
            SortedDictionary <float, List <Cloth> > sortClothes = new SortedDictionary <float, List <Cloth> >();

            foreach (Cloth cloth in clothes)
            {
                float md = calcDist(featureVector, GetVector(cloth));
                if (md <= limit)
                {
                    if (!sortClothes.ContainsKey(md))
                    {
                        sortClothes[md] = new List <Cloth>();
                    }
                    sortClothes[md].Add(cloth);
                }
            }

            List <Cloth> resultClothes = new List <Cloth>();

            foreach (List <Cloth> cs in sortClothes.Values)
            {
                resultClothes.AddRange(cs);
            }

            if (resultClothes.Count > MaxResult)
            {
                return(resultClothes.GetRange(0, MaxResult));
            }

            return(resultClothes);
        }
Ejemplo n.º 2
0
 public ColorSearcher(PicParam picParam, float limit, DelCalcDist calcDist, IClothDao clothDao, int maxResult)
     : base(picParam, limit, calcDist, clothDao, maxResult)
 {
 }
Ejemplo n.º 3
0
 public ColorSearcher(PicParam picParam, float limit, DelCalcDist calcDist, IBaseSearcher wrappedSearcher, int maxResult)
     : base(picParam, limit, calcDist, wrappedSearcher, maxResult)
 {
 }
Ejemplo n.º 4
0
 public CooccurrenceSearcher(PicParam picParam, float limit, IClothDao clothDao, int maxResult)
     : this(picParam, limit, ClothUtil.CalcManhattanDistance, clothDao, maxResult)
 {
 }
Ejemplo n.º 5
0
 public CooccurrenceSearcher(PicParam picParam, float limit, IBaseSearcher wrappedSearcher, int maxResult)
     : this(picParam, limit, ClothUtil.CalcManhattanDistance, wrappedSearcher, maxResult)
 {
 }
Ejemplo n.º 6
0
 public GaborSearcher(PicParam picParam, float limit, IClothDao clothDao, int maxResult)
     : this(picParam, limit, ClothUtil.CalcGaborDistance, clothDao, maxResult)
 {
 }
Ejemplo n.º 7
0
 public GaborSearcher(PicParam picParam, float limit, IBaseSearcher wrappedSearcher, int maxResult)
     : this(picParam, limit, ClothUtil.CalcGaborDistance, wrappedSearcher, maxResult)
 {
 }
 public DaubechiesWaveletSearcher(PicParam picParam, float limit, DelCalcDist calcDist, IClothDao clothDao, int maxResult)
     : base(picParam, limit, calcDist, clothDao, maxResult)
 {
 }
 public DaubechiesWaveletSearcher(PicParam picParam, float limit, IClothDao clothDao, int maxResult)
     : this(picParam, limit, ClothUtil.CalcManhattanDistance, clothDao, maxResult)
 {
 }
 public DaubechiesWaveletSearcher(PicParam picParam, float limit, DelCalcDist calcDist, IBaseSearcher wrappedSearcher, int maxResult)
     : base(picParam, limit, calcDist, wrappedSearcher, maxResult)
 {
 }
 public DaubechiesWaveletSearcher(PicParam picParam, float limit, IBaseSearcher wrappedSearcher, int maxResult)
     : this(picParam, limit, ClothUtil.CalcManhattanDistance, wrappedSearcher, maxResult)
 {
 }
Ejemplo n.º 12
0
 public PicSearcher(PicParam picParam, float limit, DelCalcDist calcDist, IClothDao clothDao, int maxResult)
     : base(picParam, clothDao, maxResult)
 {
     this.limit    = limit;
     this.calcDist = calcDist;
 }
Ejemplo n.º 13
0
 public PicSearcher(PicParam picParam, float limit, DelCalcDist calcDist, IBaseSearcher wrappedSearcher, int maxResult)
     : base(picParam, wrappedSearcher, maxResult)
 {
     this.limit    = limit;
     this.calcDist = calcDist;
 }