示例#1
0
        public void ProcessFields()
        {
            foreach (ICRField Field in this.Fields)
            {
                ImageX           FieldImage = new ImageX(imagXpress1);
                DropOutProcessor oDrop      = new DropOutProcessor(formFix1);
                oDrop.DropOutMethod         = DropOutMethod.DropOut;
                oDrop.PerformReconstruction = false;
                oDrop.Area = new Rectangle(Field.Left, Field.Top, Field.Width, Field.Height);
                DropOutResult oDropOutResult = oDrop.CreateImageOfField(frmFilledImage, regResult);

                FieldImage = ImageX.FromHdib(imagXpress1, oDropOutResult.Image.ToHdib(true), true);
                oDrop.Dispose();


                OutputFieldImg.Image = FieldImage.Copy();
                OnPictureChanged(ICRType.Field);
                // MessageBox.Show("Field Loaded");
                Application.DoEvents();

                // Set area and analyze field DIB
                SmartZone2.Reader.CharacterSet = Field.CharSet;
                SmartZone2.Reader.Segmentation.SplitMergedChars      = true;
                SmartZone2.Reader.Segmentation.SplitOverlappingChars = true;

                FieldImage = this.PreprocessField(FieldImage);

                OutputFieldImg.Image = FieldImage.Copy();
                OnPictureChanged(ICRType.FieldProcessed);
                //MessageBox.Show("Field Processed");
                Application.DoEvents();

                Rectangle currentArea = new Rectangle(0, 0, Field.Width, Field.Height);
                SmartZone2.Reader.Area = currentArea;
                myTextBlockRes         = SmartZone2.Reader.AnalyzeField(FieldImage.ToHdib(true));


                if (myTextBlockRes.NumberTextLines > 0)
                {
                    //  MessageBox.Show(myTextBlockRes.TextLine(0).Text);

                    Chars.Clear();
                    for (int i = 1; myTextBlockRes.NumberTextLines + 1 != i; i++)
                    {
                        LineResult = myTextBlockRes.TextLine(0);

                        String charResult   = "";
                        int    ControlIndex = 1;
                        for (int charIndex = 0; LineResult.NumberCharacters != charIndex; charIndex++)
                        {
                            CharacterResult characterResult = LineResult.Character(charIndex);
                            ICRChar         oChar           = new ICRChar(characterResult.Text, characterResult.Confidence);
                            for (int x = 0; x < characterResult.NumberResults; x++)
                            {
                                oChar.Results.Add(new ICRAlternateChar(characterResult.AlternateText(x), characterResult.AlternateConfidence(x)));
                            }

                            oChar.Area          = characterResult.Area;
                            oChar.NumberResults = characterResult.NumberResults;
                            Chars.Add(oChar);

                            charResult = charResult + characterResult.Text;
                            ControlIndex++;
                        }
                        Field.Result = charResult;
                        //MessageBox.Show(Field.Result);
                        Console.Out.WriteLine(Field.Result);
                    }
                }
                else
                {
                    Field.Result = "";
                }
            }
        }