/// <summary> /// OCR related processing entry point /// </summary> private static void GetPrices() { try { if (_primeParts == null || !_primeParts.Any()) { throw new Exception("There is no file containing prime parts prices. Please get the prices from listings first"); } ConcurrentBag <PrimePart> foundPrimeParts = new ConcurrentBag <PrimePart>(); if (!string.IsNullOrEmpty(Settings.TestImageName) || (SetForegroundWindow(_process.MainWindowHandle) && GetWindowRect(_process.MainWindowHandle, out RECT location))) { List <string> newImages = new List <string>(); string imageName = Guid.NewGuid().ToString(); string imagePath; if (!string.IsNullOrEmpty(Settings.TestImageName)) { imagePath = Path.Combine(ImagesPath, Settings.TestImageName); } else { imagePath = Path.Combine(ImagesPath, $"{imageName}.tiff"); ScreenCapture.CaptureScreenToFile(imagePath, System.Drawing.Imaging.ImageFormat.Tiff); } Bitmap initialImage = new Bitmap(imagePath); newImages.AddRange(CreateProcessedImages( imageName, _numberOfPlayers, initialImage, new List <Func <Bitmap, Bitmap> > { ImageProcessor.InvertColors })); newImages.AddRange(CreateProcessedImages( imageName, _numberOfPlayers, initialImage, new List <Func <Bitmap, Bitmap> > { ImageProcessor.Sharpen, ImageProcessor.InvertColors })); newImages.AddRange(CreateProcessedImages( imageName, _numberOfPlayers, initialImage, new List <Func <Bitmap, Bitmap> > { ImageProcessor.PrimePartImageCustomProcess, ImageProcessor.Sharpen })); DoOCRAndProcessFoundText(_ocrEngine, foundPrimeParts, newImages); if (foundPrimeParts.Count == 0) { Console.WriteLine("No parts found"); return; } List <PrimePart> orderedPrimeParts = foundPrimeParts .Distinct(new PrimePart()) .OrderByDescending(primePart => primePart.PriceInPlat) .ThenByDescending(primePart => primePart.PriceInDucats).ToList(); if (string.IsNullOrEmpty(Settings.TestImageName)) { ShowFoundPartsInOverlay(orderedPrimeParts); } ShowFoundPartsInConsole(orderedPrimeParts); GeneralUtils.DeleteFiles(newImages); } else { throw new Exception("Can't bring Warframe's window in the foreground"); } } catch (Exception exception) { Console.WriteLine(exception.Message); } }