//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(); }
private void interlineadoMedioNumericUpDown_ValueChanged(object sender, EventArgs e) { if (previsualizarCheckBox.Checked) { if (formPadre.textoSegmentado != copiaTexto) { formPadre.textoSegmentado.LiberarTextoManejado(); } formPadre.textoSegmentado = copiaTexto.Copia(); formPadre.textoSegmentado.SegmentacionLineas((int)interlineadoMedioNumericUpDown.Value, (int)incrementoMinimoNumericUpDown.Value); formPadre.CargarImagenSegmentada(); } }
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); }
private void grosorTrazoNumericicUpDown_ValueChanged(object sender, EventArgs e) { if (previsualizarCheckBox.Checked) { if (formPadre.textoSegmentado != copiaTexto) { formPadre.textoSegmentado.LiberarTextoManejado(); } formPadre.textoSegmentado = copiaTexto.Copia(); formPadre.textoSegmentado.SegmentacionCaracteres((int)grosorTrazoNumericicUpDown.Value, (double)incrementoMinimoNumericUpDown.Value, true); formPadre.CargarImagenSegmentada(); } }
private void distanciaMinimaNumericUpDown_ValueChanged(object sender, EventArgs e) { if (previsualizarCheckBox.Checked) { if (formPadre.textoSegmentado != copiaTexto) { formPadre.textoSegmentado.LiberarTextoManejado(); } formPadre.textoSegmentado = copiaTexto.Copia(); formPadre.textoSegmentado.CorregirSlope((int)distanciaMinimaNumericUpDown.Value); formPadre.CargarImagenSegmentada(); } }
private void umbralTextBox_TextChanged(object sender, EventArgs e) { if (previsualizarCheckBox.Checked) { if (formPadre.textoActual != copiaTexto) { formPadre.textoActual.LiberarTextoManejado(); } formPadre.textoActual = copiaTexto.Copia(); formPadre.textoActual.Umbralizar(umbralTrackBar.Value); formPadre.CargarImagen(); } }
private void espaciadoMedioNumericUpDown_ValueChanged(object sender, EventArgs e) { if (previsualizarCheckBox.Checked) { if (formPadre.textoSegmentado != copiaTexto) { formPadre.textoSegmentado.LiberarTextoManejado(); } formPadre.textoSegmentado = copiaTexto.Copia(); formPadre.textoSegmentado.SegmentacionPalabras((int)espaciadoMedioNumericUpDown.Value, true); formPadre.CargarImagenSegmentada(); } }
//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); }
private void derechaRadioButton_CheckedChanged(object sender, EventArgs e) { direccion = 1; if (previsualizarCheckBox.Checked) { if (formPadre.textoActual != copiaTexto) { formPadre.textoActual.LiberarTextoManejado(); } formPadre.textoActual = copiaTexto.Copia(); if (manualRadioButton.Checked) { formPadre.textoActual.Rotacion(direccion * gradosTrackBar.Value); } else { formPadre.textoActual.Enderezar(); } formPadre.CargarImagen(); } }
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; }
//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(); }
private void anchoNumericUpDown_ValueChanged(object sender, EventArgs e) { if (proporcionesCheckBox.Checked) { altoNumericUpDown.Value = (anchoNumericUpDown.Value * copiaTexto.GetAlto()) / copiaTexto.GetAncho(); } if (previsualizarCheckBox.Checked) { if (formPadre.textoActual != copiaTexto) { formPadre.textoActual.LiberarTextoManejado(); } formPadre.textoActual = copiaTexto.Copia(); formPadre.textoActual.Escalacion((double)anchoNumericUpDown.Value / copiaTexto.GetAncho(), (double)altoNumericUpDown.Value / copiaTexto.GetAlto()); formPadre.CargarImagen(); } }