Это OCR.Моя система позволяет пользователям вводить изображение, состоящее из символа, заполнять определенный символ и описание.Входные данные будут вставлены в базу данных.Вот мой вопрос: если пользователь хочет ввести изображение с тем же символом, но другим шрифтом, ему не нужно повторно вводить символ и описание.им может просто понадобиться использовать кнопку импорта, которая может импортировать существующее изображение, чтобы система знала, что оба символа одинаковы.Таким образом, когда пользователь вводит изображение для сканирования системой, система может знать символ, который написан другим шрифтом.
Тогда, как я кодирую систему, чтобы сообщить системе, что символ является тем же, когда пользователь импортирует существующий?
регион Библиотека обучения (Tab2_Component)
private void Browse1_Click(object sender, EventArgs e)
{
try
{
//open file dialog for the users to input image to the system
OpenFileDialog open = new OpenFileDialog();
//Set default directory to the open file dialog
open.InitialDirectory = @"C:\Users\Shen\Desktop";
//limit input image type for the users
open.Filter = "Image Files(*.jpg; *.jpeg)|*.jpg; *.jpeg";
if (open.ShowDialog() == DialogResult.OK)
{
singleFileInfo = new FileInfo(open.FileName);
string dirName = System.IO.Path.GetDirectoryName(open.FileName);
imgLoc.Text = open.FileName;
}
}
catch (Exception)
{
throw new ApplicationException("Failed loading image");
}
}
private void typeRadio_CheckedChanged(object sender, EventArgs e)
{
//set the textbox to editable and the "import" button unclickable when user select the "Type Character" radio button
CharTB.ReadOnly = false;
ImportButton.Enabled = false;
DescTB.ReadOnly = false;
}
private void importRadio_CheckedChanged(object sender, EventArgs e)
{
//set the "import" button to clickable and the textbox to uneditable when the user select "Import Existing" radio button
ImportButton.Enabled = true;
CharTB.ReadOnly = true;
DescTB.ReadOnly = true;
}
private void AddBt_Click(object sender, EventArgs e)
{
con = new System.Data.SqlClient.SqlConnection();
con.ConnectionString = "Data Source=SHEN-PC\\SQLEXPRESS;Initial Catalog=CharacterImage;Integrated Security=True";
con.Open();
//set variables to the textbox.text
String ImageLocation = imgLoc.Text;
String typeName = CharTB.Text;
String ImportExt = importTB.Text;
String CharDesc = DescTB.Text;
String fileName = System.IO.Path.GetFileName(ImageLocation);
String savePath = @"C:\Users\Shen\Desktop\LenzOCR\LenzOCR\WindowsFormsApplication1\ImageFile\" + fileName;
inputImageBox.Image = Image.FromFile(ImageLocation);
inputImageBox.Image.Save(savePath);
String insertData = "INSERT INTO CharacterImage(ImageName, ImagePath, Character, CharacterDescription) VALUES('"+fileName+"', '"+savePath+"', '"+typeName+"', '"+CharDesc+"')";
SqlCommand cmd = new SqlCommand(insertData, con);
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Character Inserted", "Insert Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
descDisplayTB.Text = typeName + "\r\n\r\n" + CharDesc;
//set the Textbox to empty and the "Type Character" textboxt to uneditable
//and the "Import" button to unclickable after user add the data into the database
imgLoc.Text = "";
CharTB.Text = "";
importTB.Text = "";
DescTB.Text = "";
CharTB.ReadOnly = true;
ImportButton.Enabled = false;
}
private void button2_Click(object sender, EventArgs e)
{
descDisplayTB.Text = "";
pictureBox1.Image = null;
}
#endregion