Статья: Реализация метода главных компонент с помощью библиотеки OpenCV
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
float e[3];
CvTermCriteria limit;
CvSize size;
size.width = Object->width; size.height = Object->height;
Pro = cvCreateImage_( size, IPL_DEPTH_8U, 1 );
limit.type = CV_TERMCRIT_EPS;
limit.max_iter = 1;
limit.epsilon = 0.1;
show_im(Image4->Canvas,Object);
pca(obj_number,Objs,limit,Object,Pro);
show_im(Image5->Canvas,Pro);
cvThreshold_(Pro,Object,200,255,CV_THRESH_BINARY);
show_im(Image6->Canvas,Object);
cvMul_(Object,Objs[0],Pro);
show_im(Image7->Canvas,Pro);
cvMul_(Object,Objs[1],Pro);
show_im(Image8->Canvas,Pro);
cvMul_(Object,Objs[2],Pro);
show_im(Image9->Canvas,Pro);
e[0]=cvDotProduct_(Object,Objs[0])/cvDotProduct_(Objs[0],Objs[0]);
e[1]=cvDotProduct_(Object,Objs[1])/cvDotProduct_(Objs[1],Objs[1]);
e[2]=cvDotProduct_(Object,Objs[2])/cvDotProduct_(Objs[2],Objs[2]);
Label1->Caption=FloatToStr(int(e[0]*1000)/1000.);
Label2->Caption=FloatToStr(int(e[1]*1000)/1000.);
Label3->Caption=FloatToStr(int(e[2]*1000)/1000.);