//------------------------------------------------------------------------- public int GetFrames() { Result.Audit.MadeArchiveAudit(defaults.ArchiveFolder);//сделали аудит файл для архива FramesAndBitmap fab = new FramesAndBitmap(); fab.GetFrames(Result.FileName, Result.Audit);//разбило на фреймы (выделило странички по отдельным файлам в темпфрейм фолдер if (fab.Exception != null) { log.LogMessage(fab.Exception); //utils.MoveBadFile(OcrAppConfig.TempFolder, defaults.ManualNextProccessingFolder, Result.FileName, Result.Audit, fab.Exception.Message);//сохраняем файл в папку для дальнейшей обработки и удаляем из ТЕМПА //log.LogMessage("File " + Path.GetFileName(Result.FileName) + " was moved to '" + defaults.ManualNextProccessingFolder + "'"); utils.MoveBadFile(OcrAppConfig.TempFolder, defaults.ErrorFolder, Result.FileName, Result.Audit, fab.Exception.Message);//сохраняем файл в папку для дальнейшей обработки и удаляем из ТЕМПА log.LogMessage("File " + Path.GetFileName(Result.FileName) + " was moved to '" + defaults.ErrorFolder + "'"); } else { utils.MoveFileFromTemp(OcrAppConfig.TempFolder, Result.FileName, Result.Audit, Result.Audit.archiveFileName); //сохраняем файл в архив и удаляем из ТЕМПА } return fab.PageCount; }
//------------------------------------------------------------------------- private void OpenFileMainMenuItem_Click(object sender, EventArgs e) { log.LogMessage("OpenFile MainMenuItem Click"); openFileDialog1.Filter = OcrAppConfig.SupportedExtensions + "|" + OcrAppConfig.SupportedExtensions.Replace(",", ";"); if (openFileDialog1.ShowDialog() == DialogResult.OK) { FramesAndBitmap fab = new FramesAndBitmap(); fab.VerifyFileForMultipaging(openFileDialog1.FileName); if (fab.Exception != null) { UpdateUI("Exception", fab.Exception.Message); return; } string fileName = utils.GetFileForRecognize(openFileDialog1.FileName, OcrAppConfig.TempEdFolder); Working(fileName); } }
public Recognize(string fileName, OcrAppConfig defaults, CancellationToken token, bool auto = false , bool normalizeBitmap = true) { SetCancellationToken(token); this.Auto = auto; this.defaults = defaults; recTools.frameFileName = fileName; //defaults.frameFileName = fileName; if (String.IsNullOrEmpty(fileName) || !File.Exists(fileName)) { Exception = new Exception("File name is incorrect: " + fileName); log.LogMessage(Exception); NotifyUpdated(ExceptionEvent, Exception, null); return; } FileName = fileName; AuditFileName = utils.GetFileAuditName(fileName); #region Get Bitmap FramesAndBitmap fab = new FramesAndBitmap(); Bitmap = fab.GetBitmapFromFile(FileName); if (fab.Exception != null) { Exception = fab.Exception; log.LogMessage(Exception); NotifyUpdated(ExceptionEvent, Exception, null); return; } //bool bppIndexed1 = false; //if (Bitmap.PixelFormat == System.Drawing.Imaging.PixelFormat.Format1bppIndexed) // bppIndexed1 = true; if (normalizeBitmap) Bitmap = recTools.NormalizeBitmap(Bitmap, out exception); if (exception != null) { log.LogMessage(Exception); NotifyUpdated(ExceptionEvent, Exception, null); return; } //if (exception != null) //{ // if (auto) // { // fab.Exception = exception; // Audit = new Audit(AuditFileName, out exception); // exception = fab.Exception; // Audit.error = exception.Message; // if (defaults.MoveToNextProccessingFolderOnSheetIdentifierError) // { // utils.MoveBadFile(OcrAppConfig.TempFramesFolder, defaults.ManualNextProccessingFolder, fileName, Audit, fab.Exception.Message);//сохраняем файл в папку для дальнейшей обработки и удаляем из ТЕМПА // File.Delete(fileName); // } // else // { // } // return; // } //} //else if (exception != null) //{ //Bitmap = recTools.GetMonohromeNoIndexBitmap(Bitmap, false, true); //Bitmap.SetResolution(96, 96); #endregion #region Get audit file Audit = new Audit(AuditFileName, out exception); if (Audit == null || !File.Exists(AuditFileName)) { log.LogMessage(Exception); NotifyUpdated(ExceptionEvent, Exception, null); return; } #endregion regionsList = recTools.GetAllRegions(ConfigsFolder); regionsListFLEX = recTools.GetAllRegionsFLEX(ConfigsFolder); }