0
    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();
}

我的“.cpp”中有这样的功能。当我在 Visual Studio 2010 中编译它时,我收到如下链接器错误:

1>realtime.obj:错误 LNK2019:引用了未解析的外部符号“public:__thiscall cv::SIFT::SIFT(int,int,double,double,double)”(??0SIFT@cv@@QAE@HHNNN@Z)在函数“void _ cdecl 'detector''(void) 的动态初始化程序”中 (?? _Edetector@@YAXXZ)

1>realtime.obj:错误 LNK2019:未解析的外部符号“公共:__thiscall cv::flann::KDTreeIndexParams::KDTreeIndexParams(int)”(??0KDTreeIndexParams@flann@cv@@QAE@H@Z) 在函数中引用“ void _ cdecl 'matcher'的动态初始化器'(void)" (?? _Ematcher@@YAXXZ)

1>realtime.obj:错误 LNK2019:未解析的外部符号“公共:__thiscall cv::flann::SearchParams::SearchParams(int,float,bool)”(??0SearchParams@flann@cv@@QAE@HM_N@Z)在函数“void _ cdecl 'matcher'(void) 的动态初始化程序”中引用 (?? _Ematcher@@YAXXZ)

1>realtime.obj:错误 LNK2019:未解析的外部符号“public:__thiscall cv::flann::IndexParams::~IndexParams(void)”(??1IndexParams@flann@cv@@QAE@XZ) 在函数“public”中引用: void * __thiscall cv::flann::IndexParams::`标量删除析构函数'(unsigned int)" (??_GIndexParams@flann@cv@@QAEPAXI@Z)

1>C:\Users\vinit\documents\visual studio 2010\Projects\mynewopencv\Debug\mynewopencv.exe : 致命错误 LNK1120: 4 unresolved externals

我是新的 Visual Studio,我将非常感谢一些帮助。

4

3 回答 3

1

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.

于 2013-02-19T06:33:21.387 回答
1

您正在使用opencv而不是链接其库(.lib 文件)。

在解决方案资源管理器中右键单击您的项目,然后从上下文菜单中选择属性。

Configuration Properties > Linker > Input下,将 .lib 文件添加opencvAdditional Dependencies

于 2013-02-18T19:54:30.350 回答
1

对于 Flann Matcher,您需要链接:opencv_flannXXXd.lib

于 2014-01-24T12:29:56.370 回答