ImageEn, unit ievision

TIEVisionImage.matchTemplate

TIEVisionImage.matchTemplate


Declaration

function matchTemplate(templ: TIEVisionImage; matchMethod: TIEVisionTemplateMatchMethod; rank: double_p = nil): TIEVisionRect; safecall;


Description

Searches the image for the location of the template image and returns the best matched rectangle.

Parameter Description
templ Template image to find. It must be not larger than the source image.
matchMethod Comparison method
rank Returns the confidence level of the match. Range is 0 to 100%, though generally values of <90% are not good matches




Demo

Demo  Demos\IEVision\PatternMatching\PatternMatching.dpr


Example

procedure TMainForm.Button2Click(Sender: TObject);
var
  image, templ: TIEVisionImage;
  rect: TIEVisionRect;
begin
  ImageEnVect1.RemoveAllObjects();

  // get image to search
  image := ImageEnVect1.IEBitmap.GetIEVisionImage();

  // get the template image to find
  templ := IEVSource.IEBitmap.GetIEVisionImage();

  // perform template searching
  rect := image.matchTemplate(templ, TIEVisionTemplateMatchMethod(ComboBox1.ItemIndex));

  // draw a red box around the found rectangle
  ImageEnVect1.ObjPenWidth[-1] := 3;
  ImageEnVect1.AddNewObject(iekBOX, IEVisionRectToTRect(rect), clRed);
end;