1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
int mainStaticMatch()
{
IplImage *img1;
IplImage *img2[6];
IpVec ipts1, ipts2[6];
IpPairVec matches[6], matchesMax;
int number_max_matches=0, indice_max;
img1 = cvLoadImage("bourse1.jpg");
surfDetDes(img1,ipts1,false,4,4,2,0.0001f);
for (int k=0; k<6; k++)
{
stringstream ss;
ss << "file" << k+1 << ".jpg";
img2[k] = cvLoadImage(ss.str().c_str());
surfDetDes(img2[k],ipts2[k],false,4,4,2,0.0001f);
getMatches(ipts1,ipts2[k],matches[k]);
if(k==0)
{
number_max_matches = matches[k].size();
indice_max = k;
matchesMax = matches[k];
}
else if(matches[k].size() > number_max_matches)
{
number_max_matches = matches[k].size();
indice_max = k;
matchesMax = matches[k];
}
}
switch (indice_max)
{
case 0: cout<< "Votre photo est celle de la Banque de France." ; break;
case 1: cout<< "Votre photo est celle du parlement anglais." ;break;
case 2: cout<< "Votre photo est celle de la place de la bourse de bordeaux." ;break;
case 3: cout<< "Votre photo est celle du parlement anglais." ;break;
case 4: cout<< "Votre photo est celle du pentagone." ;break;
case 5: cout<< "Votre photo est celle de la tour eiffel." ;break;
}
std::cout<< "Matches: " << number_max_matches;
for (int i = 0; i < number_max_matches; i++)
{
drawPoint(img1, matchesMax[i].first);
drawPoint(img2[indice_max], matchesMax[i].second);
const int & w = img1->width;
cvLine(img1,cvPoint(matchesMax[i].first.x, matchesMax[i].first.y), cvPoint(matchesMax[i].second.x+w, matchesMax[i].second.y), cvScalar(255,255,255), 1);
cvLine(img2[indice_max],cvPoint(matchesMax[i].first.x-w, matchesMax [i].first.y), cvPoint(matchesMax[i].second.x, matchesMax[i].second.y), cvScalar(255,255,255), 1);
}
cvNamedWindow("1", CV_WINDOW_AUTOSIZE );
cvNamedWindow("2", CV_WINDOW_AUTOSIZE );
cvShowImage("1", img1);
cvShowImage("2", img2[indice_max]);
cvWaitKey(0);
return 0;
} |
Partager