GetTransformationParameters example for Delphi
procedure TForm1.Button1Click(Sender: TObject);
var
nAngle: L_INT;
uXTranslation: L_INT;
uYTranslation: L_INT;
uXScale: L_UINT;
uYScale: L_UINT;
aSearchMarks: Array[0..2] of REGMARKS;
aMarkPoints: Array[0..2] of TPoint;
aMarkCMPoints: Array[0..2] of TPoint;
aRefPoints: Array[0..2] of TPoint;
CenterPt: TPoint;
begin
{ This example loads a bitmap, and computes the translation parameters.
The example makes the assumption that you have saved the position of the
registration marks of the reference bitmap in a file. It also assumes you have
a method which loads these positions, namely, ?oadRefParameters·
You should modify this example and replace LoadRefParameters with your
own method before testing this example.}
// Load a bitmap at its own bits per pixel
LEADImage1.Load('e:\\image1.cmp', 0, 1, 1 );
// bend the image around it is center
CenterPt.x:= Trunc(LEADImage1.BitmapWidth/2);
CenterPt.y:= Trunc(LEADImage1.BitmapHeight/2);
{ Get aRefPoints from pre-calculated saved values. You have to implement LoadRefParameters }
//LoadRefParameters(aRefPoints);
aSearchMarks[0].uType:= RGS_T;
aSearchMarks[0].uMinScale:= 90;
aSearchMarks[0].uMaxScale:= 110;
aSearchMarks[0].uWidth:= 31;
aSearchMarks[0].uHeight:= 29;
SetRect(aSearchMarks[0].rcRect, 200, 150, 100, 100);
aSearchMarks[0].uSearchMarkCount:= 1;
aSearchMarks[0].pMarkDetectedPoints:= @aMarkPoints[0];
aSearchMarks[1].uType:= RGS_T;
aSearchMarks[1].uMinScale:= 90;
aSearchMarks[1].uMaxScale:= 110;
aSearchMarks[1].uWidth:= 31;
aSearchMarks[1].uHeight:= 29;
SetRect(aSearchMarks[0].rcRect, 200, 150, 100, 100);
aSearchMarks[1].uSearchMarkCount:= 1;
aSearchMarks[1].pMarkDetectedPoints:= @aMarkPoints[1];
aSearchMarks[2].uType:= RGS_T;
aSearchMarks[2].uMinScale:= 90;
aSearchMarks[2].uMaxScale:= 110;
aSearchMarks[2].uWidth:= 31;
aSearchMarks[2].uHeight:= 29;
SetRect(aSearchMarks[0].rcRect, 300,300,100,100);
aSearchMarks[2].uSearchMarkCount:= 1;
aSearchMarks[2].pMarkDetectedPoints:= @aMarkPoints[2];
LEADImage1.Load('e:\\image2.cmp', 0, 1, 1 );
LEADImage1.SearchRegMarks( @aSearchMarks[0], 3 );
LEADImage1.GetMarksCenterMass( @aMarkPoints[0], @aMarkCMPoints, 3 );
LEADImage1.GetTransformationParameters( @aRefPoints[0], @aMarkCMPoints[0], uXTranslation, uYTranslation, nAngle, uXScale, uYScale );
end;