public IdTranslator(string pathToCsv) { _dataPath = pathToCsv; _dataReader = new CsvReader(new StreamReader(_dataPath)); _translatorDict = new Dictionary <string, CsvDataNode>(); while (_dataReader.Read()) { CsvDataNode newRecord = _dataReader.GetRecord <CsvDataNode>(); // Debug.WriteLine("New Record: " + newRecord.code + " " + newRecord.name); _translatorDict[newRecord.code] = newRecord; // THIS SHOULD THROW IF THERE IS A NULL CODE } // load in the CSV }
public List <ScanInfo> ScanImages(string sourcePath) // take every sourcePath and pair it with the QR codes it came with { string[] myPaths = Directory.GetFiles(sourcePath); // this should filter for jpg, gif, bmp, and png List <ScanInfo> toReturn = new List <ScanInfo>(); foreach (string imagePath in myPaths) { Debug.WriteLine("ImageScanner begin: " + imagePath); ScanInfo newInfo = new ScanInfo(imagePath); Result currentResult = _myQrSingleReader.decode( new BinaryBitmap( new HybridBinarizer( new BitmapLuminanceSource( (Bitmap)Bitmap.FromFile(imagePath) ) ) ), _myHints); if (currentResult != null) { Debug.WriteLine("ImageScan raw: " + currentResult.Text); string[] splitString = currentResult.Text.Split(_stringDelimiter); if (splitString != null) { // translate these foreach (string currCode in splitString) { CsvDataNode translatedCode = _idParser.translateId(currCode); if (translatedCode != null) { newInfo.Properties[translatedCode.type] = translatedCode.name; // this should never be null } } } else { Debug.WriteLine("ImageScanner invalid raw"); } } else { Debug.WriteLine("ImageScan null scan"); } toReturn.Add(newInfo); } return(toReturn); }