function FindTopMatchesFeatureVectorDistance(source: CharacterTemplate; matchCnt: integer): TList;
= TList.Create; result.Capacity := matchCnt; for currPos := 0 to matchCnt - 1 do result.Add(nil); currPos := 0; minRelativeDistance := PixelHolderSize * PixelHolderSize; for i := 0 to TemplatesCount - 1 do begin ct := Templates[i]; for j := 0 to ct.TemplatesCount - 1 do begin td := ct.Templates[j]; currDist := td.GetDistance(pixels); currRelativeDistance := currDist {/ td.TotalCount}; if (minRelativeDistance >= currRelativeDistance) then begin minRelativeDistance := currRelativeDistance; if (result[currPos] <> nil) then TemplateMatch(result[currPos]).Free; result[currPos] := TemplateMatch.Create(ct, td, 1 - (currDist / (PixelHolderSize * PixelHolderSize))); Inc(currPos); if currPos >= matchCnt then currPos := 0; end; end; end; result.Pack; result.Sort(@ByRelativeDistanceAscending); end;
procedure ExtractImages; function FindTopMatchesTemplateDistance(pixels: TemplatePixels; matchCnt: integer): TList;
function TemplateLibrary.FindTopMatchesTemplateDistance(pixels: TemplatePixels; matchCnt: integer): TList; var currPos, i, j: integer; ct: CharacterClass; td: CharacterTemplate; minRelativeDistance, currRelativeDistance: double; currDist: integer;
begin