Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {$I SCARExt\SCARExt.scar}
- {$L project1.dll}
- function GetBitmapColorTPA(bmp: TSCARBitmap; color: Integer;Tol:Integer): TPointArray;
- var
- client: TSCARClient;
- begin
- Client := SetClient(TSCARBitmapClient.Create(bmp));
- FindColorTolEx(Result, color, 0, 0, (bmp.Width - 1), (bmp.Height - 1), Tol);
- SetClient(client).Free;
- end;
- procedure Test;
- var
- t:Integer;
- TPA,Skel: TPointArray;
- Img:T2DIntArray;
- bmp: TSCARBitmap;
- png: TPNGFile;
- begin
- bmp := TSCARBitmap.Create('');
- png := TPNGFile.Create;
- png.LoadFromFile(ScriptPath + 'small_ints2.png');
- bmp := png.ToBitmap;
- png.Free;
- begin
- //bmp.ResizeEx(bmp.width*5, bmp.height*5, brBilinear);
- t := GetTimeRunning;
- Img := XT_Bmp2Matrix(bmp,False);
- XT_ImResize(Img,bmp.width*5, bmp.height*6, rm_bilinear);
- Img := XT_ImThresholdAdaptive(Img, 0, 255, TM_Mean, 65);
- Img := XT_ImBlurFilter(Img,5);
- Img := XT_ImBlurFilter(Img,3);
- Img := XT_ImThresholdAdaptive(Img, 0, 255, TM_MinMax, 0);
- XT_BmpSetData(bmp, Img, True);
- TPA := GetBitmapColorTPA(bmp, 255, 0);
- Skel := XT_TPASkeleton(TPA, 2, 6); //Skeletonize for smooth chars
- Skel := XT_TPAExpand(Skel, 1); //More stable.
- Bmp.Clear(0);
- bmp.SetPixels(Skel,255);
- WriteLn(GetTimeRunning - t);
- DebugBitmap(bmp);
- bmp.SaveToPng(ScriptPath + 'small_ints.png');
- bmp.Free;
- SetTesserPath(ScriptPath + 'Tesseract-OCR\Tesseract.exe');
- WriteLn(Tesseract(ScriptPath + 'small_ints.png', ScriptPath + 'temp.txt'));
- end;
- end;
- begin
- Test;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement