rj
2013-12-18 21:35:59
So… if I use the following code, including SRL5 with the pascalscript interpreter:
I get these results:
But when I use the lape interpreter.. and the function renamed to _724_getChooseOption I get these results..
So… it's somehow different? How come I can't get the choose options with lape? It's finding the boxes but not storing the string?
Debug

it finds the chooseoptions… but it's not splitting into an atpa

somehow the length of that tpa is changing… because when it goes to split it the length of that tpa is 0.
somewhere here
the length of the tpa goes to 0 after the for loop goes after 1. The length of the atpa is 6, but the length of the array of arrays is 0
debug looks like
as you can se.. the lenth was 2817, but after it entered the for loop it went to 0.. why?
Function GetChooseOptions(TextType: string): Array of TOptions;
var
B, BB, sB, BigBox: TBox;
TPA, TPA1, TPA2: TPointArray;
ATPA, tempatpa: T2DPointArray;
I, L, target, bmp,w,h, cts: Integer;
BoxColors: TIntegerArray;
begin
target := GetImageTarget;
GetClientDimensions(B.X2, B.Y2);
B := IntToBox(0, 0, B.X2-1, B.Y2-1);
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
// Black, Top Blue, grey
BoxColors := [131843, 3682593, 3552822];
SetLength(ATPA, Length(BoxColors));
for i := 0 to High(BoxColors) do
FindColorsTolerance(ATPA[i], BoxColors[i], B.X1, B.Y1, B.X2, B.Y2, 0);
TPA := MergeATPA(ATPA);
If Length(TPA) < 100 Then
begin
ColorToleranceSpeed(cts);
Exit;
end;
ATPA := SplitTPA(TPA, 4);
For i := 0 to High(ATPA) do
begin
B := GetTPABounds(ATPA[i]);
if ((B.x2-B.x1) > 90) and ((B.y2-B.y1) > 18) then
Break
else
B := IntToBox(0, 0, 0, 0);
end;
If (B.x2 = 0) then
begin
ColorToleranceSpeed(cts);
Exit;
end;
BigBox := B;
SetColorToleranceSpeed(3);
FindColorsTolerance(TPA1, 4996381, B.X1, B.Y1, B.X2, B.Y2, 18);//One color covers both Highlighted and non
sB := GetTPABounds(TPA1);
ReturnPointsNotInTPAWrap(TPA1, sB, TPA);
FindColorsTolerance(TPA2, 460291, B.X1, B.Y1, B.X2, B.Y2, 6);//shadow
SetColorToleranceSpeed(cts);
bmp := CreateBitmap(B.X2-B.X1+2, B.Y2-B.Y1+2);
OffsetTPA(TPA, Point(-B.X1, -B.Y1));
OffsetTPA(TPA2, Point(-B.X1, -B.Y1));
FastDrawClear(bmp, 0);
DrawTPABitmap(bmp, TPA, clRed);//Text
DrawTPABitmap(bmp, TPA2, clPurple);//Shadow
ocr_FilterUpTextByCharacteristics(GetMufasaBitmap(bmp));
GetbitmapSize(bmp,w,h);
SetTargetBitmap(bmp); // new target for findcolorstolerance.
SetLength(ATPA, H div 16);
for i := 0 to High(ATPA) do
FindColorsTolerance(ATPA[i], clRed, 0, 2+i*16, W-1, 18+i*16, 0);//+2 to y to line it up
L := High(ATPA);
SortATPAFromFirstPointY(ATPA, Point(w div 2,0));
SetArrayLength(Result, Length(ATPA));
Result[0].BigBox := BigBox;
for i := 0 to high(ATPA) do
begin
TPA := ATPA[i];
tempatpa := SplitTPAEx(TPA, 1, 10); // Split one into characters
SortATPAFromFirstPointX(tempatpa, Point(0, 0));
Result[i].Str := GetTextATPA(tempatpa, 5, 'UpCharsEx'); //Writeln(Result[i].Str);
BB := GetTPABounds(ATPA[i]);
Result[i].Bounds := IntToBox(BB.X1+B.X1, BB.Y1+B.Y1, BB.X2+B.X1, BB.Y2+B.Y1);
setlength(tempatpa,0);
setlength(TPA,0);
end;
ColorToleranceSpeed(cts);
SetImageTarget(target);
FreeBitmap(bmp);
end; I get these results:
[('CraM Diamond', (702, 473, 793, 485), (700, 469, 824, 553)), ('Use Diamond', (702, 489, 783, 498), (0, 0, 0, 0)), ('Drop Diamond', (702, 505, 788, 517), (0, 0, 0, 0)), ('Examine Diamond', (702, 521, 811, 530), (0, 0, 0, 0)), ('Cancel', (702, 537, 742, 546), (0, 0, 0, 0))]But when I use the lape interpreter.. and the function renamed to _724_getChooseOption I get these results..
[{STR = , BOUNDS = {X1 = 700, Y1 = 472, X2 = 700, Y2 = 472}, BIGBOX = {X1 = 700, Y1 = 472, X2 = 824, Y2 = 556}}, {STR = , BOUNDS = {X1 = 700, Y1 = 472, X2 = 700, Y2 = 472}, BIGBOX = {X1 = 0, Y1 = 0, X2 = 0, Y2 = 0}}, {STR = , BOUNDS = {X1 = 700, Y1 = 472, X2 = 700, Y2 = 472}, BIGBOX = {X1 = 0, Y1 = 0, X2 = 0, Y2 = 0}}, {STR = , BOUNDS = {X1 = 700, Y1 = 472, X2 = 700, Y2 = 472}, BIGBOX = {X1 = 0, Y1 = 0, X2 = 0, Y2 = 0}}, {STR = , BOUNDS = {X1 = 700, Y1 = 472, X2 = 700, Y2 = 472}, BIGBOX = {X1 = 0, Y1 = 0, X2 = 0, Y2 = 0}}So… it's somehow different? How come I can't get the choose options with lape? It's finding the boxes but not storing the string?
Debug

it finds the chooseoptions… but it's not splitting into an atpa

somehow the length of that tpa is changing… because when it goes to split it the length of that tpa is 0.
somewhere here
writeln('length 2 ', length(tpa));
Result[0].BigBox := BigBox;
for i := 0 to high(ATPA) do
begin
writeln('length 3 ', length(tpa));
TPA := ATPA[i]; the length of the tpa goes to 0 after the for loop goes after 1. The length of the atpa is 6, but the length of the array of arrays is 0
debug looks like
length 1 2817
length 2 2817
length 3 2817
length 3 0
length 3 0
length 3 0
length 3 0
length 3 0as you can se.. the lenth was 2817, but after it entered the for loop it went to 0.. why?
