Simba Code:
function GetBitmapText(x1,y1,x2,y2):String;
var tmpBitmap:Integer;
var tmpMufasa:TMufasaBitmap;
var tmpString:String;
begin
tmpBitmap := bitmapFromClient(x1,y1,x2,y2); //creates 1 bitmap
tmpMufasa := GetMufasaBitmap(tmpBitmap); //get the actual underlying bitmap (it's the same as tmpBitmap atm)
tmpMufasa := Resize(tmpMufasa); //Idk of any such method, but as you assign some result.. then you are likely copying..
ThresholdAdaptiveBitmap(tmpBitmap, 0, 255, false, TM_Mean, 18); //runs threshold on the OLD bitmap.. not the new resized one
tmpString := Tess_GetText(tmpMufasa); //Gets text from the new resize one, which is not thresholded...
Freebitmap(tmpBitmap); //free the first bitmap (the thresholded one) -> not the resized one
Result := tmpString;
end;
This is pretty much how it should be:
Simba Code:
function RecognizeTextAt(x1,y1,x2,y2: Int32; Scale:Double; ThresholdMod:Int32):String;
var
clientBmp:TMufasaBitmap;
begin
clientBmp := GetMufasaBitmap(BitmapFromClient(x1,y1,x2,y2)); //get client image and get the actual mufasa bitmap directly
clientBmp.ResizeEx(RM_Bilinear, Round((x2-x1+1)*Scale), Round((y2-y1+1)*Scale)); //resize that bitmap without copying
clientBmp.ThresholdAdaptive(0, 255, False, TM_Mean, ThresholdMod); //threshold it, again without copying
//assuming it takes a mufasabitmap (I don't use SRL-6 at all)
Result := Tess_GetText(clientBmp); //recognize the text
//Result := Tess_GetText(clientBmp.GetIndex()); //if not
clientBmp.Free(); //free
end;
var text:String;
begin
text := RecognizeTextAt(someBounds..., 3.5, 18);
end.