mirror of
https://github.com/moparisthebest/Simba
synced 2025-01-30 23:00:18 -05:00
More OCR changes, but mainly OCRBench changes.
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@314 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
19abae25e1
commit
80ce9744c6
@ -7,7 +7,7 @@
|
||||
<TargetFileExt Value=""/>
|
||||
<Icon Value="0"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<ActiveEditorIndexAtStart Value="0"/>
|
||||
<ActiveEditorIndexAtStart Value="3"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<ProjectVersion Value=""/>
|
||||
@ -31,12 +31,12 @@
|
||||
<PackageName Value="LCL"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="9">
|
||||
<Units Count="11">
|
||||
<Unit0>
|
||||
<Filename Value="project1.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="project1"/>
|
||||
<UsageCount Value="24"/>
|
||||
<UsageCount Value="27"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="unit1.pas"/>
|
||||
@ -44,10 +44,10 @@
|
||||
<ComponentName Value="Form1"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Unit1"/>
|
||||
<CursorPos X="95" Y="72"/>
|
||||
<TopLine Value="44"/>
|
||||
<CursorPos X="64" Y="131"/>
|
||||
<TopLine Value="102"/>
|
||||
<EditorIndex Value="0"/>
|
||||
<UsageCount Value="24"/>
|
||||
<UsageCount Value="27"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
@ -58,9 +58,7 @@
|
||||
<UnitName Value="colourhistory"/>
|
||||
<CursorPos X="10" Y="457"/>
|
||||
<TopLine Value="437"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<UsageCount Value="12"/>
|
||||
<Loaded Value="True"/>
|
||||
<UsageCount Value="13"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="../SAMufasaGUI/testunit.pas"/>
|
||||
@ -78,25 +76,25 @@
|
||||
<CursorPos X="21" Y="52"/>
|
||||
<TopLine Value="32"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<UsageCount Value="12"/>
|
||||
<UsageCount Value="14"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<UnitName Value="ocr"/>
|
||||
<CursorPos X="10" Y="290"/>
|
||||
<TopLine Value="313"/>
|
||||
<CursorPos X="86" Y="342"/>
|
||||
<TopLine Value="315"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<UsageCount Value="12"/>
|
||||
<UsageCount Value="14"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit5>
|
||||
<Unit6>
|
||||
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
||||
<UnitName Value="bitmaps"/>
|
||||
<CursorPos X="49" Y="368"/>
|
||||
<TopLine Value="337"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<UsageCount Value="11"/>
|
||||
<CursorPos X="25" Y="436"/>
|
||||
<TopLine Value="416"/>
|
||||
<EditorIndex Value="6"/>
|
||||
<UsageCount Value="13"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit6>
|
||||
<Unit7>
|
||||
@ -105,7 +103,7 @@
|
||||
<CursorPos X="58" Y="184"/>
|
||||
<TopLine Value="160"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<UsageCount Value="11"/>
|
||||
<UsageCount Value="13"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit7>
|
||||
<Unit8>
|
||||
@ -114,127 +112,145 @@
|
||||
<TopLine Value="1205"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit8>
|
||||
<Unit9>
|
||||
<Filename Value="../../Units/MMLAddon/tpa.pas"/>
|
||||
<UnitName Value="tpa"/>
|
||||
<CursorPos X="68" Y="798"/>
|
||||
<TopLine Value="779"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<UsageCount Value="11"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit9>
|
||||
<Unit10>
|
||||
<Filename Value="../../Units/MMLCore/mufasatypesutil.pas"/>
|
||||
<UnitName Value="mufasatypesutil"/>
|
||||
<CursorPos X="1" Y="1"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit10>
|
||||
</Units>
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="65" Column="43" TopLine="33"/>
|
||||
<Caret Line="87" Column="27" TopLine="56"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="55" Column="70" TopLine="22"/>
|
||||
<Caret Line="72" Column="4" TopLine="56"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="54" Column="70" TopLine="22"/>
|
||||
<Caret Line="70" Column="70" TopLine="56"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="30" Column="60" TopLine="22"/>
|
||||
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
|
||||
<Caret Line="169" Column="23" TopLine="156"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="31" Column="60" TopLine="22"/>
|
||||
<Caret Line="71" Column="29" TopLine="44"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="32" Column="60" TopLine="22"/>
|
||||
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
|
||||
<Caret Line="184" Column="58" TopLine="160"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="31" Column="60" TopLine="22"/>
|
||||
<Caret Line="74" Column="107" TopLine="58"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="33" Column="60" TopLine="22"/>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="57" Column="33" TopLine="37"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="84" Column="50" TopLine="44"/>
|
||||
<Filename Value="../../Units/MMLAddon/tpa.pas"/>
|
||||
<Caret Line="30" Column="64" TopLine="25"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="81" Column="22" TopLine="60"/>
|
||||
<Filename Value="../../Units/MMLAddon/tpa.pas"/>
|
||||
<Caret Line="63" Column="20" TopLine="44"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="75" Column="33" TopLine="49"/>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="89" Column="20" TopLine="70"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="79" Column="15" TopLine="42"/>
|
||||
<Caret Line="94" Column="57" TopLine="71"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
||||
<Caret Line="98" Column="21" TopLine="75"/>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="96" Column="57" TopLine="71"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="31" Column="54" TopLine="25"/>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="98" Column="61" TopLine="82"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
|
||||
<Caret Line="180" Column="111" TopLine="157"/>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="114" Column="13" TopLine="88"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
|
||||
<Caret Line="181" Column="13" TopLine="160"/>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="96" Column="61" TopLine="77"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
|
||||
<Caret Line="57" Column="51" TopLine="36"/>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="103" Column="10" TopLine="77"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="72" Column="83" TopLine="57"/>
|
||||
<Caret Line="102" Column="8" TopLine="84"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="78" Column="38" TopLine="65"/>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="42" Column="36" TopLine="25"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="42" Column="34" TopLine="25"/>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="108" Column="47" TopLine="84"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="78" Column="70" TopLine="62"/>
|
||||
<Caret Line="333" Column="23" TopLine="301"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="290" Column="10" TopLine="265"/>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="109" Column="28" TopLine="89"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="75" Column="17" TopLine="46"/>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="356" Column="43" TopLine="325"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="76" Column="21" TopLine="56"/>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="343" Column="17" TopLine="324"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="87" Column="27" TopLine="56"/>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="346" Column="11" TopLine="331"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="72" Column="4" TopLine="56"/>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="355" Column="37" TopLine="331"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="70" Column="70" TopLine="56"/>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="351" Column="33" TopLine="332"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
|
||||
<Caret Line="169" Column="23" TopLine="156"/>
|
||||
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
||||
<Caret Line="368" Column="49" TopLine="337"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="71" Column="29" TopLine="44"/>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="351" Column="37" TopLine="332"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
|
||||
<Caret Line="184" Column="58" TopLine="160"/>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="377" Column="57" TopLine="347"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
@ -256,7 +272,8 @@
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CustomOptions Value="-dOCRDEBUG"/>
|
||||
<CustomOptions Value="-dOCRDEBUG
|
||||
-dOCRTPA"/>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
|
@ -1,12 +1,13 @@
|
||||
object Form1: TForm1
|
||||
Left = 493
|
||||
Height = 305
|
||||
Top = 293
|
||||
Left = 462
|
||||
Height = 306
|
||||
Top = 264
|
||||
Width = 609
|
||||
ActiveControl = BitmapButton
|
||||
Caption = 'Form1'
|
||||
ClientHeight = 305
|
||||
ClientHeight = 306
|
||||
ClientWidth = 609
|
||||
OnCreate = FormCreate
|
||||
LCLVersion = '0.9.29'
|
||||
object OCRButton: TButton
|
||||
Left = 512
|
||||
@ -47,15 +48,33 @@ object Form1: TForm1
|
||||
Top = 112
|
||||
Width = 79
|
||||
Caption = 'Shadow?'
|
||||
OnChange = FShadowChange
|
||||
TabOrder = 3
|
||||
end
|
||||
object SplitEdit: TEdit
|
||||
Left = 512
|
||||
Height = 27
|
||||
Top = 168
|
||||
Width = 88
|
||||
TabOrder = 4
|
||||
Text = '1'
|
||||
end
|
||||
object SplitLabel: TLabel
|
||||
Left = 512
|
||||
Height = 18
|
||||
Top = 144
|
||||
Width = 88
|
||||
AutoSize = False
|
||||
Caption = 'Split Spacing:'
|
||||
ParentColor = False
|
||||
end
|
||||
object OCRFileOpen: TOpenDialog
|
||||
Filter = '.bmp'
|
||||
left = 528
|
||||
top = 192
|
||||
left = 416
|
||||
top = 277
|
||||
end
|
||||
object UpCharsDialog: TSelectDirectoryDialog
|
||||
left = 528
|
||||
top = 160
|
||||
left = 448
|
||||
top = 277
|
||||
end
|
||||
end
|
||||
|
@ -14,6 +14,8 @@ type
|
||||
|
||||
TForm1 = class(TForm)
|
||||
BitmapButton: TButton;
|
||||
SplitLabel: TLabel;
|
||||
SplitEdit: TEdit;
|
||||
FShadow: TCheckBox;
|
||||
PathButton: TButton;
|
||||
OCRButton: TButton;
|
||||
@ -21,6 +23,8 @@ type
|
||||
OCRFileOpen: TOpenDialog;
|
||||
UpCharsDialog: TSelectDirectoryDialog;
|
||||
procedure BitmapButtonClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FShadowChange(Sender: TObject);
|
||||
procedure OCRButtonClick(Sender: TObject);
|
||||
procedure PathButtonClick(Sender: TObject);
|
||||
private
|
||||
@ -48,6 +52,7 @@ Var
|
||||
x,y: integer;
|
||||
s: string;
|
||||
Shadow: boolean;
|
||||
Spacing: Integer;
|
||||
|
||||
begin
|
||||
if not FileExists(BitmapPath) then
|
||||
@ -70,6 +75,7 @@ begin
|
||||
Form1.Image1.Canvas.Brush.Color := 0;
|
||||
Form1.Image1.Canvas.Rectangle(0, 0, Form1.Image1.Canvas.Width, Form1.Image1.Canvas.Height);
|
||||
|
||||
// create and init client
|
||||
C := TClient.Create;
|
||||
bmp := TMufasaBitmap.Create;
|
||||
bmp.LoadFromFile(BitmapPath);
|
||||
@ -77,15 +83,39 @@ begin
|
||||
|
||||
Shadow :=FShadow.Checked;
|
||||
|
||||
try
|
||||
Spacing := StrToInt(Form1.SplitEdit.Text);
|
||||
except
|
||||
if shadow then
|
||||
begin
|
||||
MessageBox(0,pchar('Spacing could not be parsed.' +
|
||||
'Defaulting to 2' ), Pchar('Space Error'), MB_OK);
|
||||
Spacing := 2;
|
||||
end
|
||||
else
|
||||
begin
|
||||
MessageBox(0,pchar('Spacing could not be parsed.' +
|
||||
'Defaulting to 1' ), Pchar('Space Error'), MB_OK);
|
||||
Spacing := 1;
|
||||
end;
|
||||
end;
|
||||
writeln('Spacing: ' + Inttostr(spacing));
|
||||
// DS + .. + DS because InitOCR wants the directory of the Fonts, not UpChars
|
||||
// only.
|
||||
C.MOCR.InitTOCR(UpTextPath + DS + '..' + DS, Shadow);
|
||||
s := C.MOCR.GetUpTextAt(7,7, Shadow);
|
||||
s := C.MOCR.GetUpTextAtEx(7,7, Shadow, Spacing);
|
||||
|
||||
// write to debugbmp
|
||||
for y := 0 to C.MOCR.debugbmp.Height - 1 do
|
||||
for x := 0 to C.MOCR.debugbmp.Width -1 do
|
||||
Form1.Image1.Canvas.Pixels[x,y] := C.MOCR.debugbmp.FastGetPixel(x,y);
|
||||
|
||||
// print ocr'ed text
|
||||
Form1.Image1.Canvas.Font.Color:=clRed;
|
||||
Form1.Image1.Canvas.TextOut(0, C.MOCR.debugbmp.Height, s);
|
||||
|
||||
Form1.Image1.Picture.SaveToFile('/tmp/ocrbench.bmp');
|
||||
|
||||
C.Free;
|
||||
end;
|
||||
|
||||
@ -95,6 +125,20 @@ begin
|
||||
BitmapPath := OCRFileOpen.FileName;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
{BitmapPath := '/home/merlijn/Programs/mufasa/pics/uptext2.bmp';
|
||||
UpTextPath := '/home/merlijn/Programs/mufasa/Fonts/UpChars';}
|
||||
end;
|
||||
|
||||
procedure TForm1.FShadowChange(Sender: TObject);
|
||||
begin
|
||||
if Form1.FShadow.Checked then
|
||||
Form1.SplitEdit.Text:='2'
|
||||
else
|
||||
Form1.SplitEdit.Text:='1';
|
||||
end;
|
||||
|
||||
procedure TForm1.PathButtonClick(Sender: TObject);
|
||||
begin
|
||||
if UpCharsDialog.Execute then
|
||||
|
@ -98,7 +98,7 @@ threadvar
|
||||
CurrThread : TMMLPSThread;
|
||||
implementation
|
||||
uses
|
||||
dtmutil,
|
||||
colour_conv,dtmutil,
|
||||
{$ifdef mswindows}windows,{$endif}
|
||||
uPSC_std, uPSC_controls,uPSC_classes,uPSC_graphics,uPSC_stdctrls,uPSC_forms,
|
||||
uPSC_extctrls, //Compile-libs
|
||||
@ -108,7 +108,6 @@ uses
|
||||
Graphics, //For Graphics types
|
||||
math, //Maths!
|
||||
strutils,
|
||||
colour_conv,
|
||||
input,
|
||||
tpa, //Tpa stuff
|
||||
forms,//Forms
|
||||
|
@ -38,7 +38,8 @@ uses
|
||||
constructor Create(Owner: TObject);
|
||||
destructor Destroy; override;
|
||||
function InitTOCR(path: string; shadow: Boolean): boolean;
|
||||
function getTextPointsIn(sx, sy, w, h: Integer; shadow: boolean): TNormArray;
|
||||
function getTextPointsIn(sx, sy, w, h: Integer; shadow: boolean; spacing: Integer): TNormArray;
|
||||
function GetUpTextAtEx(atX, atY: integer; shadow: boolean; Spacing: Integer): string;
|
||||
function GetUpTextAt(atX, atY: integer; shadow: boolean): string;
|
||||
private
|
||||
Client: TObject;
|
||||
@ -54,7 +55,7 @@ uses
|
||||
implementation
|
||||
|
||||
uses
|
||||
colour_conv, client, files;
|
||||
colour_conv, client, files, tpa, mufasatypesutil;
|
||||
|
||||
const
|
||||
ocr_Limit_High = 190;
|
||||
@ -75,7 +76,7 @@ const
|
||||
Non optimised. ;-)
|
||||
}
|
||||
|
||||
function TMOCR.getTextPointsIn(sx, sy, w, h: Integer; shadow: boolean): TNormArray;
|
||||
function TMOCR.getTextPointsIn(sx, sy, w, h: Integer; shadow: boolean; spacing: integer): TNormArray;
|
||||
var
|
||||
bmp: TMufasaBitmap;
|
||||
x,y: integer;
|
||||
@ -84,7 +85,12 @@ var
|
||||
{$IFDEF OCRDEBUG}
|
||||
dx,dy: integer;
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF OCRTPA}
|
||||
t: tpointarray;
|
||||
at, atf,att: T2DPointArray;
|
||||
pc: integer;
|
||||
max_len: integer;
|
||||
{$ENDIF}
|
||||
|
||||
begin
|
||||
bmp := TMufasaBitmap.Create;
|
||||
@ -97,7 +103,7 @@ begin
|
||||
|
||||
{$IFDEF OCRDEBUG}
|
||||
debugbmp := TMufasaBitmap.Create;
|
||||
debugbmp.SetSize(w, (h + 2) * 4);
|
||||
debugbmp.SetSize(w, (h + 2) * 5);
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF OCRSAVEBITMAP}
|
||||
@ -266,11 +272,6 @@ begin
|
||||
for y := 0 to bmp.Height - 1 do
|
||||
for x := 0 to bmp.Width - 1 do
|
||||
begin
|
||||
{ if bmp.fastgetpixel(x,y) <> clPurple then
|
||||
begin
|
||||
bmp.FastSetPixel(x,y,0);
|
||||
continue;
|
||||
end; }
|
||||
if bmp.fastgetpixel(x,y) = clPurple then
|
||||
begin
|
||||
bmp.FastSetPixel(x,y,0);
|
||||
@ -292,17 +293,33 @@ begin
|
||||
for y := 0 to bmp.Height -1 do
|
||||
bmp.fastsetpixel(0, y, 0);
|
||||
|
||||
{$IFDEF OCRTPA}
|
||||
pc := 0;
|
||||
setlength(t, bmp.Height * bmp.Width);
|
||||
{$ENDIF}
|
||||
|
||||
setlength(n, bmp.Height * bmp.Width);
|
||||
|
||||
for y := 0 to bmp.Height - 1 do
|
||||
for x := 0 to bmp.Width - 1 do
|
||||
begin
|
||||
if bmp.fastgetpixel(x,y) > 0 then
|
||||
n[x + y * bmp.width] := 1
|
||||
begin
|
||||
n[x + y * bmp.width] := 1;
|
||||
{$IFDEF OCRTPA}
|
||||
t[pc] := point(x,y);
|
||||
inc(pc);
|
||||
{$ENDIF}
|
||||
end
|
||||
else
|
||||
n[x + y * bmp.width] := 0;
|
||||
n[x
|
||||
+ y * bmp.width] := 0;
|
||||
end;
|
||||
|
||||
{$IFDEF OCRTPA}
|
||||
setlength(t,pc);
|
||||
{$ENDIF}
|
||||
|
||||
result := n;
|
||||
{$IFDEF OCRSAVEBITMAP}
|
||||
bmp.SaveToFile('/tmp/ocrfinal.bmp');
|
||||
@ -312,6 +329,64 @@ begin
|
||||
for dx := 0 to bmp.width - 1 do
|
||||
debugbmp.fastsetpixel(dx,dy+h+h+h,bmp.fastgetpixel(dx,dy));
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF OCRTPA}
|
||||
at:=splittpaex(t,spacing,bmp.height);
|
||||
|
||||
{
|
||||
// this was to split extra large points into smaller ones, but it usually won't help
|
||||
if shadow then
|
||||
max_len := 30
|
||||
else
|
||||
max_len := 50;
|
||||
|
||||
for x := 0 to high(at) do
|
||||
begin
|
||||
if length(at[x]) > max_len then
|
||||
begin
|
||||
setlength(t,0);
|
||||
// t := at[x];
|
||||
att := splittpaex(at[x], 1, bmp.height);
|
||||
for y := 0 to high(att) do
|
||||
begin
|
||||
setlength(atf,length(atf)+1);
|
||||
atf[high(atf)] := convtpaarr(att[y]);
|
||||
end;
|
||||
end else
|
||||
begin
|
||||
setlength(atf,length(atf)+1);
|
||||
atf[high(atf)] := convtpaarr(at[x]);
|
||||
end;
|
||||
end;
|
||||
|
||||
for x := 0 to high(atf) do
|
||||
begin
|
||||
pc := random(clWhite);
|
||||
for y := 0 to high(atf[x]) do
|
||||
bmp.FastSetPixel(atf[x][y].x, atf[x][y].y, pc);
|
||||
end; }
|
||||
|
||||
for x := 0 to high(at) do
|
||||
begin
|
||||
if length(at[x]) > 70 then
|
||||
begin
|
||||
for y := 0 to high(at[x]) do
|
||||
bmp.FastSetPixel(at[x][y].x, at[x][y].y, clOlive);
|
||||
end else
|
||||
begin
|
||||
pc := random(clWhite);
|
||||
for y := 0 to high(at[x]) do
|
||||
bmp.FastSetPixel(at[x][y].x, at[x][y].y, pc);
|
||||
end;
|
||||
end;
|
||||
{$IFDEF OCRDEBUG}
|
||||
for dy := 0 to bmp.height - 1 do
|
||||
for dx := 0 to bmp.width - 1 do
|
||||
debugbmp.fastsetpixel(dx,dy+h+h+h+h,bmp.fastgetpixel(dx,dy));
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
bmp.Free;
|
||||
{ Dangerous removes all pixels that had no pixels on x-1 or x+1}
|
||||
{ for y := 0 to bmp.Height - 2 do
|
||||
@ -369,19 +444,25 @@ begin
|
||||
result := false;
|
||||
end;
|
||||
|
||||
function TMOCR.GetUpTextAt(atX, atY: integer; shadow: boolean): string;
|
||||
|
||||
function TMOCR.GetUpTextAtEx(atX, atY: integer; shadow: boolean; spacing: Integer): string;
|
||||
var
|
||||
n:Tnormarray;
|
||||
ww, hh: integer;
|
||||
|
||||
begin
|
||||
ww := 400;
|
||||
hh := 20;
|
||||
|
||||
n := getTextPointsIn(atX, atY, ww, hh, shadow);
|
||||
n := getTextPointsIn(atX, atY, ww, hh, shadow, spacing);
|
||||
Result := ocrDetect(n, ww, hh, OCRData[0]);
|
||||
//writeln(result);
|
||||
end;
|
||||
|
||||
function TMOCR.GetUpTextAt(atX, atY: integer; shadow: boolean): string;
|
||||
|
||||
begin
|
||||
if shadow then
|
||||
result := GetUpTextAtEx(atX, atY, shadow, 2)
|
||||
else
|
||||
result := GetUpTextAtEx(atX, atY, shadow, 1);
|
||||
end;
|
||||
{
|
||||
function TMOCR.GetUpTextAt(atX, atY: integer): string;
|
||||
|
Loading…
Reference in New Issue
Block a user