GetTransformationParameters example for C++ Builder
void __fastcall TForm1::Button1Click(TObject *Sender)
{
/* 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.*/
L_INT nAngle, uXTranslation, uYTranslation;
L_UINT uXScale, uYScale;
REGMARKS aSearchMarks[3];
TPoint aMarkPoints[3];
TPoint aMarkCMPoints[3];
TPoint aRefPoints[3];
TPoint CenterPt;
// 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= LEADImage1->BitmapWidth/2;
CenterPt.y= 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, 3 );
LEADImage1->GetMarksCenterMass( aMarkPoints, aMarkCMPoints, 3 );
LEADImage1->GetTransformationParameters( aRefPoints, aMarkCMPoints, uXTranslation, uYTranslation, nAngle, uXScale, uYScale );
}