Esempio n. 1
0
        private string recognizeLetter(BufferedImage image)
        {
            // samo za test
            //        OCRUtilities.saveToFile(image, "C:\\Users\\Mihailo\\Desktop\\OCR\\test-letters", new Random().nextInt()+"", "png");
            //
            IDictionary <string, double?> output = plugin.recognizeImage(image);

            return(OCRUtilities.getCharacter(output));
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static void main(String[] args) throws java.io.IOException
        public static void Main(string[] args)
        {
            // User input parameters
            //***********************************************************************************************************************************
            string networkPath = "C:/Users/Mihailo/Desktop/OCR/nnet/nnet-12-0.01.nnet";     // path to the trained network                *
            string letterPath  = "C:/Users/Mihailo/Desktop/OCR/letters/259.png";            // path to the letter for recognition                   *
            //***********************************************************************************************************************************

            NeuralNetwork                 nnet             = NeuralNetwork.createFromFile(networkPath);
            ImageRecognitionPlugin        imageRecognition = (ImageRecognitionPlugin)nnet.getPlugin(typeof(ImageRecognitionPlugin));
            IDictionary <string, double?> output           = imageRecognition.recognizeImage(new File(letterPath));

            Console.WriteLine("Recognized letter: " + OCRUtilities.getCharacter(output));
        }
Esempio n. 3
0
        public String IdentifyDocumentType(String physicalPath)
        {
            OCRUtilities ocrUtil = new OCRUtilities();

            return(IndexOfDocumentTypeFromTemplates((ocrUtil.GetPDFPageContent(physicalPath, new List <int>()))[0]));
        }
Esempio n. 4
0
        private void createImagesWithLetters()
        {
            int cropWidth  = letterInformation.CropWidth;
            int cropHeight = letterInformation.CropHeight;
            int tmpWidth   = 3 * cropWidth;
            int tmpHeight  = 3 * cropHeight;
            int trashSize  = letterInformation.TrashSize;

            OCRExtractLetter extractionLetter = new OCRExtractLetter(tmpWidth, tmpHeight, trashSize);

            int letterSize  = letterInformation.LetterSize;
            int imageHeight = image.Height;
            int imageWidth  = image.Width;

//JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java:
//ORIGINAL LINE: bool[][] visited = new bool[imageHeight][imageWidth];
            bool[][] visited = RectangularArrays.ReturnRectangularBoolArray(imageHeight, imageWidth);
            Color    white   = Color.WHITE;
            Color    color;
            int      seqNum = 0;

            for (int line = 0; line < textInformation.numberOfRows(); line++)
            {
                //==============================================================================
                for (int j = 0; j < imageWidth; j++)
                {
                    for (int k = -(letterSize / 4); k < (letterSize / 4); k++)
                    {
                        int rowPixel = textInformation.getRowAt(line);
                        int i        = rowPixel + k;
                        if (i < 0 || i >= imageHeight)
                        {
                            continue;
                        }
                        //==============================================================================
                        //                   fornja verzija radi, ova ima gresku
                        //            for (int k = -(letterSize / 4); k < (letterSize / 4); k++) {
                        //                int rowPixel = textInformation.getRowAt(line);
                        //                int i = rowPixel + k;
                        //                if (i < 0 || i >= imageHeight) {
                        //                    continue;
                        //                }
                        //                for (int j = 0; j < imageWidth; j++) {
                        //==============================================================================
                        color = new Color(image.getRGB(j, i));
                        if (color.Equals(white))
                        {
                            visited[i][j] = true;
                        }
                        else if (visited[i][j] == false)
                        {
                            BufferedImage letter = extractionLetter.extraxtLetter(image, visited, i, j);                             // OCRUtilities.extraxtCharacterImage(image, visited, i, j, tmpWidth, tmpHeight, letterInformation.getTrashSize());
                            if (letter != null)
                            {
                                OCRCropLetter crop      = new OCRCropLetter(letter, cropWidth, cropHeight);
                                BufferedImage croped    = crop.processImage();
                                string        character = trainingText[seqNum] + "";
                                string        name      = character + "_" + seqNum;
                                OCRUtilities.saveToFile(croped, folderPath, name, imageExtension);
                                seqNum++;
                            }
                        }
                    }
                }
            }
        }