Exemplo n.º 1
0
        private static Descriptor[] LoadArrayDescriptors(string descriptorFile, string clusteringFile)
        {
            List <int> idsToExtract = new List <int>();

            using (StreamReader reader = new StreamReader(clusteringFile))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    string[] tokens       = line.Split(':');
                    int      clusterId    = int.Parse(tokens[0]);
                    int      descriptorId = int.Parse(tokens[1]);
                    string   descriptors  = tokens[2];

                    idsToExtract.Add(descriptorId);
                }
            }

            using (FeatureReader featureReader = new FeatureReader(descriptorFile, true))
            {
                Console.WriteLine("Loading {0} descriptors ({1} dimensions).", idsToExtract.Count, featureReader.FeatureDimension);
                Descriptor[] descriptors = new Descriptor[idsToExtract.Count];
                for (int i = 0; i < idsToExtract.Count; i++)
                {
                    float[] features = featureReader.GetFeatures(idsToExtract[i]);    // TODO: optimize
                    descriptors[i] = new Descriptor(idsToExtract[i], features);
                }
                return(descriptors);
            }
        }
Exemplo n.º 2
0
 private static Descriptor[] LoadArrayDescriptors(string descriptorFile)
 {
     using (FeatureReader featureReader = new FeatureReader(descriptorFile))
     {
         Console.WriteLine("Loading {0} descriptors ({1} dimensions).", featureReader.FeatureCount, featureReader.FeatureDimension);
         Descriptor[] descriptors = new Descriptor[featureReader.FeatureCount];
         for (int i = 0; i < featureReader.FeatureCount; i++)
         {
             float[] features = featureReader.GetFeatures(i);    // TODO: optimize
             descriptors[i] = new Descriptor(i, features);
         }
         return(descriptors);
     }
 }