Example #1
0
        public void SaveDatabase()
        {
            string itemsToCategoryMapDatabasePath =
                Path.Combine(DATABASE_DIRECTORY_NAME, ITEMS_TO_Category_MAP_NAME);

            SerializationMachine.SaveDictionaryIntoDB(itemsToCategoryMapDatabasePath, mItemToCategoryDictionary);
        }
        public void LoadDatabase()
        {
            string itemsToRecognizerTypeMapDatabasePath =
                Path.Combine(DATABASE_DIRECTORY_NAME, ITEMS_TO_RECOGNIZER_TYPE_MAP_NAME);

            mItemToRecognizerTypeDictionary = SerializationMachine.LoadDictionaryFromDB <IItemInfo, string>(itemsToRecognizerTypeMapDatabasePath);
        }
Example #3
0
        public void LoadDatabase()
        {
            string itemsToCategoryMapDatabasePath =
                Path.Combine(DATABASE_DIRECTORY_NAME, ITEMS_TO_Category_MAP_NAME);

            mItemToCategoryDictionary = SerializationMachine.LoadDictionaryFromDB <IItemInfo, string>(itemsToCategoryMapDatabasePath);
        }
Example #4
0
        public void LoadDatabases()
        {
            string itemsToRecognizerTypeMapDatabasePath =
                Path.Combine(mDatabaseDirectoryName, ITEMS_TO_RECOGNIZER_TYPE_MAP_NAME);

            mItemToRecognizerTypeDictionary = SerializationMachine.
                                              LoadDictionaryFromDB <IItemInfo, ItemRecognizeData>(itemsToRecognizerTypeMapDatabasePath);
        }
        private void LoadDatabases()
        {
            // Saves items.
            mItemsDictionary = SerializationMachine.LoadDictionaryFromDB <string, IItemInfo>(mItemsDBPath);

            // Load ItemToRecognizerDataMap.
            ItemToRecognizeDataMap.LoadDatabases();
        }
Example #6
0
        public void LoadDatabase()
        {
            string itemsDatabasePath = Path.Combine(DATABASE_DIRECTORY_NAME, ITEMS_DATA_BASE_NAME);

            mMicrowaveItemsDictionary = SerializationMachine.LoadDictionaryFromDB <string, IItemInfo>(itemsDatabasePath);
            mItemToCategoryMap.LoadDatabase();
            ItemToRecognizerTypeMap.LoadDatabase();
        }
        private void SaveDatabases(IItemInfo itemInfo, string recognitionType, string category)
        {
            string databaseCategoryDirectory = Path.Combine(mDatabaseDirectoryPath, recognitionType, category);

            Directory.CreateDirectory(databaseCategoryDirectory);

            ItemToRecognizeDataMap.Add(itemInfo, recognitionType, category);
            ItemToRecognizeDataMap.SaveDatabases();

            SerializationMachine.SaveDictionaryIntoDB(mItemsDBPath, mItemsDictionary);
        }
Example #8
0
        private void SaveFingerPrintsInMemory(
            List <HashedFingerprint> newHashedFingerprints,
            ModelReference <int> trackReference,
            string name)
        {
            FilePath fingerPrintsDBFilePath =
                FilePath.CreateFilePath(Path.Combine(mDatabaseDirectoryPath, RecognizerType, DatabaseCategory, $"{name}{FINGERPRINT_EXTENSION}"));
            FilePath trackRefernceFilePath =
                FilePath.CreateFilePath(Path.Combine(mDatabaseDirectoryPath, RecognizerType, DatabaseCategory, $"{name}{TRACK_REFERENCE_EXTENSION}"));

            SerializationMachine.ProtoSerialize(newHashedFingerprints, fingerPrintsDBFilePath);
            SerializationMachine.ProtoSerialize(trackReference, trackRefernceFilePath);
        }
        private static void SaveFingerPrintsInMemory(
            List <HashedFingerprint> newHashedFingerprints,
            IModelReference trackReference,
            string name)
        {
            FilePath fingerPrintsDBFilePath =
                FilePath.CreateFilePath(Path.Combine(DATABASE_DIRECTORY_NAME, $"{name}{FINGEPRINT_EXTENSION}"));
            FilePath trackRefernceFilePath =
                FilePath.CreateFilePath(Path.Combine(DATABASE_DIRECTORY_NAME, $"{name}{TRACK_REFERENCE_EXTENSION}"));

            SerializationMachine.ProtoSerialize(newHashedFingerprints, fingerPrintsDBFilePath);
            SerializationMachine.ProtoSerialize(trackReference, trackRefernceFilePath);
        }
        public static void LoadFingerPrintsDataBase(string databaseCategory)
        {
            // Search for all files with given extensios in given directory.
            string databaseDirectoryPath = Path.Combine(DATABASE_DIRECTORY_NAME, databaseCategory);

            try
            {
                string[] files = Directory.GetFiles(databaseDirectoryPath, $"*{FINGEPRINT_EXTENSION}");
                foreach (string fingerPrintFile in files)
                {
                    List <HashedFingerprint> hashedFingerprints =
                        SerializationMachine.ProtoDeserialize <List <HashedFingerprint> >(
                            FilePath.CreateFilePath(fingerPrintFile));

                    string trackReferenceFile = fingerPrintFile.Replace(FINGEPRINT_EXTENSION, TRACK_REFERENCE_EXTENSION);
                    if (File.Exists(trackReferenceFile))
                    {
                        IModelReference trackReference =
                            SerializationMachine.ProtoDeserialize <IModelReference>(
                                FilePath.CreateFilePath(trackReferenceFile));

                        if (hashedFingerprints != null && trackReference != null)
                        {
                            mModelService.InsertHashDataForTrack(hashedFingerprints, trackReference);
                            Console.WriteLine($"Loaded fingerprint of track reference ID: {trackReference.Id}");
                        }
                        else
                        {
                            Console.WriteLine($"Cannot load fingerprint {fingerPrintFile}");
                        }
                    }
                    else
                    {
                        Console.WriteLine($"Error! the track reference file of {fingerPrintFile} is missing");
                    }
                }
            }
            catch (ArgumentException e)
            {
                Console.WriteLine($"Argument Exception occures: {e.Message}");
            }
            catch (DirectoryNotFoundException)
            {
                Console.WriteLine($"No such directory: {databaseDirectoryPath}");
            }
        }
Example #11
0
        /// <summary>
        /// Search for all files with given extensios in given directory.
        /// </summary>
        /// <param name="waveFile"></param>
        public void LoadFingerPrintsDatabase()
        {
            try
            {
                string[] files = Directory.GetFiles(mDatabaseDirectoryPath, $"*{FINGERPRINT_EXTENSION}");
                foreach (string fingerPrintFile in files)
                {
                    List <HashedFingerprint> hashedFingerprints =
                        SerializationMachine.ProtoDeserialize <List <HashedFingerprint> >(
                            FilePath.CreateFilePath(fingerPrintFile));

                    string trackReferenceFile = fingerPrintFile.Replace(FINGERPRINT_EXTENSION, TRACK_REFERENCE_EXTENSION);
                    if (File.Exists(trackReferenceFile))
                    {
                        ModelReference <int> trackReference = SerializationMachine.ProtoDeserialize <ModelReference <int> >(
                            FilePath.CreateFilePath(trackReferenceFile));

                        if (hashedFingerprints != null && trackReference != null)
                        {
                            mModelService.InsertHashDataForTrack(hashedFingerprints, trackReference);
                            mLogger.WriteLine($"Loaded fingerprint of track reference ID: {trackReference.Id}");
                        }
                        else
                        {
                            mLogger.WriteLine($"Cannot load fingerprint {fingerPrintFile}");
                        }
                    }
                    else
                    {
                        mLogger.WriteError($"Error! the track reference file of {fingerPrintFile} is missing");
                    }
                }
            }
            catch (DirectoryNotFoundException)
            {
                mLogger.WriteError($"No such directory: {mDatabaseDirectoryPath}");
            }
            catch (Exception ex) when(ex is ArgumentException || ex is NullReferenceException)
            {
                mLogger.WriteError($"Exception occures: {ex.Message}", ex);
            }
        }
        public void SaveDatabase()
        {
            string itemsToRecognizerTypeDatabasePath = Path.Combine(DATABASE_DIRECTORY_NAME, ITEMS_TO_RECOGNIZER_TYPE_MAP_NAME);

            SerializationMachine.SaveDictionaryIntoDB(itemsToRecognizerTypeDatabasePath, mItemToRecognizerTypeDictionary);
        }
Example #13
0
        public void SaveDatabases()
        {
            string itemsToRecognizerTypeDatabasePath = Path.Combine(mDatabaseDirectoryName, ITEMS_TO_RECOGNIZER_TYPE_MAP_NAME);

            SerializationMachine.SaveDictionaryIntoDB(itemsToRecognizerTypeDatabasePath, mItemToRecognizerTypeDictionary);
        }
Example #14
0
        public void SaveDatabase()
        {
            string itemsDatabasePath = Path.Combine(DATABASE_DIRECTORY_NAME, ITEMS_DATA_BASE_NAME);

            SerializationMachine.SaveDictionaryIntoDB(itemsDatabasePath, mMicrowaveItemsDictionary);
        }