Ejemplo n.º 1
0
        /// <summary>
        /// Creates and initializes a new <see cref="Tesseract"/> object.
        /// </summary>
        /// <param name="dataDirectory">The path to Tesseract data directory.</param>
        /// <returns>
        /// The <see cref="Tesseract"/> object this method creates.
        /// </returns>
        public static Tesseract Create(string dataDirectory)
        {
            if (string.IsNullOrEmpty(dataDirectory))
            {
                dataDirectory = Globals.LookupDataDirectory("Tesseract");
            }

            // ensure the data directory exist
            if (!Directory.Exists(dataDirectory))
            {
                throw new DirectoryNotFoundException(
                          string.Format(
                              CultureInfo.InvariantCulture,
                              Genix.Core.Properties.Resources.E_DirectoryNotFound,
                              dataDirectory));
            }

            TesseractHandle handle = NativeMethods.TessBaseAPICreate();

            try
            {
                if (NativeMethods.TessBaseAPIInit2(handle, dataDirectory, "eng", OcrEngineMode.LstmOnly) != 0)
                {
                    throw new InvalidOperationException("Cannot initialize Tesseract engine.");
                }
            }
            catch
            {
                handle?.Dispose();
                throw;
            }

            return(new Tesseract(handle));
        }
Ejemplo n.º 2
0
 public static extern int TessBaseAPIRecognize(TesseractHandle handle, IntPtr monitor);
Ejemplo n.º 3
0
 public static extern PageIterator TessBaseAPIAnalyseLayout(TesseractHandle handle);
Ejemplo n.º 4
0
 public static extern void TessBaseAPISetPageSegMode(TesseractHandle handle, PageSegmentationMode mode);
Ejemplo n.º 5
0
 public static extern void TessBaseAPISetImage2(TesseractHandle handle, SafeHandle pix);
Ejemplo n.º 6
0
 public static extern void TessBaseAPIClearPersistentCache(TesseractHandle handle);
Ejemplo n.º 7
0
 public static extern void TessBaseAPIClearAdaptiveClassifier(TesseractHandle handle);
Ejemplo n.º 8
0
 public static extern void TessBaseAPIClear(TesseractHandle handle);
Ejemplo n.º 9
0
 public static extern int TessBaseAPIInit3(
     TesseractHandle handle,
     [MarshalAs(UnmanagedType.LPStr)] string datapath,
     [MarshalAs(UnmanagedType.LPStr)] string language);
Ejemplo n.º 10
0
 public static extern int TessBaseAPIInit2(
     TesseractHandle handle,
     [MarshalAs(UnmanagedType.LPStr)] string datapath,
     [MarshalAs(UnmanagedType.LPStr)] string language,
     OcrEngineMode oem);
Ejemplo n.º 11
0
 public static extern ResultIterator TessBaseAPIGetIterator(TesseractHandle handle);
Ejemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Tesseract"/> class.
 /// </summary>
 /// <param name="handle">The pointer to native Tesseract object.</param>
 private Tesseract(TesseractHandle handle)
 {
     this.handle = handle;
 }