2011-04-10 36 views
0

這是OCR。我的系統允許用戶輸入一個由字符組成的圖像,填入特定的字符和描述。輸入數據將被插入到數據庫中。這是我的問題,如果用戶想要輸入具有相同字符但字體不同的圖像,則不需要重新輸入字符以及描述。他們可能只需要使用導入按鈕,它可以導入現有的圖像,讓系統知道兩個字符是相同的。因此,當用戶輸入要掃描的系統圖像時,系統可能會知道不同字體的字符。c#sql查詢問題

那麼我如何編寫系統來通知系統,當用戶導入現有的字符是相同的?

區圖書館培訓(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 

回答

0

原諒我,如果我誤解了你的問題,但似乎你需要一個多表數據庫做

一個例子

  1. 用戶+字體細節(我不明白什麼字體細節)
  2. 上傳詳細信息,例如掃描的項目

在數據庫方面,它也許更有用做

  1. 用戶
  2. 圖像細節
  3. 鏈接USER_ID之間image_id

除了復位描述和人物等,你可以做的是詢問他們是否想要基於相同的圖像插入另一個。

我沒有真正理解這個的字體部分。

+0

我的意思是,用戶輸入圖像,字符和描述。然後,如果用戶想輸入具有相同字符和decsription的另一個圖像,則用戶只需要導入現有的圖像以告訴系統該字符和描述是相同的,以便他們不需要再次輸入字符和描述。 – joonshen 2011-04-10 15:18:52