Reputation: 339
int match(int page,Mat img_frame){
Mat des_frame;
std::vector<KeyPoint> kp_frame;
std::vector<vector<DMatch > > matches;
detector.detect( img_frame, kp_frame );
extractor.compute(img_frame,kp_frame,des_frame);
std::vector<DMatch > good_matches;
if(page<0)
return 0;
switch(pageNumber)
{
case 0:
matcher.knnMatch(des_page[0], des_frame, matches, 2);
break;
case 2:
matcher.knnMatch(des_page[1], des_frame, matches, 2);
//cout<<"matcigpage23";
break;
case 4:
matcher.knnMatch(des_page[2], des_frame, matches, 2);
break;
case 6:
matcher.knnMatch(des_page[3], des_frame, matches, 2);
break;
case 8:
matcher.knnMatch(des_page[4], des_frame, matches, 2);
break;
case 10:
matcher.knnMatch(des_page[5], des_frame, matches, 2);
break;
}
for(int i = 0; i < min(des_frame.rows-1,(int) matches.size()); i++) //THIS LOOP IS SENSITIVE TO SEGFAULTS
{
if((matches[i][0].distance < 0.6*(matches[i][1].distance)) && ((int) matches[i].size()<=2 && (int) matches[i].size()>0))
{
good_matches.push_back(matches[i][0]);
}
}
return good_matches.size();
}
I have a function like this in my '.cpp'. When I compile this in Visual Studio 2010, I get a linker error like this:
1>realtime.obj : error LNK2019: unresolved external symbol "public: __thiscall cv::SIFT::SIFT(int,int,double,double,double)" (??0SIFT@cv@@QAE@HHNNN@Z) referenced in function "void _cdecl `dynamic initializer for 'detector''(void)" (??_Edetector@@YAXXZ)
1>realtime.obj : error LNK2019: unresolved external symbol "public: __thiscall cv::flann::KDTreeIndexParams::KDTreeIndexParams(int)" (??0KDTreeIndexParams@flann@cv@@QAE@H@Z) referenced in function "void _cdecl `dynamic initializer for 'matcher''(void)" (??_Ematcher@@YAXXZ)
1>realtime.obj : error LNK2019: unresolved external symbol "public: __thiscall cv::flann::SearchParams::SearchParams(int,float,bool)" (??0SearchParams@flann@cv@@QAE@HM_N@Z) referenced in function "void _cdecl `dynamic initializer for 'matcher''(void)" (??_Ematcher@@YAXXZ)
1>realtime.obj : error LNK2019: unresolved external symbol "public: __thiscall cv::flann::IndexParams::~IndexParams(void)" (??1IndexParams@flann@cv@@QAE@XZ) referenced in function "public: void * __thiscall cv::flann::IndexParams::`scalar deleting destructor'(unsigned int)" (??_GIndexParams@flann@cv@@QAEPAXI@Z)
1>C:\Users\vinit\documents\visual studio 2010\Projects\mynewopencv\Debug\mynewopencv.exe : fatal error LNK1120: 4 unresolved externals
I am new Visual Studio and I will really appreciate some help.
Upvotes: 0
Views: 2675
Reputation: 1687
you need to link the library in the visual studio editor.
Please right click on project in the Solution Explorer and select Properties from the menu.
Under Configuration Properties -> Linker -> Input -> Additional Dependencies add the (.lib) such as-opencv_calib3d220d.lib opencv_contrib220d.lib opencv_core220d.lib opencv_features2d220d.lib
and then do Apply, I hope your problem will be solved.
Upvotes: 1
Reputation: 5138
You are using opencv
and not linking against its library (.lib file).
Right click on your project in the Solution Explorer and select Properties from the context menu.
Under Configuration Properties > Linker > Input add the .lib file for opencv
to Additional Dependencies.
Upvotes: 1