public void SetPageSegmentationMode(PageSegmentationMode mode)
        {
            CheckIfInitialized();
            switch (mode)
            {
            case PageSegmentationMode.Auto:
                _api.SetPageSegMode(PageSegMode.Auto);
                break;

            case PageSegmentationMode.AutoOnly:
                _api.SetPageSegMode(PageSegMode.AutoOnly);
                break;

            case PageSegmentationMode.AutoOsd:
                _api.SetPageSegMode(PageSegMode.AutoOsd);
                break;

            case PageSegmentationMode.CircleWord:
                _api.SetPageSegMode(PageSegMode.CircleWord);
                break;

            case PageSegmentationMode.OsdOnly:
                _api.SetPageSegMode(PageSegMode.OsdOnly);
                break;

            case PageSegmentationMode.SingleBlock:
                _api.SetPageSegMode(PageSegMode.SingleBlock);
                break;

            case PageSegmentationMode.SingleBlockVertText:
                _api.SetPageSegMode(PageSegMode.SingleBlockVertText);
                break;

            case PageSegmentationMode.SingleChar:
                _api.SetPageSegMode(PageSegMode.SingleChar);
                break;

            case PageSegmentationMode.SingleColumn:
                _api.SetPageSegMode(PageSegMode.SingleColumn);
                break;

            case PageSegmentationMode.SingleLine:
                _api.SetPageSegMode(PageSegMode.Auto);
                break;

            case PageSegmentationMode.SingleWord:
                _api.SetPageSegMode(PageSegMode.SingleWord);
                break;

            case PageSegmentationMode.SparseText:
                _api.SetPageSegMode(PageSegMode.SparseText);
                break;

            case PageSegmentationMode.SparseTextOsd:
                _api.SetPageSegMode(PageSegMode.SparseTextOsd);
                break;
            }
        }
Beispiel #2
0
        static void example2()
        {
            string               dataPath = "./tessdata/";
            string               language = "eng";
            OcrEngineMode        oem      = OcrEngineMode.DEFAULT;
            PageSegmentationMode psm      = PageSegmentationMode.AUTO_OSD;

            TessBaseAPI tessBaseAPI = new TessBaseAPI(dataPath, language, oem, psm);
        }
        public void SetPageSegmentationMode(PageSegmentationMode mode)
        {
            switch (mode)
            {
            case PageSegmentationMode.Auto:
                _api.PageSegmentationMode = G8PageSegmentationMode.Auto;
                break;

            case PageSegmentationMode.AutoOnly:
                _api.PageSegmentationMode = G8PageSegmentationMode.AutoOnly;
                break;

            case PageSegmentationMode.AutoOsd:
                _api.PageSegmentationMode = G8PageSegmentationMode.AutoOSD;
                break;

            case PageSegmentationMode.CircleWord:
                _api.PageSegmentationMode = G8PageSegmentationMode.CircleWord;
                break;

            case PageSegmentationMode.OsdOnly:
                _api.PageSegmentationMode = G8PageSegmentationMode.OSDOnly;
                break;

            case PageSegmentationMode.SingleBlock:
                _api.PageSegmentationMode = G8PageSegmentationMode.SingleBlock;
                break;

            case PageSegmentationMode.SingleBlockVertText:
                _api.PageSegmentationMode = G8PageSegmentationMode.SingleBlockVertText;
                break;

            case PageSegmentationMode.SingleChar:
                _api.PageSegmentationMode = G8PageSegmentationMode.SingleChar;
                break;

            case PageSegmentationMode.SingleColumn:
                _api.PageSegmentationMode = G8PageSegmentationMode.SingleColumn;
                break;

            case PageSegmentationMode.SingleLine:
                _api.PageSegmentationMode = G8PageSegmentationMode.SingleLine;
                break;

            case PageSegmentationMode.SingleWord:
                _api.PageSegmentationMode = G8PageSegmentationMode.SingleWord;
                break;

            case PageSegmentationMode.SparseText:
                _api.PageSegmentationMode = G8PageSegmentationMode.SparseText;
                break;

            case PageSegmentationMode.SparseTextOsd:
                _api.PageSegmentationMode = G8PageSegmentationMode.SparseTextOSD;
                break;
            }
        }
Beispiel #4
0
        private List <string> run_tessract()
        {
            List <string>        re        = new List <string>();
            string               dataPath  = "./tessdata/";
            string               language  = 1 != 1 ? "eng" : "jpn";
            string               inputFile = "./_tmp.bmp";
            OcrEngineMode        oem       = OcrEngineMode.DEFAULT;
            PageSegmentationMode psm       = PageSegmentationMode.AUTO_OSD;

            TessBaseAPI tessBaseAPI = new TessBaseAPI();

            // Initialize tesseract-ocr
            if (!tessBaseAPI.Init(dataPath, language, oem))
            {
                throw new Exception("Could not initialize tesseract.");
            }

            // Set the Page Segmentation mode
            tessBaseAPI.SetPageSegMode(psm);

            // Set the input image
            Pix pix = tessBaseAPI.SetImage(inputFile);

            tessBaseAPI.SetVariable("number", "1234567890");

            // Recognize image
            tessBaseAPI.Recognize();

            ResultIterator resultIterator = tessBaseAPI.GetIterator();

            // extract text from result iterator
            StringBuilder     stringBuilder     = new StringBuilder();
            PageIteratorLevel pageIteratorLevel = PageIteratorLevel.RIL_PARA;

            do
            {
                string str = resultIterator.GetUTF8Text(pageIteratorLevel);


                if (str != null)
                {
                    str = Regex.Replace(str, @"\n", "\r\n");
                    re.Add(str);
                }
            } while (resultIterator.Next(pageIteratorLevel));

            tessBaseAPI.Dispose();
            pix.Dispose();
            return(re);
        }
Beispiel #5
0
        static void example1()
        {
            string               dataPath = "./tessdata/";
            string               language = "eng";
            OcrEngineMode        oem      = OcrEngineMode.DEFAULT;
            PageSegmentationMode psm      = PageSegmentationMode.AUTO_OSD;

            TessBaseAPI tessBaseAPI = new TessBaseAPI();

            // Initialize tesseract-ocr
            if (!tessBaseAPI.Init(dataPath, language, oem))
            {
                throw new Exception("Could not initialize tesseract.");
            }

            // Set the Page Segmentation mode
            tessBaseAPI.SetPageSegMode(psm);
        }
Beispiel #6
0
        static void example4()
        {
            string               dataPath  = "./tessdata/";
            string               language  = "eng";
            string               inputFile = "./input.png";
            OcrEngineMode        oem       = OcrEngineMode.DEFAULT;
            PageSegmentationMode psm       = PageSegmentationMode.AUTO_OSD;

            TessBaseAPI tessBaseAPI = new TessBaseAPI();

            // Initialize tesseract-ocr
            if (!tessBaseAPI.Init(dataPath, language, oem))
            {
                throw new Exception("Could not initialize tesseract.");
            }

            // Set the Page Segmentation mode
            tessBaseAPI.SetPageSegMode(psm);

            // Set the input image
            Pix pix = tessBaseAPI.SetImage(inputFile);

            // Recognize image
            tessBaseAPI.Recognize();

            //ensure input name is set
            tessBaseAPI.SetInputName(inputFile);

            var    fileInfo     = new System.IO.FileInfo(inputFile);
            string tessDataPath = tessBaseAPI.GetDatapath();
            string outputName   = fileInfo.FullName.Replace(fileInfo.Extension, string.Empty); //input name.pdf

            // call pdf renderer and export pdf
            using (var pdfRenderer = new PdfRenderer(outputName, tessDataPath, false))
            {
                pdfRenderer.BeginDocument("tesseract.net searchable Pdf generation");
                pdfRenderer.AddImage(tessBaseAPI);
                pdfRenderer.EndDocument();
            }

            tessBaseAPI.Dispose();
            pix.Dispose();
        }
Beispiel #7
0
        private void ConvertImageToText()
        {
            try{
                string               dataPath  = "./tessdata";
                string               language  = "eng";
                string               inputFile = "./imageSaved.bmp";
                OcrEngineMode        oem       = OcrEngineMode.DEFAULT;
                PageSegmentationMode psm       = PageSegmentationMode.AUTO_OSD;

                TessBaseAPI tessBaseAPI = new TessBaseAPI();

                if (!tessBaseAPI.Init(dataPath, language, oem))
                {
                    throw new Exception("Could not initialize tesseract.");
                }

                // Set the Page Segmentation mode
                tessBaseAPI.SetPageSegMode(psm);

                // Set the input image
                tessBaseAPI.SetImage(inputFile);

                // Recognize image
                tessBaseAPI.Recognize();

                ResultIterator resultIterator = tessBaseAPI.GetIterator();

                // Extract text from result iterator
                StringBuilder     stringBuilder     = new StringBuilder();
                PageIteratorLevel pageIteratorLevel = PageIteratorLevel.RIL_WORD;// RIL_PARA;

                do
                {
                    stringBuilder.Append(resultIterator.GetUTF8Text(pageIteratorLevel) + " ");
                } while (resultIterator.Next(pageIteratorLevel));

                tessBaseAPI.Dispose();
                textParsed = stringBuilder.ToString().Trim();
                //textParsedBox.Text = stringBuilder.ToString().Trim();
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #8
0
        public TessBaseAPI(string dataPath, string language = "eng",
                           OcrEngineMode oem        = OcrEngineMode.DEFAULT,
                           PageSegmentationMode psm = PageSegmentationMode.AUTO_OSD)
            : this()
        {
            //ensure the data directory exist
            if (!System.IO.Directory.Exists(dataPath))
            {
                throw new System.IO.DirectoryNotFoundException("Datapath does not exist");
            }

            // Initialize tesseract-ocr with language and datapath and OEM_TESSERACT_CUBE_COMBINED
            if (!Init(dataPath, language, oem))
            {
                throw new Exception("Could not initialize tesseract.");
            }

            // Set the Page Segmentation mode
            SetPageSegMode(psm);
        }
Beispiel #9
0
        /// <summary>
        /// Processes the <see cref="Imaging.Image"/>.
        /// </summary>
        /// <param name="image">The <see cref="Imaging.Image"/> to process.</param>
        /// <param name="pageSegmentationMode">The page segmentation mode.</param>
        /// <returns>
        /// The <see cref="PageShape"/> object this method creates.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="image"/> is <b>null</b>.
        /// </exception>
        public PageShape Recognize(Imaging.Image image, PageSegmentationMode pageSegmentationMode)
        {
            using (Pix pix = Pix.FromImage(image))
            {
                ////Clear();
                ////NativeMethods.TessBaseAPIClear(this.handle);

                ////ClearPersistentCache();
                ////NativeMethods.TessBaseAPIClearPersistentCache(this.handle);

                ////ClearAdaptiveClassifier();
                ////NativeMethods.TessBaseAPIClearAdaptiveClassifier(this.handle);

                NativeMethods.TessBaseAPISetImage2(this.handle, pix.Handle);
                NativeMethods.TessBaseAPISetPageSegMode(this.handle, pageSegmentationMode);

                NativeMethods.TessBaseAPIRecognize(this.handle, IntPtr.Zero);

                return(this.ExtractResults(image.Bounds, image.HorizontalResolution, image.VerticalResolution));
            }
        }
Beispiel #10
0
        static void example3()
        {
            string dataPath = "./tessdata/";
            //string language = "eng";
            string               language  = "chi_sim";
            string               inputFile = "./input.png";
            OcrEngineMode        oem       = OcrEngineMode.DEFAULT;
            PageSegmentationMode psm       = PageSegmentationMode.AUTO_OSD;

            TessBaseAPI tessBaseAPI = new TessBaseAPI();

            // Initialize tesseract-ocr
            if (!tessBaseAPI.Init(dataPath, language, oem))
            {
                throw new Exception("Could not initialize tesseract.");
            }

            // Set the Page Segmentation mode
            tessBaseAPI.SetPageSegMode(psm);

            // Set the input image
            Pix pix = tessBaseAPI.SetImage(inputFile);

            // Recognize image
            tessBaseAPI.Recognize();

            ResultIterator resultIterator = tessBaseAPI.GetIterator();

            // extract text from result iterator
            StringBuilder     stringBuilder     = new StringBuilder();
            PageIteratorLevel pageIteratorLevel = PageIteratorLevel.RIL_PARA;

            do
            {
                stringBuilder.Append(resultIterator.GetUTF8Text(pageIteratorLevel));
            } while (resultIterator.Next(pageIteratorLevel));

            tessBaseAPI.Dispose();
            pix.Dispose();
        }
        public void /*Image*/ GetTextFromImage(IWebElement element, string uniqueName)
        {
            Screenshot screenshot = ((ITakesScreenshot)Driver).GetScreenshot();

            string pth       = Assembly.GetCallingAssembly().CodeBase;
            string finalpth  = pth.Substring(0, pth.LastIndexOf("bin")) + "Screenshots/" + uniqueName + ".jpeg";
            string localpath = new Uri(finalpth).LocalPath;

            screenshot.SaveAsFile(localpath, ScreenshotImageFormat.Jpeg);

            Image     img  = Image.FromFile(localpath /*uniqueName*/);
            Rectangle rect = new Rectangle();

            if (element != null)
            {
                // Get the Width and Height of the WebElement using
                int width  = element.Size.Width;
                int height = element.Size.Height;

                // Get the Location of WebElement in a Point.
                // This will provide X & Y co-ordinates of the WebElement
                Point p = element.Location;

                // Create a rectangle using Width, Height and element location
                rect = new Rectangle(p.X, p.Y, width, height);
            }

            //croping the image based on rect.
            Bitmap bmpImage   = new Bitmap(img);
            var    cropedImag = bmpImage.Clone(rect, bmpImage.PixelFormat);


            string dataPath = @"C:\Betsold\AutomationTesting\Tests\testdata\";
            string language = "eng";
            string imgPath  = @"C:\Betsold\AutomationTesting\Tests\Screenshots\logo-test.jpeg";

            OcrEngineMode        oem = OcrEngineMode.LSTM_ONLY;
            PageSegmentationMode psm = PageSegmentationMode.AUTO;

            TessBaseAPI tessBaseAPI = new TessBaseAPI(dataPath, language, oem, psm);

            // Set the input image
            tessBaseAPI.SetImage(imgPath);

            var processedImage = tessBaseAPI.GetThresholdedImage();

            processedImage.Write(@"C:\Users\ibozhinovski\Desktop\", ImageFileFormatTypes.IFF_JFIF_JPEG);


            // Recognize image
            tessBaseAPI.Recognize();

            ResultIterator resultIterator = tessBaseAPI.GetIterator();

            // Extract text from result iterator
            StringBuilder     text = new StringBuilder();
            PageIteratorLevel pageIteratorLevel = PageIteratorLevel.RIL_PARA;

            do
            {
                text.Append(resultIterator.GetUTF8Text(pageIteratorLevel));
            } while (resultIterator.Next(pageIteratorLevel));

            tessBaseAPI.Dispose();

            Console.Read();

            /*
             * // croping the image based on rect.
             * Bitmap bmpImage = new Bitmap(img);
             * var cropedImag = bmpImage.Clone(rect, bmpImage.PixelFormat);
             *
             * var ocr = new TesseractEngine("./testdata", "eng");
             *
             * var page = ocr.Process(cropedImag);
             *
             * var result = page.GetText();
             *
             * Console.WriteLine(result);
             */
        }
Beispiel #12
0
        public new void KeyDown(KeyboardHookEventArgs e)
        {
            // Use Singleton design to store location information
            PartLocation currentLocation = PartLocation._instance;

            // Print Screen key was pressed
            if (e.Key == Keys.PrintScreen)
            {
                // Grab image from screen and convert to black and white using a threshold
                PrintScreenThreshold();

                // Process text from image
                try
                {
                    string               dataPath  = @"./tessdata";
                    string               language  = "eng";
                    string               inputFile = "rewards.jpg";
                    OcrEngineMode        oem       = OcrEngineMode.DEFAULT;
                    PageSegmentationMode psm       = PageSegmentationMode.SINGLE_LINE;

                    TessBaseAPI tessBaseAPI = new TessBaseAPI();

                    // Initialize tesseract-ocr
                    if (!tessBaseAPI.Init(dataPath, language, oem))
                    {
                        throw new Exception("Could not initialize tesseract");
                    }

                    // Set the Page Segmentation mode
                    tessBaseAPI.SetPageSegMode(psm);

                    // Warframe Relics are displayed using A-Z, a-z, and &
                    tessBaseAPI.SetVariable("tessedit_char_whitelist", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&");

                    // Set input file
                    Pix pix = tessBaseAPI.SetImage(inputFile);

                    TB_Part1.Text = GetText(tessBaseAPI, currentLocation.PartLoc1, 580);
                    TB_Part2.Text = GetText(tessBaseAPI, currentLocation.PartLoc2, 580);
                    if (currentLocation.NumPeople >= 3)
                    {
                        TB_Part3.Text = GetText(tessBaseAPI, currentLocation.PartLoc3, 580);
                    }
                    if (currentLocation.NumPeople == 4)
                    {
                        TB_Part4.Text = GetText(tessBaseAPI, currentLocation.PartLoc4, 580);
                    }

                    tessBaseAPI.Dispose();
                    pix.Dispose();

                    // Grab latest order list for parts
                    // TODO: Try multiple threads! If that's too fast, cache prices for a duration
                    using (var client = new WebClient())
                    {
                        GetPriceJson(client, TB_Part1, TB_Plat1);
                        GetPriceJson(client, TB_Part2, TB_Plat2);
                        if (currentLocation.NumPeople >= 3)
                        {
                            GetPriceJson(client, TB_Part3, TB_Plat3);
                        }
                        if (currentLocation.NumPeople == 4)
                        {
                            GetPriceJson(client, TB_Part4, TB_Plat4);
                        }

                        // These get cached
                        GetDucatsJson(client, TB_Part1, TB_Ducats1);
                        GetDucatsJson(client, TB_Part2, TB_Ducats2);
                        if (currentLocation.NumPeople >= 3)
                        {
                            GetDucatsJson(client, TB_Part3, TB_Ducats3);
                        }
                        if (currentLocation.NumPeople == 4)
                        {
                            GetDucatsJson(client, TB_Part4, TB_Ducats4);
                        }
                    }

                    List <PartWorth> sortPartWorth = new List <PartWorth>();
                    sortPartWorth.Add(new PartWorth(TB_Part1, TB_Ducats1));
                    sortPartWorth.Add(new PartWorth(TB_Part2, TB_Ducats2));
                    if (currentLocation.NumPeople >= 3)
                    {
                        sortPartWorth.Add(new PartWorth(TB_Part3, TB_Ducats3));
                    }
                    if (currentLocation.NumPeople == 4)
                    {
                        sortPartWorth.Add(new PartWorth(TB_Part4, TB_Ducats4));
                    }

                    // Sort by Plat, then Ducats
                    sortPartWorth = sortPartWorth.OrderByDescending(o => Int32.Parse(o.platinum.Tag.ToString())).ThenByDescending(o => Int32.Parse(o.ducats.Tag.ToString())).ToList();

                    // If max Plat is low, sort by the reverse
                    if (Int32.Parse(sortPartWorth[0].platinum.Tag.ToString()) < 15)
                    {
                        sortPartWorth = sortPartWorth.OrderByDescending(o => Int32.Parse(o.ducats.Tag.ToString())).ThenByDescending(o => Int32.Parse(o.platinum.Tag.ToString())).ToList();
                    }

                    // Show best option
                    TB_Pick.Text = sortPartWorth[0].platinum.Text;

                    // Show current amount of Plat (and Ducats) made in the current session
                    if (Int32.Parse(sortPartWorth[0].platinum.Tag.ToString()) != -1)
                    {
                        //GlobalVar.PLAT += Int32.Parse(platDuc[0].plat.Tag.ToString());
                        LB_Plat.Tag = Int32.Parse(LB_Plat.Tag.ToString()) + Int32.Parse(sortPartWorth[0].platinum.Tag.ToString());
                    }
                    if (Int32.Parse(sortPartWorth[0].ducats.Tag.ToString()) != -1)
                    {
                        //GlobalVar.DUCATS += Int32.Parse(platDuc[0].ducats.Tag.ToString());
                        LB_Ducs.Tag = Int32.Parse(LB_Ducs.Tag.ToString()) + Int32.Parse(sortPartWorth[0].ducats.Tag.ToString());
                    }

                    LB_Plat.Text = LB_Plat.Tag.ToString() + " p";
                    LB_Ducs.Text = LB_Ducs.Tag.ToString() + " d";
                }
                catch (Exception ex)
                {
                    LogError("KeyDown: " + ex.Message);
                }
            }
            else if (e.Key == Keys.NumPad2)
            {
                Debug.WriteLine("Switched to 2 people");

                ClearBox();
                VisibleRow(false, LB_Part3, TB_Part3, TB_Plat3, TB_Ducats3);
                VisibleRow(false, LB_Part4, TB_Part4, TB_Plat4, TB_Ducats4);

                currentLocation.SetPeople2();
            }
            else if (e.Key == Keys.NumPad3)
            {
                Debug.WriteLine("Switched to 3 people");

                ClearBox();
                VisibleRow(true, LB_Part3, TB_Part3, TB_Plat3, TB_Ducats3);
                VisibleRow(false, LB_Part4, TB_Part4, TB_Plat4, TB_Ducats4);

                currentLocation.SetPeople3();
            }
            else if (e.Key == Keys.NumPad4)
            {
                Debug.WriteLine("Switched to 4 people");

                ClearBox();
                VisibleRow(true, LB_Part3, TB_Part3, TB_Plat3, TB_Ducats3);
                VisibleRow(true, LB_Part4, TB_Part4, TB_Plat4, TB_Ducats4);

                currentLocation.SetPeople4();
            }
            else if (e.Key == Keys.Pause)
            {
                Environment.Exit(0);
            }
        }
Beispiel #13
0
        //public static void  clearFaceFlag() { faceFlag = 0; }
        public string RecognizeText(int id)
        {
            DBService dbs = new DBService();
            Document  doc = dbs.FindDocumentById(id);

            Image <Gray, Byte> img = scale(doc);

            //var image = PixConverter.ToPix(img.ToBitmap()))

            Tesseract.Native.DllImports.TesseractDirectory = System.Web.HttpContext.Current.Server.MapPath("~/Tesseract/bin/Debug/DLLS/");
            TessBaseAPI tessBaseAPI = new TessBaseAPI();

            System.Diagnostics.Debug.WriteLine("The current version is {0}", tessBaseAPI.GetVersion());

            string dataPath = System.Web.HttpContext.Current.Server.MapPath("~/tessdata/");
            string language = "eng";

            string        inputFile = doc.Path;
            OcrEngineMode oem       = OcrEngineMode.DEFAULT;
            //OcrEngineMode oem = OcrEngineMode.DEFAULT;
            PageSegmentationMode psm = PageSegmentationMode.AUTO_OSD;

            // Initialize tesseract-ocr
            if (!tessBaseAPI.Init(dataPath, language, oem))
            {
                throw new Exception("Could not initialize tesseract.");
            }

            // Set the Page Segmentation mode
            tessBaseAPI.SetPageSegMode(psm);

            // Set the input image
            Pix pix = tessBaseAPI.SetImage(inputFile);

            // Recognize image
            tessBaseAPI.Recognize();

            ResultIterator resultIterator = tessBaseAPI.GetIterator();

            // extract text from result iterator
            StringBuilder stringBuilder = new StringBuilder();
            int           top, bottom, left, right, i = 0;

            List <OCRText> forJson = new List <OCRText>();

            PageIteratorLevel pageIteratorLevel = PageIteratorLevel.RIL_TEXTLINE;

            do
            {
                string textContent = resultIterator.GetUTF8Text(pageIteratorLevel);
                resultIterator.BoundingBox(pageIteratorLevel, out left, out top, out right, out bottom);
                string coordsString = "" + left + "," + top + "," + right + "," + bottom;

                forJson.Add(new OCRText()
                {
                    Coords = coordsString, Text = textContent
                });
            } while (resultIterator.Next(pageIteratorLevel));

            tessBaseAPI.Dispose();
            pix.Dispose();

            var textForReturn = JsonConvert.SerializeObject(forJson);

            dbs.UpdateDocument(textForReturn, id);

            if (HasFace(img) == true)
            {
                FaceFlag = 1;
            }
            else
            {
                FaceFlag = 0;
            }

            return(textForReturn);
        }
Beispiel #14
0
 public static extern void TessBaseAPISetPageSegMode(TesseractHandle handle, PageSegmentationMode mode);
 public void SetPageSegmentationMode (PageSegmentationMode mode)
 {
     switch (mode) {
     case PageSegmentationMode.Auto:
         _api.SetPageSegMode (PageSegMode.Auto);
         break;
     case PageSegmentationMode.AutoOnly:
         _api.SetPageSegMode (PageSegMode.AutoOnly);
         break;
     case PageSegmentationMode.AutoOsd:
         _api.SetPageSegMode (PageSegMode.AutoOsd);
         break;
     case PageSegmentationMode.CircleWord:
         _api.SetPageSegMode (PageSegMode.CircleWord);
         break;
     case PageSegmentationMode.OsdOnly:
         _api.SetPageSegMode (PageSegMode.OsdOnly);
         break;
     case PageSegmentationMode.SingleBlock:
         _api.SetPageSegMode (PageSegMode.SingleBlock);
         break;
     case PageSegmentationMode.SingleBlockVertText:
         _api.SetPageSegMode (PageSegMode.SingleBlockVertText);
         break;
     case PageSegmentationMode.SingleChar:
         _api.SetPageSegMode (PageSegMode.SingleChar);
         break;
     case PageSegmentationMode.SingleColumn:
         _api.SetPageSegMode (PageSegMode.SingleColumn);
         break;
     case PageSegmentationMode.SingleLine:
         _api.SetPageSegMode (PageSegMode.Auto);
         break;
     case PageSegmentationMode.SingleWord:
         _api.SetPageSegMode (PageSegMode.SingleWord);
         break;
     case PageSegmentationMode.SparseText:
         _api.SetPageSegMode (PageSegMode.SparseText);
         break;
     case PageSegmentationMode.SparseTextOsd:
         _api.SetPageSegMode (PageSegMode.SparseTextOsd);
         break;
     }
 }
Beispiel #16
0
 internal static extern void TessBaseAPISetPageSegMode(HandleRef handle, PageSegmentationMode mode);
Beispiel #17
0
 internal static extern int TessBaseAPIAdaptToWordStr(HandleRef handle, PageSegmentationMode mode, IntPtr wordstr);
Beispiel #18
0
 /// <summary>
 /// Set the current page segmentation mode. Defaults to PSM_SINGLE_BLOCK.
 /// The mode is stored as an IntParam so it can also be modified by
 /// ReadConfigFile or SetVariable("tessedit_pageseg_mode", mode as string).
 /// </summary>
 public void SetPageSegMode(PageSegmentationMode value)
 {
     Native.DllImports.TessBaseAPISetPageSegMode((HandleRef)this, value);
 }
 public void SetPageSegmentationMode (PageSegmentationMode mode)
 {
     switch (mode) {
     case PageSegmentationMode.Auto:
         _api.PageSegmentationMode = G8PageSegmentationMode.Auto;
         break;
     case PageSegmentationMode.AutoOnly:
         _api.PageSegmentationMode = G8PageSegmentationMode.AutoOnly;
         break;
     case PageSegmentationMode.AutoOsd:
         _api.PageSegmentationMode = G8PageSegmentationMode.AutoOSD;
         break;
     case PageSegmentationMode.CircleWord:
         _api.PageSegmentationMode = G8PageSegmentationMode.CircleWord;
         break;
     case PageSegmentationMode.OsdOnly:
         _api.PageSegmentationMode = G8PageSegmentationMode.OSDOnly;
         break;
     case PageSegmentationMode.SingleBlock:
         _api.PageSegmentationMode = G8PageSegmentationMode.SingleBlock;
         break;
     case PageSegmentationMode.SingleBlockVertText:
         _api.PageSegmentationMode = G8PageSegmentationMode.SingleBlockVertText;
         break;
     case PageSegmentationMode.SingleChar:
         _api.PageSegmentationMode = G8PageSegmentationMode.SingleChar;
         break;
     case PageSegmentationMode.SingleColumn:
         _api.PageSegmentationMode = G8PageSegmentationMode.SingleColumn;
         break;
     case PageSegmentationMode.SingleLine:
         _api.PageSegmentationMode = G8PageSegmentationMode.SingleLine;
         break;
     case PageSegmentationMode.SingleWord:
         _api.PageSegmentationMode = G8PageSegmentationMode.SingleWord;
         break;
     case PageSegmentationMode.SparseText:
         _api.PageSegmentationMode = G8PageSegmentationMode.SparseText;
         break;
     case PageSegmentationMode.SparseTextOsd:
         _api.PageSegmentationMode = G8PageSegmentationMode.SparseTextOSD;
         break;
     }
 }