From e9d3eabf453909c63999b7ac2a9696967535659e Mon Sep 17 00:00:00 2001 From: Uyghur Date: Tue, 16 Mar 2021 14:10:47 +0900 Subject: [PATCH] Add files via upload --- ocr/OCRForm.Designer.cs | 40 ++++++++++++++++++++++++++++++++++++++++ ocr/OCRForm.cs | 29 ++++++++++++++++++++++++++++- 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/ocr/OCRForm.Designer.cs b/ocr/OCRForm.Designer.cs index 9e94db3..543be1d 100644 --- a/ocr/OCRForm.Designer.cs +++ b/ocr/OCRForm.Designer.cs @@ -45,6 +45,9 @@ private void InitializeComponent() this.chkEng = new System.Windows.Forms.CheckBox(); this.chkChi = new System.Windows.Forms.CheckBox(); this.chkRus = new System.Windows.Forms.CheckBox(); + this.label2 = new System.Windows.Forms.Label(); + this.radAuto = new System.Windows.Forms.RadioButton(); + this.radSingle = new System.Windows.Forms.RadioButton(); this.SuspendLayout(); // // butTonu @@ -140,12 +143,45 @@ private void InitializeComponent() this.chkRus.UseVisualStyleBackColor = true; this.chkRus.CheckedChanged += new System.EventHandler(this.CheckedChanged); // + // label2 + // + this.label2.Location = new System.Drawing.Point(8, 179); + this.label2.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(170, 27); + this.label2.TabIndex = 50; + this.label2.Text = "Bet Qurulmisi:"; + this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // radAuto + // + this.radAuto.Checked = true; + this.radAuto.Location = new System.Drawing.Point(25, 209); + this.radAuto.Name = "radAuto"; + this.radAuto.Size = new System.Drawing.Size(153, 30); + this.radAuto.TabIndex = 51; + this.radAuto.TabStop = true; + this.radAuto.Text = "Ozung Tap"; + this.radAuto.UseVisualStyleBackColor = true; + // + // radSingle + // + this.radSingle.Location = new System.Drawing.Point(25, 245); + this.radSingle.Name = "radSingle"; + this.radSingle.Size = new System.Drawing.Size(153, 30); + this.radSingle.TabIndex = 52; + this.radSingle.Text = "Birla Bolek"; + this.radSingle.UseVisualStyleBackColor = true; + // // OCRForm // this.AllowDrop = true; this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.ClientSize = new System.Drawing.Size(804, 578); + this.Controls.Add(this.radSingle); + this.Controls.Add(this.radAuto); + this.Controls.Add(this.label2); this.Controls.Add(this.chkRus); this.Controls.Add(this.chkChi); this.Controls.Add(this.chkEng); @@ -161,6 +197,7 @@ private void InitializeComponent() this.Name = "OCRForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Simple Uyghur OCR using Tessract"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OCRFormFormClosing); this.Load += new System.EventHandler(this.MainFormLoad); this.Shown += new System.EventHandler(this.OCRFormShown); this.DragDrop += new System.Windows.Forms.DragEventHandler(this.MainFormDragDrop); @@ -177,5 +214,8 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox chkEng; private System.Windows.Forms.CheckBox chkChi; private System.Windows.Forms.CheckBox chkRus; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.RadioButton radAuto; + private System.Windows.Forms.RadioButton radSingle; } } \ No newline at end of file diff --git a/ocr/OCRForm.cs b/ocr/OCRForm.cs index 9454861..a2c615d 100644 --- a/ocr/OCRForm.cs +++ b/ocr/OCRForm.cs @@ -51,12 +51,24 @@ void OCRFormPaint(object sender, PaintEventArgs e) else{ butAch.Enabled = !gRunning; butTonu.Enabled = !gRunning; + chkUyghur.Enabled = !gRunning; + chkEng.Enabled = !gRunning; + chkRus.Enabled = !gRunning; + chkChi.Enabled = !gRunning; + radAuto.Enabled = !gRunning; + radSingle.Enabled = !gRunning; } } async void ButtonRight(object sender, EventArgs e) { gRunning = true; + if(radAuto.Checked){ + gOcr.DefaultPageSegMode = PageSegMode.Auto; + } + else{ + gOcr.DefaultPageSegMode = PageSegMode.SingleBlock; + } Invalidate(); Bitmap roibmp; Pix roipix; @@ -105,8 +117,13 @@ void OCRFormShown(object sender, EventArgs e) chkEng.Text = MainForm.gLang.GetText("In’glizche"); chkChi.Text = MainForm.gLang.GetText("Xenzuche"); chkRus.Text = MainForm.gLang.GetText("Slawyanche"); + radAuto.Text = MainForm.gLang.GetText("Özüng Tap"); + radSingle.Text = MainForm.gLang.GetText("Birla Bölek"); chkUyghur.Checked = true; + radAuto.Checked = true; + + if(gImgFile!=null){ Bitmap bimg = new Bitmap(gImgFile); @@ -180,12 +197,22 @@ void CheckedChanged(object sender, EventArgs e) if(lang.Length >=3){ gOcr= new TesseractEngine(@".\tessdata",lang,EngineMode.LstmOnly); - gOcr.DefaultPageSegMode = PageSegMode.SingleBlock; Text = MainForm.gLang.GetText("Uyghurche OCR(Resimdiki Yéziqni Tonush) Programmisi")+ "Tessract[v " + gOcr.Version + "]" + " neshrini ishletken"; } this.Cursor = Cursors.Default; Invalidate(); } + void OCRFormFormClosing(object sender, FormClosingEventArgs e) + { + if(gRunning){ + e.Cancel = true; + } + else{ + if(gOcr!=null){ + gOcr.Dispose(); + } + } + } } } \ No newline at end of file