コード例 #1
0
ファイル: OcrEngine.cs プロジェクト: Amichai/Prax
 public void Train(int imageWidth, int imageHeight, int[][] arrayBitmap, List<ImageSegmentElement> ImageSegmentData)
 {
     IterateInput UploadedFile = new IterateInput(imageWidth, imageHeight, arrayBitmap);
     int pixelsToSkip = 5;
     bool trainWithTheArray;
     initializeLabeledSegmentBitmap(imageWidth, imageHeight);
     for (int i = 0; i < ImageSegmentData.Count; i++)
     {
         for (int xOffset = 0; xOffset < ImageSegmentData[i].rect.Width; xOffset++)
         {
             for (int yOffset = 0; yOffset < ImageSegmentData[i].rect.Height; yOffset++)
             {
                 HeuristicArray currentHArray = new HeuristicArray();
                 trainWithTheArray = currentHArray.DefineHeuristicArray(ImageSegmentData[i].rect.X + xOffset, ImageSegmentData[i].rect.Y + yOffset,
                                             UploadedFile.SetOfIteratedBoards, imageWidth, imageHeight);
                 if (trainWithTheArray)
                 {
                     currentHArray.CommitArrayToTrainingData(ImageSegmentData[i].label, ImageSegmentData[i].rect);
                     labeledSegmentBitmap[ImageSegmentData[i].rect.X + xOffset][ImageSegmentData[i].rect.Y + yOffset] = i;
                     TestAlgorithm.labeledSegmentBitmap_test[ImageSegmentData[i].rect.X + xOffset][ImageSegmentData[i].rect.Y + yOffset] = i;
                 }
             }
         }
     }
     printLabeledSegementBitmap(imageWidth, imageHeight, pixelsToSkip);
     UploadedFile.reset();
 }
コード例 #2
0
ファイル: OcrEngine.cs プロジェクト: Amichai/Prax
        public void Test(int imageWidth, int imageHeight, int[][] arrayBitmap)
        {
            int pixelsToSkip = 5;
            initializeLabeledPixelBitmap(imageWidth, imageHeight);
            if (TrainingData.TrainingDataIndex.Count > 0) //make sure their is training data to test against
            {
                IterateInput UploadedFile = new IterateInput(imageWidth, imageHeight, arrayBitmap);
                HeuristicArray currentHArray = new HeuristicArray();

                for (int i = 0; i < imageWidth; i += pixelsToSkip)
                {
                    for (int j = 0; j < imageHeight; j += pixelsToSkip)
                    {
                        currentHArray.DefineHeuristicArray(i, j, UploadedFile.SetOfIteratedBoards, imageWidth, imageHeight);
                        testArrayAgainstTrainingData(i, j, currentHArray.currentHeuristicArray);
                    }
                }
                printResultToFile(imageWidth, imageHeight, pixelsToSkip);
            }
            //Iterate through the entire bitmap (with a skip function)
            //For each pixel define the heuristic array
            //Test each heuristic array against the training Data
        }