void ImageIndexing_Load(object sender, EventArgs e) { this.VisualWord = VisualWordHelper.CreateListVWKeys_Rgb(); }
public static void RunIndexing_RGB(string imageIndexStoragePath) { #region init List <Color> visualWordColor = ColorHelper.GenerateColorVisualWord_Rgb(); // * Dictionary <string, List <string> > visualWordMain = new Dictionary <String, List <string> >(); List <VisualWordCell_RGB> listKeys = VisualWordHelper.CreateListVWKeys_Rgb(); // * foreach (var item in listKeys) { // * String key = item.Color.R + "_" + item.Color.G + "_" + item.Color.B + "_" + item.XIndex + "_" + item.YIndex; visualWordMain.Add(key, new List <String>()); } string indexFileNameExtension = GetIndexFileNameExtension(); #endregion // for each folder int count = 0; string[] SubDirs = Directory.GetDirectories(ConfigCommon.PCT_OUTPUT_PATH); foreach (String folderPath in SubDirs) { Console.WriteLine((++count) + ". " + folderPath); FileInfo[] fileInfos = FileManager.GetInstance().GetAllFileInFolder(folderPath); int sizeFiles = fileInfos.Length; // for each X file (X = PCTConfig.PCT_STEP_INDEX_FILE) for (int i = 0; i < sizeFiles; i += ConfigPCT.PCT_STEP_INDEX_FILE) { // read data PCT from file PCTFeature_RGB dataPCT = PCTReadingFeature.ReadingFeatureFromFile_RGB(fileInfos[i].FullName); // * // if number of color visual-word > Y, skip (Y = PCTConfig.COLOR_NOISE_THRESHOLD) int numberColor = CountColorsVW_RGB(dataPCT, visualWordColor); if (numberColor > ConfigPCT.COLOR_NOISE_THRESHOLD) { continue; } foreach (Dot_RGB colorPoint in dataPCT.ListColorPoint) { // if radius >= Z, index it (Z = PCTConfig.RADIUS_THRESHOLD) if (colorPoint.radius >= ConfigPCT.RADIUS_THRESHOLD) { List <RegionOfFrame> listRegionDotBelongTo = Utils.RegionOfFrameHelper.GetListRegionDotBelongTo(colorPoint.location, colorPoint.radius, dataPCT.Width, dataPCT.Height); Color color = visualWordColor[DistanceHelper.ColorKNN_RGB(colorPoint.color, visualWordColor)]; foreach (RegionOfFrame region in listRegionDotBelongTo) { String key = color.R + "_" + color.G + "_" + color.B + "_" + region.X + "_" + region.Y; visualWordMain[key].Add(dataPCT.FrameName); } } } } } foreach (var item in listKeys) { string key = item.Color.R + "_" + item.Color.G + "_" + item.Color.B + "_" + item.XIndex + "_" + item.YIndex; visualWordMain[key] = visualWordMain[key].Distinct().ToList(); } // save the indexing to a file //String json = JsonConvert.SerializeObject(visualWordMain); //FileManager.GetInstance().WriteFile(json, Path.Combine(imageIndexStoragePath, "index.json")); string fileSavePath = Path.Combine(imageIndexStoragePath, indexFileNameExtension); if (File.Exists(fileSavePath)) { File.Delete(fileSavePath); } FileManager.GetInstance().WriteDicIndexingToFiles(visualWordMain, fileSavePath); }