cvMul_ = (void(__stdcall *)( const CvArr* src1, const CvArr* src2, CvArr* dst, double scale=1))GetProcAddress(cv, "cvMul");
if (!cvMul_) return;
cvaux = LoadLibrary("cv100.dll");
if (!cvaux) return;
cvThreshold_ = (void(__stdcall *)(const CvArr* src, CvArr* dst, double threshold,double max_value, int threshold_type))GetProcAddress(cvaux, "cvThreshold");
if (!cvThreshold_) return;
Objs=new IplImage*[obj_number];
Objs[0] = cvLoadImage( ".\et\1.bmp", 0);
show_im(Image1->Canvas,Objs[0]);
Objs[1] = cvLoadImage( ".\et\2.bmp", 0);
show_im(Image2->Canvas,Objs[1]);
Objs[2] = cvLoadImage( ".\et\3.bmp", 0);
show_im(Image3->Canvas,Objs[2]);
String fname="6.bmp";
Object = cvLoadImage((".\in\"+fname).c_str(), 0);
show_im(Image4->Canvas,Object);
}
//---------------------------------------------------------------------------
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.);
if(e[0]>e[1])
if(e[0]>e[2])
ShowMessage("1");
if(e[1]>e[0])
if(e[1]>e[2])
ShowMessage("2");
if(e[2]>e[1])
if(e[2]>e[0])
ShowMessage("3");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image1Click(TObject *Sender)
{
if(OpenPictureDialog1->Execute())
{
Objs[0] = cvLoadImage(OpenPictureDialog1->FileName.c_str(), 0);
show_im(Image1->Canvas,Objs[0]);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image2Click(TObject *Sender)
{
if(OpenPictureDialog1->Execute())
{
Objs[1] = cvLoadImage(OpenPictureDialog1->FileName.c_str(), 0);
show_im(Image2->Canvas,Objs[1]);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image3Click(TObject *Sender)
{
if(OpenPictureDialog1->Execute())
{
Objs[2] = cvLoadImage(OpenPictureDialog1->FileName.c_str(), 0);
show_im(Image3->Canvas,Objs[2]);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image4Click(TObject *Sender)
{
if(OpenPictureDialog1->Execute())
{
Object = cvLoadImage(OpenPictureDialog1->FileName.c_str(), 0);
show_im(Image4->Canvas,Object);
}
}
//---------------------------------------------------------------------------