OpenCV 向量<point> - 没有用于初始化'cv::Point_<int>'的匹配承包商
OpenCV vector<point> - No matching contractor for initialization of 'cv::Point_<int>'
我试图将本地构造的(内部方法)cv::Point3i
放置到对象变量(声明为std::vector<cv::Point>
)上。这样做,我得到编译错误(不是运行时):
memory - No matching constructor for initialization of 'cv::Point_<int>'
用Point2i做同样的事情(省略我需要的一个值),编译器不会抛出错误。
下面是.cpp文件中的代码片段:
void ObjectDetector::centroids2Dto3D() {
const int* map_ptr = (int*)mapHeight.data;
unsigned long steps[2];
steps[0] = mapHeight.step1(0);
steps[1] = mapHeight.step1(1);
for (std::vector<cv::Point>::iterator it = centroidsXZ.begin(); it != centroidsXZ.end(); it++) {
const int x = (*it).x;
const int z = (*it).y;
int y = map_ptr[steps[0] * x + steps[1] * z];
// MARK: The following line causes the error. Without it, the program compiles fine
centroids.emplace_back(cv::Point3i(x,y,z));
}
}
由于我不擅长调试c++,我倾向于把错误归咎于我的代码,但我在这里找不到问题。
有人能给我指出一个解决方案或一条通往它的道路吗?
谢谢!
由于您插入到类型为cv::Point3i
的矢量对象,那么centroids
的类型应该是:std::vector<cv::Point3i>
。
还有,你把emplace_back
叫错了。它的参数应该是转发给Point3i
的构造函数的参数,即:centroids.emplace_back(x,y,z);
使用emplace_back
将避免使用push_back
时所需的额外复制或移动操作。
相关文章:
- 请解释这句话(cout<<1+int((a<b)^((b-a)&1) )<<endl
- 呼叫运营商<<临时
- 如何防止clang格式在流运算符调用之间添加换行符<<
- <<操作员在下面的行中工作
- EASTL矢量<向量<int>>连续的
- C - 创建矢量&lt; vector&lt; double&gt;&gt;矩阵具有分配而不是inizializ
- 为什么将此对向量&lt; map&lt; int,int&gt;&gt;中的地图进行更新.失败
- C :对矢量进行排序&lt; struct&gt;(结构有2个整数)基于结构的整数之一
- 明确的专业化“ CheckIntmap&lt;&gt;”实例化
- 什么是模板&lt;&gt;inline bla bla
- 编辑C Qlist&lt; object*&gt; gt;QML代码和一些QML警告中的模型
- eigen :: llt&lt;eigen :: matrixxd&gt;具有不完整的类型
- 错误,包括&lt; ctype&gt;在原子上使用C 11
- std::vector<;uint8_t>;当C++11/14启用时,手动复制而不是调用memcpy
- 如何加入向量&lt; int&gt;到C 中的单个INT
- 是std :: set&lt; std :: future&gt;不可能存在
- 是numeric_limits&lt; int&gt; :: is_modulo从逻辑上矛盾
- opencv 2.4.7在iOS错误背景_segm.hpp #include&lt; list&gt;未找到
- 在修改列表后,std :: list&lt; t&gt; :: end()的值是否会更改
- ///<评论></评论>在Visual Studio中