mirror of
https://github.com/moparisthebest/Simba
synced 2025-01-30 23:00:18 -05:00
Added OCRBench.
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@306 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
c3f91d9199
commit
9bc999fcad
BIN
Projects/OCRBench/project1.ico
Normal file
BIN
Projects/OCRBench/project1.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 134 KiB |
221
Projects/OCRBench/project1.lpi
Normal file
221
Projects/OCRBench/project1.lpi
Normal file
@ -0,0 +1,221 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="7"/>
|
||||
<General>
|
||||
<MainUnit Value="0"/>
|
||||
<TargetFileExt Value=""/>
|
||||
<Icon Value="0"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<ActiveEditorIndexAtStart Value="2"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<ProjectVersion Value=""/>
|
||||
<Language Value=""/>
|
||||
<CharSet Value=""/>
|
||||
</VersionInfo>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IgnoreBinaries Value="False"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="7">
|
||||
<Unit0>
|
||||
<Filename Value="project1.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="project1"/>
|
||||
<UsageCount Value="21"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Unit1"/>
|
||||
<CursorPos X="75" Y="77"/>
|
||||
<TopLine Value="55"/>
|
||||
<EditorIndex Value="0"/>
|
||||
<UsageCount Value="21"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="../SAMufasaGUI/colourhistory.pas"/>
|
||||
<ComponentName Value="ColourHistoryForm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="colourhistory"/>
|
||||
<CursorPos X="10" Y="457"/>
|
||||
<TopLine Value="437"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<UsageCount Value="11"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="../SAMufasaGUI/testunit.pas"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="TestUnit"/>
|
||||
<CursorPos X="38" Y="405"/>
|
||||
<TopLine Value="382"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="../../Units/MMLCore/client.pas"/>
|
||||
<UnitName Value="Client"/>
|
||||
<CursorPos X="21" Y="52"/>
|
||||
<TopLine Value="32"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<UnitName Value="ocr"/>
|
||||
<CursorPos X="23" Y="100"/>
|
||||
<TopLine Value="90"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit5>
|
||||
<Unit6>
|
||||
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
||||
<UnitName Value="bitmaps"/>
|
||||
<CursorPos X="3" Y="35"/>
|
||||
<TopLine Value="27"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit6>
|
||||
</Units>
|
||||
<JumpHistory Count="20" HistoryIndex="19">
|
||||
<Position1>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="9" Column="19" TopLine="1"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="25" Column="36" TopLine="1"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="../SAMufasaGUI/colourhistory.pas"/>
|
||||
<Caret Line="30" Column="67" TopLine="181"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="47" Column="87" TopLine="19"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="57" Column="34" TopLine="33"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="64" Column="7" TopLine="33"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="../../Units/MMLCore/client.pas"/>
|
||||
<Caret Line="52" Column="21" TopLine="32"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="40" Column="31" TopLine="17"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="65" Column="43" TopLine="33"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="55" Column="70" TopLine="22"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="54" Column="70" TopLine="22"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="30" Column="60" TopLine="22"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="31" Column="60" TopLine="22"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="32" Column="60" TopLine="22"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="31" Column="60" TopLine="22"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="33" Column="60" TopLine="22"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="84" Column="50" TopLine="44"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="81" Column="22" TopLine="60"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="49" Column="22" TopLine="74"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="75" Column="33" TopLine="49"/>
|
||||
</Position20>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="8"/>
|
||||
<Target>
|
||||
<Filename Value="project1"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)/;$(ProjPath)../../Units/MMLAddon/PSInc/"/>
|
||||
<OtherUnitFiles Value="$(ProjPath)../../Units/MMLCore/;$(ProjPath)../../Units/MMLAddon/;$(ProjPath)../../Units/PascalScript/;$(ProjPath)../../Units/Misc/;$(ProjPath)../../Units/MMLAddon/PSInc/;$(ProjPath)../../Units/Linux/;$(LazarusDir)/components/mouseandkeyinput/"/>
|
||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CustomOptions Value="-dOCRDEBUG"/>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
21
Projects/OCRBench/project1.lpr
Normal file
21
Projects/OCRBench/project1.lpr
Normal file
@ -0,0 +1,21 @@
|
||||
program project1;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, Unit1, LResources
|
||||
{ you can add units after this };
|
||||
|
||||
{$IFDEF WINDOWS}{$R project1.rc}{$ENDIF}
|
||||
|
||||
begin
|
||||
{$I project1.lrs}
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
5237
Projects/OCRBench/project1.lrs
Normal file
5237
Projects/OCRBench/project1.lrs
Normal file
File diff suppressed because it is too large
Load Diff
1
Projects/OCRBench/project1.rc
Normal file
1
Projects/OCRBench/project1.rc
Normal file
@ -0,0 +1 @@
|
||||
MAINICON ICON "project1.ico"
|
52
Projects/OCRBench/unit1.lfm
Normal file
52
Projects/OCRBench/unit1.lfm
Normal file
@ -0,0 +1,52 @@
|
||||
object Form1: TForm1
|
||||
Left = 492
|
||||
Height = 305
|
||||
Top = 266
|
||||
Width = 609
|
||||
Caption = 'Form1'
|
||||
ClientHeight = 305
|
||||
ClientWidth = 609
|
||||
LCLVersion = '0.9.29'
|
||||
object OCRButton: TButton
|
||||
Left = 512
|
||||
Height = 25
|
||||
Top = 255
|
||||
Width = 88
|
||||
Caption = 'OCR Filter!'
|
||||
OnClick = OCRButtonClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object Image1: TImage
|
||||
Left = 16
|
||||
Height = 264
|
||||
Top = 16
|
||||
Width = 480
|
||||
end
|
||||
object BitmapButton: TButton
|
||||
Left = 512
|
||||
Height = 25
|
||||
Top = 32
|
||||
Width = 88
|
||||
Caption = 'Set Bitmap'
|
||||
OnClick = BitmapButtonClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object PathButton: TButton
|
||||
Left = 512
|
||||
Height = 25
|
||||
Top = 72
|
||||
Width = 88
|
||||
Caption = 'Set Path'
|
||||
OnClick = PathButtonClick
|
||||
TabOrder = 2
|
||||
end
|
||||
object OCRFileOpen: TOpenDialog
|
||||
Filter = '.bmp'
|
||||
left = 528
|
||||
top = 192
|
||||
end
|
||||
object UpCharsDialog: TSelectDirectoryDialog
|
||||
left = 528
|
||||
top = 160
|
||||
end
|
||||
end
|
98
Projects/OCRBench/unit1.pas
Normal file
98
Projects/OCRBench/unit1.pas
Normal file
@ -0,0 +1,98 @@
|
||||
unit Unit1;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, ExtCtrls, Client, MufasaTypes, Bitmaps;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
BitmapButton: TButton;
|
||||
PathButton: TButton;
|
||||
OCRButton: TButton;
|
||||
Image1: TImage;
|
||||
OCRFileOpen: TOpenDialog;
|
||||
UpCharsDialog: TSelectDirectoryDialog;
|
||||
procedure BitmapButtonClick(Sender: TObject);
|
||||
procedure OCRButtonClick(Sender: TObject);
|
||||
procedure PathButtonClick(Sender: TObject);
|
||||
private
|
||||
BitmapPath: String;
|
||||
UpTextPath: String;
|
||||
{ private declarations }
|
||||
public
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
lclintf, lcltype;
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.OCRButtonClick(Sender: TObject);
|
||||
Var
|
||||
C: TClient;
|
||||
bmp: TMufasaBitmap;
|
||||
x,y: integer;
|
||||
|
||||
begin
|
||||
writeln(BitmapPath);
|
||||
if not FileExists(BitmapPath) then
|
||||
begin
|
||||
MessageBox(0,pchar('You did not set a valid bitmap'), Pchar('Bitmap Error'),
|
||||
MB_OK);
|
||||
if OCRFileOpen.Execute then
|
||||
BitmapPath := OCRFileOpen.FileName;
|
||||
Exit;
|
||||
end;
|
||||
if not DirectoryExists(UpTextPath) then
|
||||
begin
|
||||
MessageBox(0,pchar('You did not set a UpText Path' ), Pchar('Path Error'),
|
||||
MB_OK);
|
||||
if UpCharsDialog.Execute then
|
||||
UpTextPath := UpCharsDialog.FileName;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
C := TClient.Create;
|
||||
bmp := TMufasaBitmap.Create;
|
||||
bmp.LoadFromFile(BitmapPath);
|
||||
C.MWindow.SetTarget(bmp);
|
||||
C.MOCR.InitTOCR(UpTextPath + DS + '..' + DS);
|
||||
writeln(C.MOCR.GetUpTextAt(7,7));
|
||||
|
||||
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);
|
||||
|
||||
C.Free;
|
||||
end;
|
||||
|
||||
procedure TForm1.BitmapButtonClick(Sender: TObject);
|
||||
begin
|
||||
if OCRFileOpen.Execute then
|
||||
BitmapPath := OCRFileOpen.FileName;
|
||||
end;
|
||||
|
||||
procedure TForm1.PathButtonClick(Sender: TObject);
|
||||
begin
|
||||
if UpCharsDialog.Execute then
|
||||
UpTextPath := UpCharsDialog.FileName;
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$I unit1.lrs}
|
||||
|
||||
end.
|
||||
|
@ -10,7 +10,7 @@
|
||||
<TargetFileExt Value=""/>
|
||||
<Title Value="Mufasa Stand Alone"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<ActiveEditorIndexAtStart Value="6"/>
|
||||
<ActiveEditorIndexAtStart Value="12"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<ProjectVersion Value=""/>
|
||||
@ -43,7 +43,7 @@
|
||||
<UnitName Value="project1"/>
|
||||
<CursorPos X="100" Y="21"/>
|
||||
<TopLine Value="6"/>
|
||||
<EditorIndex Value="14"/>
|
||||
<EditorIndex Value="16"/>
|
||||
<UsageCount Value="205"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit0>
|
||||
@ -139,8 +139,8 @@
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="TestUnit"/>
|
||||
<CursorPos X="38" Y="1312"/>
|
||||
<TopLine Value="1291"/>
|
||||
<CursorPos X="72" Y="1327"/>
|
||||
<TopLine Value="799"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<UsageCount Value="202"/>
|
||||
<Loaded Value="True"/>
|
||||
@ -232,7 +232,7 @@
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="Window"/>
|
||||
<CursorPos X="49" Y="283"/>
|
||||
<TopLine Value="273"/>
|
||||
<TopLine Value="405"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<UsageCount Value="201"/>
|
||||
<Loaded Value="True"/>
|
||||
@ -249,8 +249,8 @@
|
||||
<UnitName Value="windowutil"/>
|
||||
<CursorPos X="23" Y="8"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="18"/>
|
||||
<UsageCount Value="79"/>
|
||||
<EditorIndex Value="20"/>
|
||||
<UsageCount Value="80"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit27>
|
||||
<Unit28>
|
||||
@ -266,7 +266,7 @@
|
||||
<UnitName Value="finder"/>
|
||||
<CursorPos X="58" Y="23"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="9"/>
|
||||
<EditorIndex Value="11"/>
|
||||
<UsageCount Value="201"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit29>
|
||||
@ -290,7 +290,7 @@
|
||||
<UnitName Value="mmlpsthread"/>
|
||||
<CursorPos X="63" Y="188"/>
|
||||
<TopLine Value="298"/>
|
||||
<EditorIndex Value="19"/>
|
||||
<EditorIndex Value="21"/>
|
||||
<UsageCount Value="202"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit32>
|
||||
@ -352,7 +352,7 @@
|
||||
<Filename Value="../../Units/MMLAddon/PSInc/pscompile.inc"/>
|
||||
<CursorPos X="117" Y="32"/>
|
||||
<TopLine Value="4"/>
|
||||
<EditorIndex Value="16"/>
|
||||
<EditorIndex Value="18"/>
|
||||
<UsageCount Value="100"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit41>
|
||||
@ -654,7 +654,7 @@
|
||||
<UnitName Value="dtm"/>
|
||||
<CursorPos X="62" Y="135"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="15"/>
|
||||
<EditorIndex Value="17"/>
|
||||
<UsageCount Value="200"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit86>
|
||||
@ -671,7 +671,7 @@
|
||||
<UnitName Value="colourpicker"/>
|
||||
<CursorPos X="65" Y="243"/>
|
||||
<TopLine Value="134"/>
|
||||
<EditorIndex Value="12"/>
|
||||
<EditorIndex Value="14"/>
|
||||
<UsageCount Value="201"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit88>
|
||||
@ -698,7 +698,7 @@
|
||||
<UnitName Value="windowselector"/>
|
||||
<CursorPos X="54" Y="139"/>
|
||||
<TopLine Value="116"/>
|
||||
<EditorIndex Value="11"/>
|
||||
<EditorIndex Value="13"/>
|
||||
<UsageCount Value="201"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit91>
|
||||
@ -734,7 +734,7 @@
|
||||
<UnitName Value="dtmutil"/>
|
||||
<CursorPos X="1" Y="1"/>
|
||||
<TopLine Value="151"/>
|
||||
<EditorIndex Value="13"/>
|
||||
<EditorIndex Value="15"/>
|
||||
<UsageCount Value="206"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit96>
|
||||
@ -749,8 +749,8 @@
|
||||
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/dtm.inc"/>
|
||||
<CursorPos X="33" Y="34"/>
|
||||
<TopLine Value="30"/>
|
||||
<EditorIndex Value="17"/>
|
||||
<UsageCount Value="38"/>
|
||||
<EditorIndex Value="19"/>
|
||||
<UsageCount Value="39"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit98>
|
||||
<Unit99>
|
||||
@ -814,9 +814,9 @@
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="ocr"/>
|
||||
<CursorPos X="59" Y="119"/>
|
||||
<TopLine Value="114"/>
|
||||
<EditorIndex Value="8"/>
|
||||
<CursorPos X="51" Y="251"/>
|
||||
<TopLine Value="14"/>
|
||||
<EditorIndex Value="9"/>
|
||||
<UsageCount Value="200"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit107>
|
||||
@ -1139,7 +1139,7 @@
|
||||
<UnitName Value="framescript"/>
|
||||
<CursorPos X="106" Y="190"/>
|
||||
<TopLine Value="180"/>
|
||||
<UsageCount Value="199"/>
|
||||
<UsageCount Value="200"/>
|
||||
</Unit151>
|
||||
<Unit152>
|
||||
<Filename Value="framesynedit.lrs"/>
|
||||
@ -1359,9 +1359,11 @@
|
||||
</Unit184>
|
||||
<Unit185>
|
||||
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/ocr.inc"/>
|
||||
<CursorPos X="40" Y="3"/>
|
||||
<CursorPos X="18" Y="5"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="10"/>
|
||||
<UsageCount Value="27"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit185>
|
||||
<Unit186>
|
||||
<Filename Value="../../../Documents/lazarus/lcl/interfaces/gtk/gtkwidgetset.inc"/>
|
||||
@ -1451,10 +1453,10 @@
|
||||
<ComponentName Value="ColourHistoryForm"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="colourhistory"/>
|
||||
<CursorPos X="22" Y="203"/>
|
||||
<TopLine Value="183"/>
|
||||
<EditorIndex Value="6"/>
|
||||
<UsageCount Value="136"/>
|
||||
<CursorPos X="81" Y="189"/>
|
||||
<TopLine Value="174"/>
|
||||
<EditorIndex Value="7"/>
|
||||
<UsageCount Value="137"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit198>
|
||||
<Unit199>
|
||||
@ -1705,7 +1707,7 @@
|
||||
<UnitName Value="about"/>
|
||||
<CursorPos X="44" Y="21"/>
|
||||
<TopLine Value="4"/>
|
||||
<UsageCount Value="99"/>
|
||||
<UsageCount Value="100"/>
|
||||
</Unit235>
|
||||
<Unit236>
|
||||
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/file.inc"/>
|
||||
@ -1719,7 +1721,7 @@
|
||||
<UnitName Value="internets"/>
|
||||
<CursorPos X="87" Y="3"/>
|
||||
<TopLine Value="1"/>
|
||||
<UsageCount Value="93"/>
|
||||
<UsageCount Value="94"/>
|
||||
</Unit237>
|
||||
<Unit238>
|
||||
<Filename Value="debugimageform.pas"/>
|
||||
@ -1728,7 +1730,7 @@
|
||||
<UnitName Value="debugimageform"/>
|
||||
<CursorPos X="20" Y="1"/>
|
||||
<TopLine Value="1"/>
|
||||
<UsageCount Value="80"/>
|
||||
<UsageCount Value="81"/>
|
||||
</Unit238>
|
||||
<Unit239>
|
||||
<Filename Value="debugimage.pas"/>
|
||||
@ -1736,10 +1738,10 @@
|
||||
<ComponentName Value="DebugImgForm"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="debugimage"/>
|
||||
<CursorPos X="1" Y="1"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="7"/>
|
||||
<UsageCount Value="79"/>
|
||||
<CursorPos X="59" Y="23"/>
|
||||
<TopLine Value="37"/>
|
||||
<EditorIndex Value="8"/>
|
||||
<UsageCount Value="80"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit239>
|
||||
<Unit240>
|
||||
@ -1811,10 +1813,10 @@
|
||||
<Unit250>
|
||||
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
|
||||
<UnitName Value="ocrutil"/>
|
||||
<CursorPos X="64" Y="22"/>
|
||||
<TopLine Value="25"/>
|
||||
<EditorIndex Value="10"/>
|
||||
<UsageCount Value="26"/>
|
||||
<CursorPos X="15" Y="176"/>
|
||||
<TopLine Value="145"/>
|
||||
<EditorIndex Value="12"/>
|
||||
<UsageCount Value="27"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit250>
|
||||
<Unit251>
|
||||
@ -1843,7 +1845,7 @@
|
||||
<CursorPos X="37" Y="3116"/>
|
||||
<TopLine Value="3105"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<UsageCount Value="21"/>
|
||||
<UsageCount Value="22"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit254>
|
||||
<Unit255>
|
||||
@ -1862,14 +1864,16 @@
|
||||
<Unit257>
|
||||
<Filename Value="../../../../Documents/lazarus/lcl/comctrls.pp"/>
|
||||
<UnitName Value="ComCtrls"/>
|
||||
<CursorPos X="29" Y="2587"/>
|
||||
<TopLine Value="2567"/>
|
||||
<UsageCount Value="10"/>
|
||||
<CursorPos X="9" Y="2978"/>
|
||||
<TopLine Value="2957"/>
|
||||
<EditorIndex Value="6"/>
|
||||
<UsageCount Value="11"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit257>
|
||||
<Unit258>
|
||||
<Filename Value="../../../../Documents/lazarus/lcl/include/treeview.inc"/>
|
||||
<CursorPos X="42" Y="2692"/>
|
||||
<TopLine Value="2684"/>
|
||||
<CursorPos X="44" Y="276"/>
|
||||
<TopLine Value="1"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit258>
|
||||
<Unit259>
|
||||
@ -1886,127 +1890,111 @@
|
||||
<UsageCount Value="10"/>
|
||||
</Unit260>
|
||||
</Units>
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<JumpHistory Count="26" HistoryIndex="25">
|
||||
<Position1>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="410" Column="48" TopLine="387"/>
|
||||
<Caret Line="393" Column="36" TopLine="356"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="87" Column="26" TopLine="58"/>
|
||||
<Caret Line="389" Column="29" TopLine="361"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="366" Column="8" TopLine="350"/>
|
||||
<Caret Line="399" Column="39" TopLine="371"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="365" Column="79" TopLine="344"/>
|
||||
<Caret Line="395" Column="31" TopLine="375"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="371" Column="21" TopLine="355"/>
|
||||
<Caret Line="342" Column="79" TopLine="330"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="376" Column="64" TopLine="356"/>
|
||||
<Caret Line="391" Column="29" TopLine="361"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="393" Column="36" TopLine="356"/>
|
||||
<Caret Line="91" Column="15" TopLine="56"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="389" Column="29" TopLine="361"/>
|
||||
<Caret Line="31" Column="65" TopLine="23"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="399" Column="39" TopLine="371"/>
|
||||
<Caret Line="393" Column="72" TopLine="383"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="395" Column="31" TopLine="375"/>
|
||||
<Caret Line="364" Column="17" TopLine="332"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="342" Column="79" TopLine="330"/>
|
||||
<Caret Line="227" Column="1" TopLine="200"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="391" Column="29" TopLine="361"/>
|
||||
<Caret Line="79" Column="26" TopLine="52"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="91" Column="15" TopLine="56"/>
|
||||
<Caret Line="177" Column="1" TopLine="134"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="31" Column="65" TopLine="23"/>
|
||||
<Caret Line="317" Column="54" TopLine="295"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="393" Column="72" TopLine="383"/>
|
||||
<Filename Value="../../Units/MMLCore/client.pas"/>
|
||||
<Caret Line="33" Column="48" TopLine="13"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="364" Column="17" TopLine="332"/>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="137" Column="43" TopLine="109"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="227" Column="1" TopLine="200"/>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="134" Column="60" TopLine="114"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="79" Column="26" TopLine="52"/>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="135" Column="18" TopLine="114"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="177" Column="1" TopLine="134"/>
|
||||
<Caret Line="74" Column="29" TopLine="49"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="317" Column="54" TopLine="295"/>
|
||||
<Caret Line="170" Column="14" TopLine="153"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="../../Units/MMLCore/client.pas"/>
|
||||
<Caret Line="33" Column="48" TopLine="13"/>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="191" Column="1" TopLine="169"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="137" Column="43" TopLine="109"/>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="172" Column="83" TopLine="157"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="134" Column="60" TopLine="114"/>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="201" Column="15" TopLine="172"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||
<Caret Line="135" Column="18" TopLine="114"/>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="205" Column="32" TopLine="169"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="74" Column="29" TopLine="49"/>
|
||||
<Caret Line="163" Column="13" TopLine="135"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="170" Column="14" TopLine="153"/>
|
||||
<Filename Value="../../../../Documents/lazarus/lcl/comctrls.pp"/>
|
||||
<Caret Line="2978" Column="9" TopLine="2957"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="191" Column="1" TopLine="169"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="172" Column="83" TopLine="157"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="201" Column="15" TopLine="172"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="colourhistory.pas"/>
|
||||
<Caret Line="205" Column="32" TopLine="169"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
@ -44,6 +44,10 @@ uses
|
||||
Client: TObject;
|
||||
OCRData: TocrDataArray;
|
||||
OCRPath: string;
|
||||
{$IFDEF OCRDEBUG}
|
||||
public
|
||||
debugbmp: TMufasaBitmap;
|
||||
{$ENDIF}
|
||||
|
||||
end;
|
||||
|
||||
@ -77,14 +81,31 @@ var
|
||||
x,y: integer;
|
||||
r,g,b: integer;
|
||||
n: TNormArray;
|
||||
{$IFDEF OCRDEBUG}
|
||||
dx,dy: integer;
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
begin
|
||||
bmp := TMufasaBitmap.Create;
|
||||
bmp.SetSize(w, h + 2);
|
||||
bmp.CopyClientToBitmap(TClient(Client).MWindow, False, 0,1, sx, sy, sx + w - 1, sy + h - 1);
|
||||
//bmp.CopyClientToBitmap(TClient(Client).MWindow, True, sx, sy, sx + w - 1, sy + h - 1);
|
||||
|
||||
{ Increase to create a black horizonal line at the top and at the bottom }
|
||||
{ This so the crappy algo can do it's work correctly. }
|
||||
bmp.SetSize(w{ + 1}, h + 2);
|
||||
|
||||
bmp.CopyClientToBitmap(TClient(Client).MWindow, False, {1}0,1, sx, sy, sx + w - 1, sy + h - 1);
|
||||
|
||||
{$IFDEF OCRDEBUG}
|
||||
debugbmp := TMufasaBitmap.Create;
|
||||
debugbmp.SetSize(w, (h + 2) * 4);
|
||||
{$ENDIF}
|
||||
|
||||
bmp.SaveToFile('/tmp/ocrinit.bmp');
|
||||
{$IFDEF OCRDEBUG}
|
||||
for dy := 0 to bmp.height - 1 do
|
||||
for dx := 0 to bmp.width - 1 do
|
||||
debugbmp.fastsetpixel(dx,dy,bmp.fastgetpixel(dx,dy));
|
||||
{$ENDIF}
|
||||
for y := 0 to bmp.Height - 1 do
|
||||
for x := 0 to bmp.Width - 1 do
|
||||
begin
|
||||
@ -147,17 +168,20 @@ begin
|
||||
bmp.fastsetpixel(x,y,0);
|
||||
end;
|
||||
|
||||
// increase height by 1, so our algo works better.
|
||||
{bmp.SetSize(Bmp.Width, Bmp.Height+1); }
|
||||
|
||||
// first and last horiz line = 0
|
||||
for x := 0 to bmp.width -1 do
|
||||
bmp.fastsetpixel(x,0,0);
|
||||
for x := 0 to bmp.width -1 do
|
||||
bmp.fastsetpixel(x,bmp.height-1,0);
|
||||
{ for y := 0 to bmp.Height -1 do
|
||||
bmp.fastsetpixel(0, y, 0); }
|
||||
|
||||
bmp.SaveToFile('/tmp/ocrcol.bmp');
|
||||
|
||||
{$IFDEF OCRDEBUG}
|
||||
for dy := 0 to bmp.height - 1 do
|
||||
for dx := 0 to bmp.width - 1 do
|
||||
debugbmp.fastsetpixel(dx,dy+h,bmp.fastgetpixel(dx,dy));
|
||||
{$ENDIF}
|
||||
for y := 0 to bmp.Height - 2 do
|
||||
for x := 0 to bmp.Width - 2 do
|
||||
begin
|
||||
@ -213,12 +237,21 @@ begin
|
||||
bmp.fastsetpixel(x,y, clOlive);
|
||||
end; }
|
||||
{ remove debug ;) }
|
||||
|
||||
{$IFDEF OCRDEBUG}
|
||||
for dy := 0 to bmp.height - 1 do
|
||||
for dx := 0 to bmp.width - 1 do
|
||||
debugbmp.fastsetpixel(dx,dy+h+h,bmp.fastgetpixel(dx,dy));
|
||||
{$ENDIF}
|
||||
bmp.SaveToFile('/tmp/ocrdebug.bmp');
|
||||
|
||||
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);
|
||||
@ -236,6 +269,9 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
for y := 0 to bmp.Height -1 do
|
||||
bmp.fastsetpixel(0, y, 0);
|
||||
|
||||
setlength(n, bmp.Height * bmp.Width);
|
||||
|
||||
for y := 0 to bmp.Height - 1 do
|
||||
@ -249,6 +285,11 @@ begin
|
||||
|
||||
result := n;
|
||||
bmp.SaveToFile('/tmp/ocrfinal.bmp');
|
||||
{$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,bmp.fastgetpixel(dx,dy));
|
||||
{$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
|
||||
@ -299,6 +340,7 @@ begin
|
||||
OCRData[0] := ocrutil.InitOCR(path + DS + 'UpChars' + DS)
|
||||
else
|
||||
result := false;
|
||||
|
||||
if DirectoryExists(path + DS + 'StatChars' + DS) then
|
||||
OCRData[1] := ocrutil.InitOCR(path + DS + 'StatChars' + DS)
|
||||
else
|
||||
|
@ -173,6 +173,7 @@ begin
|
||||
begin
|
||||
color:= bmp[i].data[j];
|
||||
if (color.r = 255) and (color.g = 255) and (color.b = 255) then
|
||||
//if (color.r = 255) and (color.g = 0) and (color.b = 0) then
|
||||
result[i].mask[j]:= 1
|
||||
else
|
||||
result[i].mask[j]:= 0;
|
||||
|
Loading…
Reference in New Issue
Block a user