Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
gheyret authored Mar 16, 2021
1 parent e9d3eab commit a226043
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
37 changes: 21 additions & 16 deletions ocr/OCRForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,28 @@ async void ButtonRight(object sender, EventArgs e)
gOcr.DefaultPageSegMode = PageSegMode.SingleBlock;
}
Invalidate();
Bitmap roibmp;
Pix roipix;
Rectangle roi = ramka.getRoi();
Cursor=Cursors.WaitCursor;
ramka.Enabled = false;
roibmp = ramka.Image.Clone(roi,ramka.Image.PixelFormat);
roipix = PixConverter.ToPix(roibmp);
roibmp.Dispose();
roipix = roipix.Deskew();

Task<string> ocr = Task.Run<string>(() =>{return DoOCR(roipix);});
string txt = await ocr;
roipix.Dispose();
try{
Bitmap roibmp;
Pix roipix;
Rectangle roi = ramka.getRoi();
Cursor=Cursors.WaitCursor;
ramka.Enabled = false;
roibmp = ramka.Image.Clone(roi,ramka.Image.PixelFormat);
roipix = PixConverter.ToPix(roibmp);
roibmp.Dispose();
roipix = roipix.Deskew();

Task<string> ocr = Task.Run<string>(() =>{return DoOCR(roipix);});
string txt = await ocr;
roipix.Dispose();
ramka.Enabled = true;
gEditor.AppendText(txt);
Cursor=Cursors.Default;
}
catch(Exception ee){
System.Diagnostics.Debug.WriteLine(ee.Message);
}
gRunning = false;
ramka.Enabled = true;
gEditor.AppendText(txt);
Cursor=Cursors.Default;
Invalidate();
}

Expand Down
2 changes: 1 addition & 1 deletion ocr/ResimRamka.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public void SetROI(int x, int y, int w, int h)
}

public Rectangle getRoi(){
if(_fW!=-1 && _fH!=-1)
if(_fW>0 && _fH>0)
{
return new Rectangle(_selX,_selY,_fW,_fH);
}
Expand Down

0 comments on commit a226043

Please sign in to comment.