Skip to content

Commit

Permalink
Korsetme Uchurlar ULY gha ozgertildi
Browse files Browse the repository at this point in the history
  • Loading branch information
gheyret authored Aug 20, 2022
1 parent d139b75 commit 5fffee4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 36 deletions.
18 changes: 9 additions & 9 deletions MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 16 additions & 27 deletions MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,35 +61,30 @@ void MainFormFormClosing(object sender, FormClosingEventArgs e)

async void ButtonRight(object sender, EventArgs e)
{
butRecognize.Enabled = false;
butNext.Enabled = false;
butDeskew.Enabled = false;

EnableAll(false);
Bitmap roibmp;
Pix roipix;
Rectangle roi = ramka.getRoi();
Cursor=Cursors.WaitCursor;
roibmp = ramka.Image.Clone(roi,ramka.Image.PixelFormat);
roibmp.SetResolution(400,400);
// roibmp.SetResolution(400,400);
roipix = PixConverter.ToPix(roibmp).Deskew().Scale(4.0f,4.0f);
roibmp.Dispose();

Task<string> ocr = Task.Run<string>(() =>{
return DoOCR(roipix);
});
string txt = await ocr;
roipix.Dispose();

if(gOcrTxtForm==null || gOcrTxtForm.IsDisposed){
gOcrTxtForm=new OCRText();
gOcrTxtForm.Show();
}
gOcrTxtForm.SetText(txt);

butRecognize.Enabled = true;
butNext.Enabled = true;
butDeskew.Enabled = true;
Cursor=Cursors.Default;
roipix.Dispose();
EnableAll(false);
}


Expand Down Expand Up @@ -152,7 +147,7 @@ void Label1Click(object sender, EventArgs e)
{
FolderBrowserDialog dlg = new FolderBrowserDialog();
dlg.SelectedPath = label1.Text;
dlg.Description = "Select Image Folder:";
dlg.Description = "Resimler bar qisquchni tallang:";
dlg.ShowNewFolderButton = false;

DialogResult drs = dlg.ShowDialog(this);
Expand Down Expand Up @@ -191,7 +186,7 @@ void MainFormShown(object sender, EventArgs e)
chkLang.SelectedIndex = ind;
}
else{
MessageBox.Show("No Language Data", "Uyghur OCR",MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("Hechqandaq Model yoq iken.", "Uyghurche OCR",MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

Expand All @@ -208,14 +203,14 @@ void ButPdftoImageClick(object sender, EventArgs e)
Directory.CreateDirectory(path);
}

butPDF.Enabled=false;
EnableAll(false);
this.Cursor=System.Windows.Forms.Cursors.WaitCursor;
if(ExtractImage(pdfFile,path)){
label1.Text = path;
listAllImg();
}
butPDF.Enabled=true;
this.Cursor=System.Windows.Forms.Cursors.Arrow;
EnableAll(true);
}

private bool ExtractImage(String pdfFile, string imgPath)
Expand All @@ -235,25 +230,18 @@ void Button2Click(object sender, EventArgs e)
{
Bitmap roibmp;
Pix roipix;
butRecognize.Enabled = false;
butNext.Enabled = false;
butDeskew.Enabled = false;
EnableAll(false);
Rectangle roi = ramka.getRoi();
Cursor=Cursors.WaitCursor;
roibmp = ramka.Image.Clone(roi,ramka.Image.PixelFormat);
// roibmp.SetResolution(00,400);

roipix = PixConverter.ToPix(roibmp);
roipix = PixConverter.ToPix(roibmp).Deskew();
roibmp.Dispose();

Pix roipix1 = roipix.Deskew();
Bitmap newbm = PixConverter.ToBitmap(roipix1);
System.Diagnostics.Debug.WriteLine(roipix.XRes + " = " + roipix.YRes);
Bitmap newbm = PixConverter.ToBitmap(roipix);
roipix.Dispose();
ramka.Image = newbm;
Cursor=Cursors.Default;
butRecognize.Enabled = true;
butNext.Enabled = true;
butDeskew.Enabled = true;
EnableAll(true);
}

void MainFormDragEnter(object sender, DragEventArgs e)
Expand Down Expand Up @@ -281,7 +269,7 @@ void ChkLangSelectedIndexChanged(object sender, EventArgs e)
lang = "ukij+uig";
}
gOcr= new TesseractEngine(@".\tessdata",lang,EngineMode.LstmOnly);
Text ="Simple Uyghur OCR using Tessract[V" + gOcr.Version + "]";
Text ="Addiy Uyghurche OCR(Tessract OCR[V" + gOcr.Version + "] Neshri Ishlitilgen)";
}

void EnableAll(bool vv){
Expand All @@ -294,6 +282,8 @@ void EnableAll(bool vv){
groupBox1.Enabled = vv;
groupBox2.Enabled = vv;
ramka.Enabled = vv;
butRecAll.Enabled = vv;

}


Expand Down Expand Up @@ -326,7 +316,6 @@ async void Button3Click(object sender, EventArgs e)
while(butRecAll.Text.Equals("Stop")){
Rectangle roi = ramka.getRoi();
roibmp = ramka.Image.Clone(roi,ramka.Image.PixelFormat);
roibmp.SetResolution(400,400);
roipix = PixConverter.ToPix(roibmp).Deskew().Scale(4.2f,4.2f);

roibmp.Dispose();
Expand Down

0 comments on commit 5fffee4

Please sign in to comment.