From 5fffee4f2f98de269e55fa098bae582a3ce7bc7b Mon Sep 17 00:00:00 2001 From: Uyghur Date: Sat, 20 Aug 2022 12:26:40 +0900 Subject: [PATCH] Korsetme Uchurlar ULY gha ozgertildi --- MainForm.Designer.cs | 18 +++++++++--------- MainForm.cs | 43 ++++++++++++++++--------------------------- 2 files changed, 25 insertions(+), 36 deletions(-) diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index 344dc7d..a3d4085 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -76,7 +76,7 @@ private void InitializeComponent() this.butRecognize.Name = "butRecognize"; this.butRecognize.Size = new System.Drawing.Size(143, 32); this.butRecognize.TabIndex = 37; - this.butRecognize.Text = "Recognize"; + this.butRecognize.Text = "Tonu"; this.butRecognize.UseVisualStyleBackColor = true; this.butRecognize.Click += new System.EventHandler(this.ButtonRight); // @@ -87,7 +87,7 @@ private void InitializeComponent() this.butNext.Name = "butNext"; this.butNext.Size = new System.Drawing.Size(143, 32); this.butNext.TabIndex = 40; - this.butNext.Text = "Next"; + this.butNext.Text = "Kéyinkisi"; this.butNext.UseVisualStyleBackColor = true; this.butNext.Click += new System.EventHandler(this.ButtonNextClick); // @@ -143,7 +143,7 @@ private void InitializeComponent() this.butPDF.Name = "butPDF"; this.butPDF.Size = new System.Drawing.Size(181, 32); this.butPDF.TabIndex = 43; - this.butPDF.Text = "PDF to Image"; + this.butPDF.Text = "PDF ni Resimge"; this.butPDF.UseVisualStyleBackColor = true; this.butPDF.Click += new System.EventHandler(this.ButPdftoImageClick); // @@ -167,7 +167,7 @@ private void InitializeComponent() this.groupBox1.Size = new System.Drawing.Size(153, 117); this.groupBox1.TabIndex = 45; this.groupBox1.TabStop = false; - this.groupBox1.Text = "Segmentation mode"; + this.groupBox1.Text = "Bet Qurulmisi"; // // rdSingle // @@ -177,7 +177,7 @@ private void InitializeComponent() this.rdSingle.Size = new System.Drawing.Size(141, 24); this.rdSingle.TabIndex = 1; this.rdSingle.TabStop = true; - this.rdSingle.Text = "Single block"; + this.rdSingle.Text = "Birla Bölek"; this.rdSingle.UseVisualStyleBackColor = true; // // rdAuto @@ -186,7 +186,7 @@ private void InitializeComponent() this.rdAuto.Name = "rdAuto"; this.rdAuto.Size = new System.Drawing.Size(141, 24); this.rdAuto.TabIndex = 0; - this.rdAuto.Text = "Automatic"; + this.rdAuto.Text = "Özüng Tap"; this.rdAuto.UseVisualStyleBackColor = true; // // butDeskew @@ -196,7 +196,7 @@ private void InitializeComponent() this.butDeskew.Name = "butDeskew"; this.butDeskew.Size = new System.Drawing.Size(143, 32); this.butDeskew.TabIndex = 46; - this.butDeskew.Text = "Deskew"; + this.butDeskew.Text = "Qiysiqni Tüzle"; this.butDeskew.UseVisualStyleBackColor = true; this.butDeskew.Click += new System.EventHandler(this.Button2Click); // @@ -228,7 +228,7 @@ private void InitializeComponent() this.butRecAll.Name = "butRecAll"; this.butRecAll.Size = new System.Drawing.Size(143, 32); this.butRecAll.TabIndex = 48; - this.butRecAll.Text = "Recognize All"; + this.butRecAll.Text = "Hemmini Tonu"; this.butRecAll.UseVisualStyleBackColor = true; this.butRecAll.Click += new System.EventHandler(this.Button3Click); // @@ -249,7 +249,7 @@ private void InitializeComponent() this.Controls.Add(this.butNext); this.Controls.Add(this.butRecognize); this.Name = "MainForm"; - this.Text = "Simple Uyghur OCR using Tessract"; + this.Text = "Addiy Uyghurche OCR"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainFormFormClosing); this.Load += new System.EventHandler(this.MainFormLoad); this.Shown += new System.EventHandler(this.MainFormShown); diff --git a/MainForm.cs b/MainForm.cs index 92f6f27..a62b9b0 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -61,16 +61,13 @@ 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(); @@ -78,6 +75,7 @@ async void ButtonRight(object sender, EventArgs e) return DoOCR(roipix); }); string txt = await ocr; + roipix.Dispose(); if(gOcrTxtForm==null || gOcrTxtForm.IsDisposed){ gOcrTxtForm=new OCRText(); @@ -85,11 +83,8 @@ async void ButtonRight(object sender, EventArgs e) } gOcrTxtForm.SetText(txt); - butRecognize.Enabled = true; - butNext.Enabled = true; - butDeskew.Enabled = true; Cursor=Cursors.Default; - roipix.Dispose(); + EnableAll(false); } @@ -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); @@ -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); } } @@ -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) @@ -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) @@ -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){ @@ -294,6 +282,8 @@ void EnableAll(bool vv){ groupBox1.Enabled = vv; groupBox2.Enabled = vv; ramka.Enabled = vv; + butRecAll.Enabled = vv; + } @@ -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();