1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-21 16:55:01 -05:00

Added DTM NOT points, made DTM algorithm more dynamic.

Added CTS support for DTM. (May remove later if it becomes slow)



git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@371 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
Wizzup? 2010-01-04 19:08:06 +00:00
parent c5d4624df2
commit b2f5a9f77a
8 changed files with 244 additions and 317 deletions

View File

@ -11,7 +11,7 @@
<TargetFileExt Value=""/>
<Icon Value="0"/>
<UseXPManifest Value="True"/>
<ActiveEditorIndexAtStart Value="4"/>
<ActiveEditorIndexAtStart Value="2"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
@ -30,15 +30,15 @@
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<Units Count="34">
<Units Count="27">
<Unit0>
<Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="project1"/>
<CursorPos X="7" Y="124"/>
<TopLine Value="99"/>
<CursorPos X="29" Y="51"/>
<TopLine Value="33"/>
<EditorIndex Value="0"/>
<UsageCount Value="121"/>
<UsageCount Value="74"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
@ -46,15 +46,15 @@
<UnitName Value="CustApp"/>
<CursorPos X="15" Y="51"/>
<TopLine Value="32"/>
<UsageCount Value="3"/>
<UsageCount Value="7"/>
</Unit1>
<Unit2>
<Filename Value="../../Units/MMLCore/client.pas"/>
<UnitName Value="Client"/>
<CursorPos X="20" Y="33"/>
<TopLine Value="1"/>
<EditorIndex Value="11"/>
<UsageCount Value="52"/>
<CursorPos X="21" Y="51"/>
<TopLine Value="35"/>
<EditorIndex Value="9"/>
<UsageCount Value="31"/>
<Loaded Value="True"/>
</Unit2>
<Unit3>
@ -62,370 +62,318 @@
<UnitName Value="windowutil"/>
<CursorPos X="110" Y="30"/>
<TopLine Value="3"/>
<UsageCount Value="3"/>
<UsageCount Value="7"/>
</Unit3>
<Unit4>
<Filename Value="../../Units/MMLCore/window.pas"/>
<UnitName Value="Window"/>
<CursorPos X="55" Y="251"/>
<TopLine Value="236"/>
<EditorIndex Value="15"/>
<UsageCount Value="51"/>
<EditorIndex Value="12"/>
<UsageCount Value="30"/>
<Loaded Value="True"/>
</Unit4>
<Unit5>
<Filename Value="../../Units/MMLCore/colour_conv.pas"/>
<UnitName Value="colour_conv"/>
<CursorPos X="18" Y="346"/>
<TopLine Value="307"/>
<EditorIndex Value="7"/>
<UsageCount Value="32"/>
<TopLine Value="309"/>
<EditorIndex Value="4"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit5>
<Unit6>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<UnitName Value="finder"/>
<CursorPos X="1" Y="1728"/>
<TopLine Value="1701"/>
<EditorIndex Value="6"/>
<UsageCount Value="55"/>
<CursorPos X="69" Y="1901"/>
<TopLine Value="1890"/>
<EditorIndex Value="2"/>
<UsageCount Value="34"/>
<Loaded Value="True"/>
</Unit6>
<Unit7>
<Filename Value="../../Units/MMLCore/input.pas"/>
<UnitName Value="Input"/>
<CursorPos X="72" Y="47"/>
<TopLine Value="36"/>
<EditorIndex Value="10"/>
<UsageCount Value="51"/>
<CursorPos X="56" Y="49"/>
<TopLine Value="24"/>
<EditorIndex Value="8"/>
<UsageCount Value="30"/>
<Loaded Value="True"/>
</Unit7>
<Unit8>
<Filename Value="../../Units/MMLCore/mufasatypes.pas"/>
<UnitName Value="MufasaTypes"/>
<CursorPos X="98" Y="92"/>
<TopLine Value="76"/>
<EditorIndex Value="16"/>
<UsageCount Value="53"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="34"/>
<EditorIndex Value="3"/>
<UsageCount Value="32"/>
<Loaded Value="True"/>
</Unit8>
<Unit9>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<UnitName Value="ocr"/>
<CursorPos X="1" Y="133"/>
<TopLine Value="108"/>
<EditorIndex Value="13"/>
<UsageCount Value="52"/>
<CursorPos X="53" Y="31"/>
<TopLine Value="24"/>
<EditorIndex Value="10"/>
<UsageCount Value="31"/>
<Loaded Value="True"/>
</Unit9>
<Unit10>
<Filename Value="../../../../Documents/fpc/rtl/objpas/sysutils/diskh.inc"/>
<CursorPos X="10" Y="18"/>
<TopLine Value="1"/>
<UsageCount Value="4"/>
<UsageCount Value="8"/>
</Unit10>
<Unit11>
<Filename Value="../../Units/MMLCore/files.pas"/>
<UnitName Value="files"/>
<CursorPos X="22" Y="36"/>
<TopLine Value="18"/>
<EditorIndex Value="12"/>
<UsageCount Value="13"/>
<Loaded Value="True"/>
<CursorPos X="5" Y="42"/>
<TopLine Value="27"/>
<UsageCount Value="8"/>
</Unit11>
<Unit12>
<Filename Value="../../../../Documents/lazarus/lcl/graphics.pp"/>
<UnitName Value="Graphics"/>
<CursorPos X="3" Y="243"/>
<TopLine Value="223"/>
<UsageCount Value="6"/>
<CursorPos X="3" Y="1426"/>
<TopLine Value="1411"/>
<UsageCount Value="8"/>
</Unit12>
<Unit13>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<UnitName Value="bitmaps"/>
<CursorPos X="56" Y="477"/>
<TopLine Value="435"/>
<CursorPos X="32" Y="835"/>
<TopLine Value="850"/>
<EditorIndex Value="1"/>
<UsageCount Value="50"/>
<UsageCount Value="29"/>
<Loaded Value="True"/>
</Unit13>
<Unit14>
<Filename Value="../../../../Documents/fpc/rtl/inc/objpash.inc"/>
<CursorPos X="22" Y="177"/>
<TopLine Value="162"/>
<UsageCount Value="4"/>
<UsageCount Value="8"/>
</Unit14>
<Unit15>
<Filename Value="../../../../Documents/lazarus/lcl/intfgraphics.pas"/>
<UnitName Value="IntfGraphics"/>
<CursorPos X="30" Y="2975"/>
<TopLine Value="2959"/>
<UsageCount Value="4"/>
<UsageCount Value="8"/>
</Unit15>
<Unit16>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<UnitName Value="mmlpsthread"/>
<CursorPos X="3" Y="154"/>
<TopLine Value="235"/>
<UsageCount Value="4"/>
<UsageCount Value="8"/>
</Unit16>
<Unit17>
<Filename Value="../../../../Documents/fpc/rtl/i386/mmx.pp"/>
<UnitName Value="mmx"/>
<CursorPos X="80" Y="15"/>
<TopLine Value="71"/>
<UsageCount Value="4"/>
<UsageCount Value="8"/>
</Unit17>
<Unit18>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/ocr.inc"/>
<CursorPos X="20" Y="4"/>
<TopLine Value="1"/>
<EditorIndex Value="14"/>
<UsageCount Value="48"/>
<EditorIndex Value="11"/>
<UsageCount Value="27"/>
<Loaded Value="True"/>
</Unit18>
<Unit19>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<UnitName Value="dtm"/>
<CursorPos X="89" Y="33"/>
<TopLine Value="1"/>
<EditorIndex Value="2"/>
<UsageCount Value="48"/>
<CursorPos X="29" Y="31"/>
<TopLine Value="411"/>
<EditorIndex Value="6"/>
<UsageCount Value="27"/>
<Loaded Value="True"/>
</Unit19>
<Unit20>
<Filename Value="../../Units/MMLCore/dtmutil.pas"/>
<UnitName Value="dtmutil"/>
<CursorPos X="43" Y="218"/>
<TopLine Value="49"/>
<EditorIndex Value="8"/>
<UsageCount Value="44"/>
<CursorPos X="1" Y="89"/>
<TopLine Value="1"/>
<EditorIndex Value="5"/>
<UsageCount Value="23"/>
<Loaded Value="True"/>
</Unit20>
<Unit21>
<Filename Value="../../../../Documents/fpc/packages/fcl-base/src/custapp.pp"/>
<UnitName Value="CustApp"/>
<CursorPos X="59" Y="274"/>
<TopLine Value="274"/>
<EditorIndex Value="5"/>
<UsageCount Value="24"/>
<Loaded Value="True"/>
<CursorPos X="59" Y="48"/>
<TopLine Value="18"/>
<UsageCount Value="9"/>
</Unit21>
<Unit22>
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
<UnitName Value="ocrutil"/>
<CursorPos X="22" Y="470"/>
<TopLine Value="445"/>
<EditorIndex Value="9"/>
<UsageCount Value="32"/>
<CursorPos X="48" Y="417"/>
<TopLine Value="395"/>
<EditorIndex Value="7"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit22>
<Unit23>
<Filename Value="../../Units/Linux/xtest.pas"/>
<UnitName Value="XTest"/>
<CursorPos X="56" Y="22"/>
<TopLine Value="1"/>
<UsageCount Value="6"/>
<Filename Value="../../Units/MMLAddon/colourpicker.pas"/>
<UnitName Value="colourpicker"/>
<CursorPos X="49" Y="288"/>
<TopLine Value="265"/>
<UsageCount Value="10"/>
</Unit23>
<Unit24>
<Filename Value="../../../../Documents/fpc/rtl/inc/mathh.inc"/>
<CursorPos X="58" Y="78"/>
<TopLine Value="57"/>
<UsageCount Value="6"/>
<Filename Value="../../Units/MMLAddon/PSInc/pscompile.inc"/>
<CursorPos X="116" Y="38"/>
<TopLine Value="12"/>
<UsageCount Value="10"/>
</Unit24>
<Unit25>
<Filename Value="../../../../Documents/fpc/rtl/inc/innr.inc"/>
<CursorPos X="4" Y="98"/>
<TopLine Value="78"/>
<UsageCount Value="6"/>
<Filename Value="../../Units/MMLAddon/PSInc/psdefines.inc"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="2"/>
<UsageCount Value="10"/>
</Unit25>
<Unit26>
<Filename Value="../../../../Documents/lazarus/lcl/graphtype.pp"/>
<UnitName Value="GraphType"/>
<CursorPos X="72" Y="96"/>
<TopLine Value="72"/>
<UsageCount Value="12"/>
<Filename Value="../../Units/MMLAddon/PSInc/psexportedmethods.inc"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<UsageCount Value="10"/>
</Unit26>
<Unit27>
<Filename Value="../../Units/Synapse/httpsend.pas"/>
<UnitName Value="httpsend"/>
<CursorPos X="64" Y="365"/>
<TopLine Value="379"/>
<UsageCount Value="14"/>
</Unit27>
<Unit28>
<Filename Value="../../Units/MMLAddon/internets.pas"/>
<UnitName Value="internets"/>
<CursorPos X="9" Y="21"/>
<TopLine Value="1"/>
<EditorIndex Value="3"/>
<UsageCount Value="15"/>
<Loaded Value="True"/>
</Unit28>
<Unit29>
<Filename Value="../../../../Documents/fpc/rtl/objpas/classes/classesh.inc"/>
<CursorPos X="14" Y="712"/>
<TopLine Value="696"/>
<UsageCount Value="9"/>
</Unit29>
<Unit30>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<UnitName Value="updater"/>
<CursorPos X="18" Y="199"/>
<TopLine Value="174"/>
<EditorIndex Value="4"/>
<UsageCount Value="15"/>
<Loaded Value="True"/>
</Unit30>
<Unit31>
<Filename Value="../../Units/Synapse/blcksock.pas"/>
<UnitName Value="blcksock"/>
<CursorPos X="3" Y="198"/>
<TopLine Value="180"/>
<UsageCount Value="15"/>
</Unit31>
<Unit32>
<Filename Value="../../Units/Synapse/ssfpc.pas"/>
<UnitName Value="ssfpc"/>
<CursorPos X="3" Y="94"/>
<TopLine Value="1"/>
<UsageCount Value="9"/>
</Unit32>
<Unit33>
<Filename Value="../../Units/Synapse/sslinux.pas"/>
<UnitName Value="sslinux"/>
<CursorPos X="1" Y="62"/>
<TopLine Value="32"/>
<UsageCount Value="9"/>
</Unit33>
</Units>
<JumpHistory Count="29" HistoryIndex="28">
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="75" Column="23" TopLine="62"/>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="1618" Column="22" TopLine="1607"/>
</Position1>
<Position2>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="115" Column="13" TopLine="84"/>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="1637" Column="18" TopLine="1621"/>
</Position2>
<Position3>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="70" Column="60" TopLine="45"/>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="31" Column="54" TopLine="13"/>
</Position3>
<Position4>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="110" Column="15" TopLine="95"/>
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
<Caret Line="8" Column="38" TopLine="1"/>
</Position4>
<Position5>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="117" Column="44" TopLine="92"/>
<Filename Value="../../Units/MMLCore/colour_conv.pas"/>
<Caret Line="47" Column="31" TopLine="27"/>
</Position5>
<Position6>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="30" Column="30" TopLine="11"/>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="31" Column="53" TopLine="24"/>
</Position6>
<Position7>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="126" Column="11" TopLine="95"/>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="85" Column="74" TopLine="75"/>
</Position7>
<Position8>
<Filename Value="project1.lpr"/>
<Caret Line="12" Column="7" TopLine="5"/>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="2027" Column="29" TopLine="2002"/>
</Position8>
<Position9>
<Filename Value="../../Units/MMLCore/client.pas"/>
<Caret Line="33" Column="20" TopLine="1"/>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="2028" Column="37" TopLine="2009"/>
</Position9>
<Position10>
<Filename Value="../../Units/MMLCore/files.pas"/>
<Caret Line="123" Column="19" TopLine="111"/>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="2021" Column="75" TopLine="2004"/>
</Position10>
<Position11>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="140" Column="18" TopLine="117"/>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="1832" Column="28" TopLine="1827"/>
</Position11>
<Position12>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="35" Column="59" TopLine="17"/>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="1822" Column="1" TopLine="1808"/>
</Position12>
<Position13>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="131" Column="13" TopLine="113"/>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="1877" Column="23" TopLine="1867"/>
</Position13>
<Position14>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="130" Column="19" TopLine="113"/>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="62" Column="31" TopLine="44"/>
</Position14>
<Position15>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="131" Column="13" TopLine="112"/>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="1893" Column="88" TopLine="1867"/>
</Position15>
<Position16>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="120" Column="54" TopLine="102"/>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="2033" Column="30" TopLine="2002"/>
</Position16>
<Position17>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="40" Column="33" TopLine="12"/>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="1934" Column="32" TopLine="1916"/>
</Position17>
<Position18>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="38" Column="41" TopLine="20"/>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="2007" Column="29" TopLine="1989"/>
</Position18>
<Position19>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="130" Column="18" TopLine="113"/>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="87" Column="28" TopLine="78"/>
</Position19>
<Position20>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="8" Column="26" TopLine="1"/>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="2010" Column="81" TopLine="1989"/>
</Position20>
<Position21>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="130" Column="18" TopLine="113"/>
<Filename Value="project1.lpr"/>
<Caret Line="111" Column="22" TopLine="101"/>
</Position21>
<Position22>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="23" Column="27" TopLine="5"/>
<Filename Value="../../Units/MMLCore/dtmutil.pas"/>
<Caret Line="31" Column="24" TopLine="12"/>
</Position22>
<Position23>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="16" Column="1" TopLine="5"/>
<Filename Value="../../Units/MMLCore/dtmutil.pas"/>
<Caret Line="158" Column="46" TopLine="133"/>
</Position23>
<Position24>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="28" Column="39" TopLine="16"/>
<Filename Value="../../Units/MMLCore/dtmutil.pas"/>
<Caret Line="148" Column="33" TopLine="119"/>
</Position24>
<Position25>
<Filename Value="project1.lpr"/>
<Caret Line="117" Column="13" TopLine="98"/>
<Filename Value="../../Units/MMLCore/dtmutil.pas"/>
<Caret Line="31" Column="30" TopLine="1"/>
</Position25>
<Position26>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="129" Column="25" TopLine="111"/>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="1898" Column="99" TopLine="1878"/>
</Position26>
<Position27>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="95" Column="56" TopLine="67"/>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="1902" Column="65" TopLine="1884"/>
</Position27>
<Position28>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="157" Column="1" TopLine="132"/>
<Filename Value="project1.lpr"/>
<Caret Line="51" Column="35" TopLine="34"/>
</Position28>
<Position29>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="156" Column="50" TopLine="139"/>
<Filename Value="../../Units/MMLCore/dtmutil.pas"/>
<Caret Line="77" Column="5" TopLine="49"/>
</Position29>
<Position30>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="31" Column="29" TopLine="1"/>
</Position30>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>
<Version Value="8"/>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)/"/>
<OtherUnitFiles Value="$(ProjPath)/../../Units/MMLCore/;$(ProjPath)/../../Units/Misc/;$(ProjPath)/../../Units/MMLAddon/;$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/$(LCLWidgetType)/;$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/;$(ProjPath)/../../Units/Linux/;$(ProjPath)/../../Units/Synapse/;$(LazarusDir)/components/mouseandkeyinput/"/>
<OtherUnitFiles Value="$(ProjPath)/../../Units/MMLCore/;$(ProjPath)/../../Units/Misc/;$(ProjPath)/../../Units/MMLAddon/;$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/$(LCLWidgetType)/;$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/;$(ProjPath)/../../Units/Linux/;$(LazarusDir)/components/mouseandkeyinput/"/>
</SearchPaths>
<CodeGeneration>
<Optimizations>
<VariablesInRegisters Value="True"/>
<OptimizationLevel Value="3"/>
</Optimizations>
</CodeGeneration>

View File

@ -10,8 +10,7 @@ uses
Forms,Interfaces,
LCLIntf,
Client,
bitmaps,{x ,}mufasatypes,dtm,dtmutil, ocrutil ,graphics ,colour_conv,math,
updater
bitmaps,x ,mufasatypes,dtm,dtmutil, ocrutil
{ you can add units after this };
@ -47,51 +46,24 @@ begin
result.t[i] := random(255);
result.asz [i] := random(5);
result.ash[i] := 0;
writeln(format('dtm: (%d, %d) c: %d, t: %d, asz: %d', [result.p[i].x,
result.p[i].y, result.c[i], result.t[i], result.asz[i]]));
{writeln(format('dtm: (%d, %d) c: %d, t: %d, asz: %d', [result.p[i].x,
result.p[i].y, result.c[i], result.t[i], result.asz[i]])); }
result.gp[i] := false;// random(10) = 1;
end;
result.c[0] := 255;
end;
var
aTime: dword;
function myChange: boolean;
begin
if gettickcount-atime > 1000 then
result := true
else
result := false;
PrintpDTM(result);
end;
procedure MufasaTests.DoRun;
{const
ocr_Limit_High = 191;
ocr_Limit_Low = 65;
ocr_White = 16777215;
ocr_Green = 65280;
ocr_Red = 255;
ocr_Yellow = 65535;
ocr_Blue = 16776960;
ocr_ItemC = 16744447;
ocr_Purple = 8388736; }
var
ErrorMsg: String;
{ Time: DWord;
Time: DWord;
C: TClient;
I, w, h,x,y: Integer;
I: Integer;
dtm: pdtm;
p:tpointarray;
bmp, bmprs: TMufasaBitmap;
tbmp: TBitmap;
r,g,b:integer;
t:Dword; }
up: TMMLFileDownloader;
bmp: TMufasaBitmap;
begin
// quick check parameters
@ -109,59 +81,57 @@ begin
Exit;
end;
atime:=gettickcount;
up := TMMLFileDownloader.Create;
up.FileURL:='http://www.villavu.com/pics/desktop.png';
up.ReplacementFile:='test.png';
up.OnBeat:=@myChange;
try
up.DownloadAndSave;
up.Replace;
finally
writeln(inttostr(gettickcount-atime));
up.Free;
end;
{ clOlive = false point }
{ clSilver = false shadow }
{ clLime = false shadow}
{ add your program here }
C := TClient.Create;
{ tbmp:=TBitmap.Create;
tbmp.LoadFromFile('/home/merlijn/Programs/mufasa/pics/16.bmp');
bmprs := TMufasaBitmap.Create;
bmprs.SetSize(10,10);
bmprs.LoadFromRawImage(tbmp.RawImage);
tbmp.Free;
tbmp := bmprs.ToTBitmap;
}
{ for y := 0 to tbmp.Height -1 do
for x := 0 to tbmp.width -1 do
begin
writeln(format('(%d, %d) = %d , %d', [x,y,tbmp.Canvas.pixels[x,y],bmprs.FastGetPixel(x,y)]));
colortorgb(tbmp.Canvas.pixels[x,y],r,g,b);
writeln(format('%d,%d,%d', [r,g,b]));
colortorgb(bmprs.FastGetPixel(x,y),r,g,b);
writeln(format('%d,%d,%d', [r,g,b]));
end; }
//bmprs.LoadFromFile('/home/merlijn/Programs/mufasa/pics/16.bmp');
{C := TClient.Create;
C.MWindow.SetTarget(bmprs); }
bmp := TMufasaBitmap.Create;
bmp.SetSize(CW,CH);
Writeln(Format('Client W/H: %d, %d', [CW, CH]));
FillChar(bmp.FData[0],sizeof(trgb32)*CW*CH, 0);
Randomize;
for i := 0 to 500 do
bmp.fastsetpixel(random(CW), random(CH), 255);
{ bmp.FastSetPixel(8,8,255);
bmp.FastSetPixel(9,9,255);
bmp.FastSetPixel(7,7,255);
bmp.FastSetPixel(9,8,255);
bmp.FastSetPixel(8,9,255); }
C.MWindow.SetTarget(bmp);
{ bmp.SaveToFile('/tmp/output.bmp');
tbmp.SaveToFile('/tmp/output2.bmp');
//bmp.OnDestroy:=nil;
{ initdtm(dtm, 5);
dtm.p[0] := Point(2, 2);
dtm.p[1] := Point(-3, -3);
dtm.p[2] := Point(0, 0);
dtm.p[3] := Point(1, 1);
dtm.p[4] := Point(3, 3);
dtm.c[0] := 255;
dtm.t[0] := 0;
dtm.asz[1] := 1;
dtm.ash[1] := dtm_Rectangle; }
dtm := randomdtm(10);
// setlength(p, 1);
C.MFinder.SetToleranceSpeed(1);
time := GetTickCount;
for i := 0 to 100 do
begin
setlength(p,0);
C.MFinder.FindDTMs(dtm, p, 0, 0,CW-1, CH-1, 0);
end;
writeln(inttostr(gettickcount - time) + 'ms');
writeln(inttostr(length(p))+ ' points found');
setlength(p,0);
{for i := 0 to high(p) do
writeln(format('%d: (%d, %d)', [i, p[i].x, p[i].y])); }
//bmp.OnDestroy:=nil;
bmp.Free;
tbmp.Free; }
// C.Free;
C.Free;
// stop program loop
Terminate;

View File

@ -32,10 +32,10 @@ Sender.Comp.AddTypeS('TBmpMirrorStyle','(MirrorWidth,MirrorHeight,MirrorLine)');
Sender.Comp.AddTypeS('TMask','record White, Black : TPointArray; WhiteHi,BlackHi : integer; W,H : integer;end;');
Sender.Comp.AddTypes('TDTMPointDef', 'record x, y, Color, Tolerance, AreaSize, AreaShape: integer; end;');
Sender.Comp.AddTypes('TDTMPointDef', 'record x, y, Color, Tolerance, AreaSize, AreaShape: integer; Good: Boolean; end;');
Sender.Comp.AddTypes('TDTMPointDefArray', 'Array Of TDTMPointDef;');
Sender.Comp.AddTypes('TDTM','record MainPoint: TDTMPointDef; SubPoints: TDTMPointDefArray; end;');
Sender.Comp.AddTypeS('pDTM','record l: Integer;p: TPointArray;c, t, asz, ash: TIntegerArray;n: String; end;');
Sender.Comp.AddTypeS('pDTM','record l: Integer;p: TPointArray;c, t, asz, ash: TIntegerArray; gp: array of boolean; n: String; end;');
Sender.Comp.AddTypeS('T2DExtendedArray', 'array of array of extended;');
Sender.Comp.AddTypeS('TStringArray','Array of string;');

View File

@ -78,24 +78,6 @@ type
FreeSpots: Array Of Integer;
end;
{
I am not sure wether I should simply copy and paste the old DTM implementation,
or rewrite it from scratch.
The old DTM system problaby doesn't perform that well, but seems to be quite
stable and complete.
If I would rewrite it from scratch, it would probably be faster, and
hopefully more efficient.That won't be too hard, especially since I have
direct data access now. (TClient FTW!)
Rewrite from scratch it will be, I guess.
And AreaShape will be turned into a {$I }, inline simply doesn't cut it.
~Wizz
}
implementation
uses
Client, dtmutil, paszlib,

View File

@ -64,6 +64,8 @@ begin
setlength(d.t, len);
setlength(d.ash, len);
setlength(d.asz, len);
setlength(d.gp, len);
FillChar(d.p[0], SizeOf(TPoint) * len, 0);
FillChar(d.c[0], SizeOf(Integer) * len, 0);
FillChar(d.t[0], SizeOf(Integer) * len, 0);
@ -71,8 +73,10 @@ begin
// Better set it to 1, than fill with 0.
FillChar(d.asz[0], SizeOf(Integer) * len, 0);
{for i := 0 to len - 1 do
d.asz[i] := 1; }
//FillChar(d.gp[0], SizeOf(Boolean) * len, 0);
for i := 0 to len - 1 do
d.gp[i] := true;
end;
Procedure PrintpDTM(tDTM : pDTM);
@ -82,9 +86,9 @@ begin;
i := 0;
if tdtm.n <> '' then
writeln('Name: ' + tdtm.n);
WriteLn('MainPoint ' + inttostr(tDTM.p[i].x) + ', ' + inttostr(tDTM.p[i].y) + ' col: ' + inttostr(tDTM.c[i]) + ', tol: ' + inttostr(tDTM.t[i]) + '; ashape ' + inttostr(tdtm.ash[i]) + ' asize ' + inttostr(tdtm.asz[i]));
WriteLn('MainPoint ' + inttostr(tDTM.p[i].x) + ', ' + inttostr(tDTM.p[i].y) + ' col: ' + inttostr(tDTM.c[i]) + ', tol: ' + inttostr(tDTM.t[i]) + '; ashape ' + inttostr(tdtm.ash[i]) + ' asize ' + inttostr(tdtm.asz[i])+ ', Good: ' + BoolToStr(tdtm.gp[i]));
for I := 1 to High(tDTM.p) do
WriteLn('SubPoint['+IntToStr(I) + '] ' + inttostr(tDTM.p[i].x) + ', ' + inttostr(tDTM.p[i].y) + ' col: ' + inttostr(tDTM.c[i]) + ', tol: ' + inttostr(tDTM.t[i]) + '; ashape ' + inttostr(tdtm.ash[i]) + ' asize ' + inttostr(tdtm.asz[i]));
WriteLn('SubPoint['+IntToStr(I) + '] ' + inttostr(tDTM.p[i].x) + ', ' + inttostr(tDTM.p[i].y) + ' col: ' + inttostr(tDTM.c[i]) + ', tol: ' + inttostr(tDTM.t[i]) + '; ashape ' + inttostr(tdtm.ash[i]) + ' asize ' + inttostr(tdtm.asz[i]) + ', Good: ' + BoolToStr(tdtm.gp[i]));
end;
Function pDTMToTDTM(Const DTM: pDTM): TDTM;
@ -102,6 +106,7 @@ Begin
Temp.AreaShape := DTM.ash[i];
Temp.Color := DTM.c[i];
Temp.Tolerance := DTM.t[i];
Temp.Good:= DTM.gp[i];
End;
Result.MainPoint := Temp;
SetLength(Result.SubPoints, Length(DTM.p) - 1);
@ -115,6 +120,7 @@ Begin
Temp.AreaShape := DTM.ash[i];
Temp.Color := DTM.c[i];
Temp.Tolerance := DTM.t[i];
Temp.Good:= DTM.gp[i];
Result.SubPoints[I - 1] := Temp;
End;
End;
@ -135,6 +141,7 @@ Begin
SetLength(Result.t, Length(DTM.SubPoints) + 1);
SetLength(Result.asz, Length(DTM.SubPoints) + 1);
SetLength(Result.ash, Length(DTM.SubPoints) + 1);
SetLength(Result.gp, Length(DTM.SubPoints) + 1);
Result.p[0].x := DTM.MainPoint.x;
Result.p[0].y := DTM.MainPoint.y;
@ -142,6 +149,7 @@ Begin
Result.t[0] := DTM.MainPoint.Tolerance;
Result.asz[0] := DTM.MainPoint.AreaSize;
Result.ash[0] := DTM.MainPoint.AreaShape;
Result.gp[0] := DTM.MainPoint.Good;
For I := 1 To Length(DTM.SubPoints) Do // High + 1 = Length
Begin
@ -151,6 +159,7 @@ Begin
Result.t[I] := DTM.SubPoints[I - 1].Tolerance;
Result.asz[I] := DTM.SubPoints[I - 1].AreaSize;
Result.ash[I] := DTM.SubPoints[I - 1].AreaShape;
Result.gp[I] := DTM.SubPoints[I - 1].Good;
End;
Result.l := length(Result.p);
End;
@ -172,6 +181,8 @@ begin
Exit(False);
if dtm.l <> length(dtm.ash) then
Exit(False);
if dtm.l <> length(dtm.gp) then
Exit(False);
for i := 0 to dtm.l-1 do
if dtm.asz[i] < 0 then
Exit(False);

View File

@ -1841,15 +1841,15 @@ begin
// Init data structure B.
W := x2 - x1;
H := y2 - y1;
setlength(b, W + 1);
setlength(b, (W + 1) * 2);
for i := 0 to W do
begin
setlength(b[i], H + 1);
setlength(b[i], (H + 1) * 2);
// does setlength init already? if it doesn't, do we want to init here?
// or do we want to init in the loop, as we loop over every b anyway?
// init
FillChar(b[i][0], SizeOf(Integer) * H, 0);
FillChar(b[i][0], SizeOf(Integer) * H * 2, 0);
end;
// C = DTM.C
@ -1869,25 +1869,38 @@ begin
for yy := MA.y1 to MA.y2 do
for xx := MA.x1 to MA.x2 do
begin
// main point
if Sqrt(sqr(rgbs[0].r - cd[yy][xx].R) + sqr(rgbs[0].g - cd[yy][xx].G) + sqr(rgbs[0].b - cd[yy][xx].B)) > dtm.t[0] then
// if not SimilarColors(dtm.c[0], RGBToColor(cd[yy][xx].R, cd[yy][xx].G, cd[yy][xx].B), dtm.t[0]) then
goto AnotherLoopEnd;
// Checking main point now; store that we have checked it.
// (Main point is point 1)
b[xx][yy] := B[xx][yy] or 1;
// if Sqrt(sqr(rgbs[0].r - cd[yy][xx].R) + sqr(rgbs[0].g - cd[yy][xx].G) + sqr(rgbs[0].b - cd[yy][xx].B)) > dtm.t[0] then
if not SimilarColors(dtm.c[0], RGBToColor(cd[yy][xx].R, cd[yy][xx].G, cd[yy][xx].B), dtm.t[0]) then
goto AnotherLoopEnd;
// Mainpoint match. (If it did not match, we would be at AnotherLoopEnd)
b[xx][yy+1] := B[xx][yy+1] or 1;
for i := 1 to dtm.l - 1 do
begin //change to use other areashapes too.
for xxx := xx - dtm.asz[i] + dtm.p[i].x to xx + dtm.asz[i] + dtm.p[i].x do
for yyy := yy - dtm.asz[i] + dtm.p[i].y to yy + dtm.asz[i]+ dtm.p[i].y do
begin
// may want to remove this line, but I think it is a good optimisation.
if B[xxx][yyy] and (1 shl i) = 0 then
// If we have matched this point
if b[xxx][yyy+1] and (1 shl i) = 0 then
begin
if Sqrt(sqr(rgbs[i].r - cd[yyy][xxx].R) + sqr(rgbs[i].g - cd[yyy][xxx].G) + sqr(rgbs[i].b - cd[yyy][xxx].B)) <= dtm.t[i] then
// if SimilarColors(dtm.c[i], RGBToColor(cd[yyy][xxx].R, cd[yyy][xxx].G, cd[yyy][xxx].B), dtm.t[i]) then
b[xxx][yyy] := B[xxx][yyy] or (1 shl i)
// Checking point i now. (Store that we matched it)
b[xxx][yyy]:=b[xxx][yyy] or (1 shl i);
// if Sqrt(sqr(rgbs[i].r - cd[yyy][xxx].R) + sqr(rgbs[i].g - cd[yyy][xxx].G) + sqr(rgbs[i].b - cd[yyy][xxx].B)) <= dtm.t[i] then
if SimilarColors(dtm.c[i], RGBToColor(cd[yyy][xxx].R, cd[yyy][xxx].G, cd[yyy][xxx].B), dtm.t[i]) then
b[xxx][yyy+1] := B[xxx][yyy+1] or (1 shl i)
else
goto AnotherLoopEnd;
end;
if (b[xxx][yyy+1] and (1 shl i) = 0) and dtm.gp[i] then
goto AnotherLoopEnd;
end;
end;
//writeln(Format('Found point: (%d, %d)', [xx,yy]));

View File

@ -98,6 +98,7 @@ type
l: Integer;
p: TPointArray;
c, t, asz, ash: TIntegerArray;
gp: TBoolArray;
n: String; // DOEN
end;
@ -105,6 +106,7 @@ type
TDTMPointDef = record
x, y, Color, Tolerance, AreaSize, AreaShape: integer;
Good: Boolean;
end;
TDTMPointDefArray = Array Of TDTMPointDef;

View File

@ -572,6 +572,7 @@ begin
H := Attrib.Height;
end else
begin
{ TODO: Raise Exception because the Window does not exist? }
W := -1;
H := -1;
end;