private void SetNoiseEraseParam() { EraseNoiseParams env = new EraseNoiseParams(); DocumentSDKDocumentType docType = (DocumentSDKDocumentType)GetEnumSelected(cmbDocType, typeof(DocumentSDKDocumentType)); env.DocumentType = docType; DocumentSDKLevel level = (DocumentSDKLevel)GetEnumSelected(cmbLevel, typeof(DocumentSDKLevel)); env.Level = level; DocumentSDKFastMode faseMode = (DocumentSDKFastMode)GetEnumSelected(cmbFastMode, typeof(DocumentSDKFastMode)); env.FastMode = faseMode; DocumentSDKNoiseType noiseType = (DocumentSDKNoiseType)GetEnumSelected(cmbNoiseType, typeof(DocumentSDKNoiseType)); env.NoiseType = noiseType; if (this.chkAutoSize.Checked) { env.MaxNoiseSize = DocumentSDKDefinition.ENSH_MDS_AUTO; } else { env.MaxNoiseSize = (short)numMaxNoiseSize.Value; } OcrSDK.SetParams(env); }
private void mnuRotateNone_Click(object sender, EventArgs e) { try { ClearMessag(); Image processImg = this.picChg.Image == null ? this.picOrg.Image : this.picChg.Image; if (processImg == null) { return; } Bitmap targetImg = (Bitmap)MakeBinImage((Bitmap)processImg); counter.Start(); Image chgimg = OcrSDK.RotateImage(targetImg, 0); chgimg.Save(@"c:\chgimg0.png", ImageFormat.Png); //Image chgimg = (Image)targetImg.Clone(); //chgimg.RotateFlip(RotateFlipType.RotateNoneFlipNone); counter.End(); this.picOrg.Image = chgimg; this.picOrg.ShowRectCross = false; } catch (DocumentSDKCommon.DocumentSDKException ex) { string code = string.Join(",", ex.GetErrorNoList()); MessageBox.Show(code); } }
private void button3_Click(object sender, EventArgs e) { if (this.SelectedRow != -1) { if (cmbOmrType.SelectedValue == null) { MessageBox.Show("OMR種別を選択してください。"); } PictureBox pic = this.tableLayoutPanel1.GetControlFromPosition(1, this.SelectedRow) as PictureBox; if (pic == null) { return; } Image resultImg = pic.Image; TransArea area = (TransArea)pic.Tag; Image masterImage = this.TargetImage; Rectangle masterArea = area.TransRect; OcrSDK ocrSdk = new OcrSDK(); DocumentSDKCheckType omrType = (DocumentSDKCheckType)cmbOmrType.SelectedValue; Rectangle markArea = new Rectangle() { X = area.CharRect.X - area.TransRect.X, Y = area.CharRect.Y - area.TransRect.Y, Width = area.CharRect.X - area.TransRect.X + area.CharRect.Width, Height = area.CharRect.Y - area.TransRect.Y + area.CharRect.Height, }; if (omrType == DocumentSDKCheckType.OMR_CT_UNKNOWN) { markArea = new Rectangle() { X = 0, Y = 0, Width = area.TransRect.Width - 1, Height = area.TransRect.Height - 1, }; } var result = ocrSdk.executeOmr(resultImg, omrType, markArea, masterImage, masterArea); this.txtResult.Text = string.Format("Check_res:{0} \n Score:{1}", result.one_res[0].check_res.ToString(), result.one_res[0].score); } }
/// <summary> /// EraseNoise /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { ClearMessag(); Image processImg = this.picChg.Image == null ? this.picOrg.Image : this.picChg.Image; if (processImg == null) { return; } Bitmap targetImg = CloneIMage((Bitmap)processImg); counter.Start(); Image chgimg = OcrSDK.EraseNoise(targetImg); counter.End(); this.picOrg.Image = chgimg; this.picOrg.ShowRectCross = false; }
private void CanvasPicture_MouseDoubleClick(object sender, MouseEventArgs e) { if (!this.AllowAddFrame || !this.ShowFrames) { return; } if (this.Image == null) { return; } Bitmap bmp = new Bitmap(this.Image); Point selPos = UnzoomPoint(new Point(e.X, e.Y)); Rectangle rect = OcrSDK.GetFrameByPoint(bmp, selPos); this.Frames.Add(rect); this.Refresh(); }
/// <summary> /// 活字OCRを使用した天地補正 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsbExecuteDDirRotate_Click(object sender, EventArgs e) { try { ClearMessag(); OcrSDK ocrSdk = new OcrSDK(); using (Image targetImg = (Image)this.picOrg.Image.Clone()) { this.counter.Start("天地補正"); Image chgImg = ocrSdk.ExecuteDDirRotate(targetImg); this.counter.End(); this.picOrg.Image = (Image)chgImg.Clone(); chgImg.Dispose(); } } catch (DocumentSDKCommon.DocumentSDKException ex) { string code = string.Join(",", ex.GetErrorNoList()); MessageBox.Show(code); } }