Пример #1
0
        public GradeViewForm()
        {
            if (!Directory.Exists(OcrData))
            {
                var fbd = new FolderBrowserDialog();
                fbd.Description = "Выберите директорию с оценками";
                if (fbd.ShowDialog() == DialogResult.OK)
                {
                    OcrData = fbd.SelectedPath;
                }
                else
                {
                    throw new Exception("no base directory was chosen");
                }
            }

            InitializeComponent();

            gradePV  = PictureView.InsertIntoPanel(gradePanel);
            digestPV = PictureView.InsertIntoPanel(digestPanel);

            this.Shown += new EventHandler(delegate {
                ProcessNextGrade();
            });

            KeyEventHandler keyHandler = new KeyEventHandler(delegate(object sender, KeyEventArgs e) {
                if (e.Control && e.KeyCode == Keys.Z)
                {
                    if (actionHistory.Count > 0)
                    {
                        Tuple <string, string> lastAction = actionHistory.Last();
                        actionHistory.Remove(lastAction);
                        File.Move(lastAction.Item2, lastAction.Item1);
                        ProcessGrade(lastAction.Item1);
                    }
                }
                else
                {
                    Dictionary <Keys, int> gradeKeys = new Dictionary <Keys, int> {
                        { Keys.D2, 2 }, { Keys.NumPad2, 2 },
                        { Keys.D3, 3 }, { Keys.NumPad3, 3 },
                        { Keys.D4, 4 }, { Keys.NumPad4, 4 },
                        { Keys.D5, 5 }, { Keys.NumPad5, 5 },
                        { Keys.D0, 0 }, { Keys.NumPad0, 0 }
                    };
                    gradeKeys.GetOption(e.KeyCode).ForEach(grade => {
                        MoveImageToDone(currentFileName, grade);
                        ProcessNextGrade();
                    });
                }
            });

            gradePV.KeyUp  += keyHandler;
            digestPV.KeyUp += keyHandler;
        }
Пример #2
0
        public FinderCircleDebugView(Bitmap sourceImage, int minPatternRadius, int maxPatternRadius, uint inputValue, NoiseFilter noiseFilter)
        {
            InitializeComponent();

            this.inputImagePV           = PictureView.InsertIntoPanel(inputImagePanel);
            this.noiseImagePV           = PictureView.InsertIntoPanel(noiseImagePanel);
            this.houghImagePV           = PictureView.InsertIntoPanel(houghImagePanel);
            this.houghPeakImagePV       = PictureView.InsertIntoPanel(houghPeaksImagePanel);
            this.peakResultImagePV      = PictureView.InsertIntoPanel(peakResultImagePanel);
            this.dataMatrixLocationPV   = PictureView.InsertIntoPanel(dataMatrixLocationPanel);
            this.rotatedDataMatrixPV    = PictureView.InsertIntoPanel(rotatedDataMatrixPanel);
            this.recognizedDataMatrixPV = PictureView.InsertIntoPanel(recognizedDataMatrixPanel);

            this.Shown += new EventHandler(delegate {
                Util.NewThread(() => {
                    Util.Timed("full AR-code OCR", () => {
                        RunOCR(sourceImage, minPatternRadius, maxPatternRadius, inputValue, noiseFilter);
                    });
                });
            });
        }
Пример #3
0
        public GradeRecognitionDebugView(Bitmap inputImage, string imageName)
        {
            InitializeComponent();

            this.Text = imageName;

            inputImagePV   = PictureView.InsertIntoPanel(inputImagePanel);
            removeBorderPV = PictureView.InsertIntoPanel(removeBorderPanel);
            noiseRemovalPV = PictureView.InsertIntoPanel(noiseRemovalPanel);
            croppedPV      = PictureView.InsertIntoPanel(croppedPanel);
            digestPV       = PictureView.InsertIntoPanel(digestPanel);

            this.Shown += new EventHandler(delegate {
                Thread worker = new Thread(new ThreadStart(delegate {
                    Util.Timed("Grade OCR debug run", () => {
                        RunOCR(inputImage);
                    });
                }));
                worker.IsBackground = true;
                worker.Start();
            });
        }
Пример #4
0
        public TableRecognitionDebugView(Bitmap sourceImage)
        {
            InitializeComponent();

            sourceImagePV      = PictureView.InsertIntoPanel(sourceImagePanel);
            bwImagePV          = PictureView.InsertIntoPanel(bwImagePanel);
            edgePointsPV       = PictureView.InsertIntoPanel(edgePointsPanel);
            houghPV            = PictureView.InsertIntoPanel(houghPanel);
            cyclicPatternsPV   = PictureView.InsertIntoPanel(cyclicPatternsPanel);
            filteredLinesPV    = PictureView.InsertIntoPanel(filteredLinesPanel);
            normalizedLinesPV  = PictureView.InsertIntoPanel(normalizedLinesPanel);
            tableRecognitionPV = PictureView.InsertIntoPanel(tableRecognitionPanel);
            recognizedTablePV  = PictureView.InsertIntoPanel(recognizedTablePanel);
            rotBwImagePV       = PictureView.InsertIntoPanel(rotBwImagePanel);
            rotEdgePointsPV    = PictureView.InsertIntoPanel(rotEdgePointsPanel);

            this.Shown += new EventHandler(delegate {
                Util.NewThread(() => {
                    RunOCR(sourceImage);
                });
            });
        }
Пример #5
0
        public RegisterView()
        {
            InitializeComponent();

            registerPV = PictureView.InsertIntoPanel(registerPanel);

            this.Shown += new EventHandler(delegate {
                Option <string> nextRegisterName = GetRegisterFileName();
                nextRegisterName.ForEach(fileName => {
                    LoadRegister(fileName);
                });
                if (nextRegisterName.IsEmpty())
                {
                    Environment.Exit(0);
                }
            });

            registerPV.AddDoubleClickListener((pt, e) => {
                if (e.Button == MouseButtons.Left)
                {
                    currentTable.ForEach(table => {
                        table.GetCellAtPoint(pt.X, pt.Y).ForEach(cell => {
                            if (cell1.HasValue && !cell2.HasValue)
                            {
                                cell2 = cell;
                                CopyData();
                            }
                            else
                            {
                                cell1 = cell;
                                cell2 = null;
                                MarkCell();
                            }
                        });
                    });
                }
            });

            debugButton.Click += new EventHandler(delegate {
                new TableRecognitionDebugView(ImageUtil.LoadImage(imageFileName)).ShowDialog();
            });

            selectRegisterButton.Click += new EventHandler(delegate {
                Option <string> nextRegisterName = GetRegisterFileName();
                nextRegisterName.ForEach(fileName => {
                    LoadRegister(fileName);
                });
            });

            nextRegisterButton.Click += new EventHandler(delegate {
                string imgDir  = Path.GetDirectoryName(imageFileName);
                string[] files = Directory.GetFiles(imgDir);
                int imgN       = 0;
                for (int q = 0; q < files.Length; q++)
                {
                    if (files[q] == imageFileName)
                    {
                        imgN = q + 1;
                    }
                }
                if (imgN < files.Length)
                {
                    LoadRegister(files[imgN]);
                }
                else
                {
                    MessageBox.Show("Ведомостей больше нет!");
                }
            });
        }
Пример #6
0
        public RegisterViewForm()
        {
            InitializeComponent();

            registerPV = PictureView.InsertIntoPanel(registerPanel);

            this.Shown += new EventHandler(delegate {
                ProcessNextImage();
            });

            this.nextRegisterButton.Click += new EventHandler(delegate {
                MoveImageToDone(currentFileName);
                ProcessNextImage();
            });

            Point?selectionStart = null;

            this.registerPV.AddDoubleClickListener((pt, e) => {
                Util.NewThread(() => {
                    currentTable.ForEach(table => {
                        if (e.Button == MouseButtons.Left)
                        {
                            table.GetCellAtPoint(pt.X, pt.Y).ForEach(cell => {
                                nextImageIndex = null;
                                ProcessTableCell(cell.X, cell.Y);

                                // color processed cell with green
                                table.GetCellContour(cell.X, cell.Y).ForEach(cellPath => {
                                    Graphics g = Graphics.FromImage(currentImage);
                                    g.FillPath(new SolidBrush(Color.FromArgb(100, Color.Green)), cellPath);
                                    g.Dispose();
                                });
                                registerPV.SetImageKeepZoom(currentImage);
                            });
                        }
                        else if (e.Button == MouseButtons.Right)
                        {
                            table.GetCellAtPoint(pt.X, pt.Y).ForEach(cell => {
                                if (selectionStart.HasValue)
                                {
                                    Graphics g = Graphics.FromImage(currentImage);

                                    int minX = Math.Min(selectionStart.Value.X, cell.X);
                                    int maxX = Math.Max(selectionStart.Value.X, cell.X);
                                    int minY = Math.Min(selectionStart.Value.Y, cell.Y);
                                    int maxY = Math.Max(selectionStart.Value.Y, cell.Y);

                                    nextImageIndex = null;
                                    ProgressDialogs.WithProgress((maxX - minX + 1) * (maxY - minY + 1), pd => {
                                        for (int y = minY; y <= maxY; y++)
                                        {
                                            for (int x = minX; x <= maxX; x++)
                                            {
                                                ProcessTableCell(x, y);
                                                table.GetCellContour(x, y).ForEach(cellPath => {
                                                    g.FillPath(new SolidBrush(Color.FromArgb(100, Color.Green)), cellPath);
                                                });
                                                pd.Increment();
                                            }
                                        }
                                    });

                                    // color processed cells with green
                                    g.Dispose();
                                    registerPV.SetImageKeepZoom(currentImage);

                                    selectionStart = null;
                                }
                                else
                                {
                                    selectionStart = new Point(cell.X, cell.Y);
                                }
                            });
                        }
                    });
                });
            });

            this.debugOcrButton.Click += new EventHandler(delegate {
                (new TableRecognitionDebugView(origImage)).ShowDialog();
            });
        }