OpenCV中重载函数的实例
Instance of overloaded function in OpenCV
你好,我正试图实现一个快速特征检测器代码,在它的初始阶段,我得到以下错误
(1)没有重载函数"cv::FastFeatureDetector::detect"的实例匹配参数列表
(2)" keypointstoppoints "未定义
请帮帮我。
#include <stdio.h>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/nonfree/nonfree.hpp"
using namespace cv;
int main()
{
Mat img1 = imread("0000.jpg", 1);
Mat img2 = imread("0001.jpg", 1);
// Detect keypoints in the left and right images
FastFeatureDetector detector(50);
Vector<KeyPoint> left_keypoints,right_keypoints;
detector.detect(img1, left_keypoints);
detector.detect(img2, right_keypoints);
vector<Point2f>left_points;
KeyPointsToPoints(left_keypoints,left_points);
vector<Point2f>right_points(left_points.size());
return 0;
}
问题在这一行:
Vector<KeyPoint> left_keypoints,right_keypoints;
c++是区分大小写的,它看到Vector
是不同于vector
的东西(它应该是什么)。为什么Vector
工作超出了我的范围,我应该预料到一个错误。
cv::FastFeatureDetector::detect
只知道如何与vector
一起工作,而不是Vector
,所以尝试修复这个错误,然后再试一次。
另外,KeyPointsToPoints
在OpenCV库中不存在(除非你自己编程),请确保使用KeyPoint::convert(const vector<KeyPoint>&, vector<Point2f>&)
进行转换。
给出的代码有一些小问题。首先,你缺少using namespace std
,这是你使用矢量的方式所需要的。您还缺少矢量#include <vector>
的包含。vector<KeyPoints>
也应该有一个小写v.我也不确定keypointstoppoints是否是OpenCV的一部分。您可能必须自己实现这个函数。我不确定,我只是以前没见过。
#include <stdio.h>
#include <vector>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/nonfree/nonfree.hpp"
using namespace cv;
using namespace std;
int main()
{
Mat img1 = imread("0000.jpg", 1);
Mat img2 = imread("0001.jpg", 1);
// Detect keypoints in the left and right images
FastFeatureDetector detector(50);
vector<KeyPoint> left_keypoints,right_keypoints;
detector.detect(img1, left_keypoints);
detector.detect(img2, right_keypoints);
vector<Point2f>left_points;
for (int i = 0; i < left_keypoints.size(); ++i)
{
left_points.push_back(left_keypoints.pt);
}
vector<Point2f>right_points(left_points.size());
return 0;
}
我没有测试上面的代码。查看这里的OpenCV文档
相关文章:
- 如何在c++中为模板函数实例创建快捷方式
- 在两个类中共享相同的函数调用,并在不需要时避免空实例化
- 对象实例化调用构造函数的次数太多
- 错误 没有与参数列表匹配的重载函数"getline"实例
- 如何使用非默认构造函数实例化模板化类
- 为什么 gcc 和 clang 为函数模板的实例化生成不同的符号名称?
- 重载 -> shared_ptr 个实例中的箭头运算符<interface>,接口中没有纯虚拟析构函数
- 将可变参数函数的参数封装在类实例中
- 模板化类构造函数的模板实例化
- 在 c++ 中的模板实例化中使用带有构造函数的类作为类型参数
- std::vector 没有重载函数的实例与参数列表匹配
- C++中的单例实现在调用 getInstance 函数时不会产生相同的类实例
- C++初始化类实例时隐式调用类成员的构造函数
- 受约束的成员函数和显式模板实例化
- 对显式实例化的模板函数的未定义引用
- 将类实例函数绑定到 v8::FunctionTemplate
- lambda作为实例函数指针
- 我的类的静态实例函数不像我预期的那样工作
- 如何在C++中传递指向类实例函数的指针?
- 为什么我可以静态地调用实例函数