首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OpenCV未定义引用(FileStorage与vector<KeyPoint>)

OpenCV未定义引用(FileStorage与vector<KeyPoint>)
EN

Stack Overflow用户
提问于 2014-01-22 23:22:17
回答 2查看 3.4K关注 0票数 0

最近我一直在使用一些OpenCV,但是我遇到了一个有趣的问题。我有一个简单的类来存储数据,并将数据读写到文件中。

以下是写函数:

代码语言:javascript
复制
cv::Mat descriptors;
vector<cv::KeyPoint> keypoints;

void EventType::write(cv::FileStorage outfile) {
    outfile << "descriptorId" << descriptors;
    outfile << "keypointId" << keypoints;
}

这一问题是在联系起来的同时提出的:

代码语言:javascript
复制
EventType.cpp.o: In function cv::FileStorage& cv::operator<< <std::vector<cv::KeyPoint,
    std::allocator<cv::KeyPoint> > >(cv::FileStorage&, std::vector<cv::KeyPoint,
    std::allocator<cv::KeyPoint> > const&)':
EventType.cpp:(.text+0xc99): undefined reference to `cv::write(cv::FileStorage&,
    std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&,
    std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> > const&)'

然而,在将其联系起来时,它也提出了以下备选办法:

代码语言:javascript
复制
/opencv2/core/operations.hpp:2707: note: candidates are: void cv::write(cv::FileStorage&, const std::string&, int)
/opencv2/core/operations.hpp:2708: note:                 void cv::write(cv::FileStorage&, const std::string&, float)
/opencv2/core/operations.hpp:2709: note:                 void cv::write(cv::FileStorage&, const std::string&, double)
/opencv2/core/operations.hpp:2710: note:                 void cv::write(cv::FileStorage&, const std::string&, const std::string&)
/opencv2/core/operations.hpp:2787: note:                 void cv::write(cv::FileStorage&, const cv::Range&)
/opencv2/core/operations.hpp:2856: note:                 void cv::write(cv::FileStorage&, const std::string&, const cv::Range&)
/opencv2/core/operations.hpp:2902: note:                 void cv::write(cv::FileStorage&, const std::string&, const cv::Mat&)
/opencv2/core/operations.hpp:2903: note:                 void cv::write(cv::FileStorage&, const std::string&, const cv::SparseMat&)
/opencv2/features2d/features2d.hpp:112: note:                 void cv::write(cv::FileStorage&, const std::string&, const std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> >&)

在我看来,/opencv2/features2d/features2d.hpp中的原型是完美匹配的。有什么建议吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-01-24 20:28:45

问题在我的FindOpenCV.cmake文件中。没有链接features2d库。

票数 -1
EN

Stack Overflow用户

发布于 2014-01-23 10:15:06

如果链接器显示“未定义的引用”,编译步骤已经完成,这意味着编译器接受您的函数为有效。

尝试链接所有opencv库,看看这是否会改变结果。还要检查所使用的标头是否与要链接到的库具有相同的版本。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21296203

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档