我正在研究Linux Ubuntu中opencv中的以下代码。 x_captured和y_captured是“int”型向量。两个矢量的大小为18。std :: out_of_range错误
for (int i=0;i<=x_captured.size();i++)
{
for (int j=0;j<=y_captured.size();j++)
{
if (i!=j)
{
if (((x_captured.at(j)-x_captured.at(i))<=2) &&
((y_captured.at(j)-y_captured.at(i))<=2))
{
consecutive=consecutive+1;
}
}
}
}
但是当i = 0和j = 18后,它引发以下错误:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check
请注意你的消息来源:[“完整的C++教程”](http://www.cplusplus.com/doc/tutorial/arrays/)(点击查看更多!)JuanSoulié(download [as PDF] (http://www.cplusplus.com/files/tutorial.pdf)) – sehe
@sehe哈哈,这是第一个想到的地方:) – FailedDev