Beispiel #1
0
        //Métodos Segmentado Semiautomático
        private void semiautomaticoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (textoSegmentado != null)
            {
                textoSegmentado.LiberarTextoManejado();
            }

            textoSegmentado = textoActual.Copia();

            deshabilitarMenus("Segmentado semiautomático");

            conometro.Start();

            //Segmentación líneas
            textoSegmentado.SegmentacionLineas(perfilActual.segmentacion.interlineadoMedio, perfilActual.segmentacion.incrementoMinimoLineas);
            estadoImagenSegmentada = EstadoImagen.lineasSegmentadas;

            ArreglarLineasForm arreglar = new ArreglarLineasForm(this);

            arreglar.ShowDialog();

            if (estadoImagenSegmentada != EstadoImagen.nula)
            {
                imagenSegmentada.habilitarBotonCerrar(false);
            }

            segmentadoSemiautomaticoBackgroundWorker.RunWorkerAsync();
        }
Beispiel #2
0
        public OpcionesKNNForm(TextoManejado texto)
        {
            InitializeComponent();

            this.texto = texto;
            numeroVecinosNumericUpDown.Value = texto.GetNumeroVecinos();
        }
Beispiel #3
0
        public ArreglarLineasForm(PrincipalForm Padre)
        {
            InitializeComponent();

            lineaSeleccionada = -1;
            fusionar          = false;

            formPadre     = (PrincipalForm)Padre;
            copiaTexto    = formPadre.textoSegmentado.Copia();
            textoEscalado = copiaTexto.Copia();

            textoEscalado.EscalacionLineal(((double)lineasSegmentadasPictureBox.Size.Width) / copiaTexto.GetAncho(), ((double)lineasSegmentadasPictureBox.Size.Height) / copiaTexto.GetAlto());

            IntPtr ptrDIB;      //Puntero al DIB
            IntPtr ptrMapaBits; //Puntero al mapa de bits en sí (nos saltamos el bitmapinfoheader y la paleta, si la hay)

            unsafe              //Zona no segura (transformación de punteros C++ a C#)
            {
                ptrDIB = (IntPtr)textoEscalado.GetDIB();

                ptrMapaBits = (IntPtr)textoEscalado.GetMapaBits();
            }

            lineasSegmentadasPictureBox.Image = PrincipalForm.BitmapFromDIB(ptrDIB, ptrMapaBits);
        }
Beispiel #4
0
        //Métodos auxiliares para escanear
        bool IMessageFilter.PreFilterMessage(ref Message m)
        {
            TwainCommand orden = escaner.RecibirMensaje(ref m);

            if (orden == TwainCommand.Not)
            {
                return(false);
            }

            switch (orden)
            {
            case TwainCommand.CloseRequest:
            {
                Terminar();
                escaner.CerrarConexion();
                break;
            }

            case TwainCommand.CloseOk:
            {
                Terminar();
                escaner.CerrarConexion();
                break;
            }

            case TwainCommand.DeviceEvent:
            {
                break;
            }

            case TwainCommand.TransferReady:
            {
                ArrayList imagenes = escaner.TransferirImagenes();
                Terminar();
                escaner.CerrarConexion();

                for (int i = 0; i < imagenes.Count; i++)
                {
                    //byte []nuevaImagen;
                    IntPtr imagen = (IntPtr)imagenes[i];

                    //Arreglar
                    textoActual = new TextoManejado(GlobalLock(imagen));

                    textoActual = textoActual.Copia();

                    GlobalFree(imagen);

                    estadoImagen = EstadoImagen.nula;

                    CargarImagen();
                }
                break;
            }
            }

            return(true);
        }
Beispiel #5
0
        public SlopeForm(PrincipalForm Padre)
        {
            InitializeComponent();

            formPadre  = (PrincipalForm)Padre;
            copiaTexto = formPadre.textoSegmentado;

            distanciaMinimaNumericUpDown.Value = formPadre.perfilActual.segmentacion.distanciaMinimaSlope;
        }
Beispiel #6
0
        //Fin Menú Segmentación


        //Menú Reconocimiento
        //Métodos Reconocimiento Manual
        private void ManualToolStripMenuItem_Click(object sender, EventArgs e)
        {
            textoReconocido = textoSegmentado.Copia();

            TextoReconocidoForm t = new TextoReconocidoForm(this);

            t.MdiParent = this;
            t.Show();
        }
Beispiel #7
0
        public PalabrasForm(PrincipalForm Padre)
        {
            InitializeComponent();

            formPadre  = (PrincipalForm)Padre;
            copiaTexto = formPadre.textoSegmentado;

            espaciadoMedioNumericUpDown.Value = formPadre.perfilActual.segmentacion.espaciadoMedio;
        }
Beispiel #8
0
        public CaracteresForm(PrincipalForm Padre)
        {
            InitializeComponent();

            formPadre  = (PrincipalForm)Padre;
            copiaTexto = formPadre.textoSegmentado;

            grosorTrazoNumericicUpDown.Value    = formPadre.perfilActual.segmentacion.grosorMedioTrazo;
            incrementoMinimoNumericUpDown.Value = (decimal)formPadre.perfilActual.segmentacion.incrementoMinimoCaracteres;
        }
Beispiel #9
0
        private int umbral;//Porque desde el hilo background no se puede acceder a la propiedad Value de la TrackBar

        public UmbralizadoForm(PrincipalForm Padre)
        {
            InitializeComponent();

            formPadre  = (PrincipalForm)Padre;
            copiaTexto = formPadre.textoActual;

            umbralTrackBar.Value = formPadre.perfilActual.preprocesado.umbral;
            umbralTextBox.Text   = formPadre.perfilActual.preprocesado.umbral.ToString();
        }
Beispiel #10
0
        public LineasForm(PrincipalForm Padre)
        {
            InitializeComponent();

            formPadre  = (PrincipalForm)Padre;
            copiaTexto = formPadre.textoActual;

            interlineadoMedioNumericUpDown.Value = formPadre.perfilActual.segmentacion.interlineadoMedio;
            incrementoMinimoNumericUpDown.Value  = formPadre.perfilActual.segmentacion.incrementoMinimoLineas;
        }
Beispiel #11
0
        public EscaladoForm(PrincipalForm Padre)
        {
            InitializeComponent();

            formPadre  = (PrincipalForm)Padre;
            copiaTexto = formPadre.textoActual;

            altoNumericUpDown.Value      = copiaTexto.GetAlto();
            anchoNumericUpDown.Value     = copiaTexto.GetAncho();
            proporcionesCheckBox.Checked = formPadre.perfilActual.preprocesado.mantenerProporcion;
        }
Beispiel #12
0
        private void corregirSlopeBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            formPadre.habilitarMenus("Correción Slope");

            if (formPadre.textoSegmentado != copiaTexto)
            {
                copiaTexto.LiberarTextoManejado();
                copiaTexto = formPadre.textoSegmentado;
            }

            habilitarBotonCerrar(true);

            Close();
        }
Beispiel #13
0
        private void enderezadoBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            formPadre.habilitarMenus("Enderezado");

            if (formPadre.textoActual != copiaTexto)
            {
                copiaTexto.LiberarTextoManejado();
                copiaTexto = formPadre.textoActual;
            }

            habilitarBotonCerrar(true);

            Close();
        }
Beispiel #14
0
        private double grados;//Porque desde el hilo background no se puede acceder a la propiedad Value de la TrackBar

        public EnderezadoForm(PrincipalForm Padre)
        {
            InitializeComponent();

            formPadre  = (PrincipalForm)Padre;
            copiaTexto = formPadre.textoActual;

            direccion = 1;

            if (formPadre.estadoImagen == EstadoImagen.cargada)//La imagen no está umbralizada aún
            {
                automaticoRadioButton.Enabled = false;
            }
        }
Beispiel #15
0
        private void umbralizadoBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            formPadre.habilitarMenus("Umbralizado");

            if (formPadre.textoActual != copiaTexto)
            {
                copiaTexto.LiberarTextoManejado();
                copiaTexto = formPadre.textoActual;
            }

            formPadre.estadoImagen = EstadoImagen.umbralizada;

            habilitarBotonCerrar(true);

            Close();
        }
Beispiel #16
0
        private void obtenerCaracteresBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            formPadre.habilitarMenus("Segmentado caracteres");

            if (formPadre.textoSegmentado != copiaTexto)
            {
                copiaTexto.LiberarTextoManejado();
                copiaTexto = formPadre.textoSegmentado;
            }

            formPadre.estadoImagenSegmentada = EstadoImagen.caracteresSegmentados;

            habilitarBotonCerrar(true);

            Close();
        }
Beispiel #17
0
        private void lineasSegmentadasPictureBox_MouseClick(object sender, MouseEventArgs e)
        {
            int linea = textoEscalado.GetLinea(e.Y, e.X);

            textoEscalado.LiberarTextoManejado();

            if (fusionar)
            {
                if (lineaSeleccionada < linea)
                {
                    copiaTexto.Fusionar(lineaSeleccionada, linea);
                }
                else
                {
                    copiaTexto.Fusionar(linea, lineaSeleccionada);
                }
            }

            textoEscalado = copiaTexto.Copia();
            textoEscalado.EscalacionLineal(((double)lineasSegmentadasPictureBox.Size.Width) / copiaTexto.GetAncho(), ((double)lineasSegmentadasPictureBox.Size.Height) / copiaTexto.GetAlto());

            if (!fusionar && linea != -1 && linea != lineaSeleccionada)
            {
                textoEscalado.PintarLinea(linea);
                lineaSeleccionada = linea;
            }
            else
            {
                lineaSeleccionada = -1;
            }

            IntPtr ptrDIB;      //Puntero al DIB
            IntPtr ptrMapaBits; //Puntero al mapa de bits en sí (nos saltamos el bitmapinfoheader y la paleta, si la hay)

            unsafe              //Zona no segura (transformación de punteros C++ a C#)
            {
                ptrDIB = (IntPtr)textoEscalado.GetDIB();

                ptrMapaBits = (IntPtr)textoEscalado.GetMapaBits();
            }

            lineasSegmentadasPictureBox.Image = PrincipalForm.BitmapFromDIB(ptrDIB, ptrMapaBits);

            fusionar = false;
        }
Beispiel #18
0
        //Métodos Segmentado Automático
        private void automaticoSegmentacionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (textoSegmentado != null)
            {
                textoSegmentado.LiberarTextoManejado();
            }

            textoSegmentado = textoActual.Copia();

            deshabilitarMenus("Segmentado automático");

            if (estadoImagenSegmentada != EstadoImagen.nula)
            {
                imagenSegmentada.habilitarBotonCerrar(false);
            }

            segmentadoAutomaticoBackgroundWorker.RunWorkerAsync();
        }
Beispiel #19
0
        //Métodos

        //Constructor
        public PrincipalForm()
        {
            InitializeComponent();

            //Inicializaciones
            textoActual  = new TextoManejado();
            estadoImagen = EstadoImagen.nula;

            textoSegmentado = new TextoManejado();

            escaner = new ConexionEscaner(this.Handle);

            if (!escaner.Inicializar())
            {
                twainToolStripMenuItem.Enabled = false;
                twainToolStripButton.Enabled   = false;
            }

            imagenPreprocesada = new ImagenActualForm(Etapa.preprocesado);
            imagenSegmentada   = new ImagenActualForm(Etapa.segmentacion);

            conometro = new Stopwatch();

            perfilesLabel.Text = "Perfil actual:";
            TransparencyKey    = Color.Red;

            tareaToolStripStatusLabel.Alignment = ToolStripItemAlignment.Right;
            barraEstadoProgressBar.Alignment    = ToolStripItemAlignment.Right;

            CargarConfiguracion();

            ActualizarPerfiles();

            perfilesComboBox.SelectedItem = configuracionGeneral.perfilInicial;

            CargarPerfil();

            if (perfilActual.general.iniciarMaximizado)
            {
                WindowState = FormWindowState.Maximized;
            }
        }
Beispiel #20
0
        private void dividirButton_Click(object sender, EventArgs e)
        {
            copiaTexto.Dividir(lineaSeleccionada);

            textoEscalado.LiberarTextoManejado();

            textoEscalado = copiaTexto.Copia();
            textoEscalado.EscalacionLineal(((double)lineasSegmentadasPictureBox.Size.Width) / copiaTexto.GetAncho(), ((double)lineasSegmentadasPictureBox.Size.Height) / copiaTexto.GetAlto());

            IntPtr ptrDIB;      //Puntero al DIB
            IntPtr ptrMapaBits; //Puntero al mapa de bits en sí (nos saltamos el bitmapinfoheader y la paleta, si la hay)

            unsafe              //Zona no segura (transformación de punteros C++ a C#)
            {
                ptrDIB = (IntPtr)textoEscalado.GetDIB();

                ptrMapaBits = (IntPtr)textoEscalado.GetMapaBits();
            }

            lineasSegmentadasPictureBox.Image = PrincipalForm.BitmapFromDIB(ptrDIB, ptrMapaBits);

            lineaSeleccionada = -1;
        }