我刚接触OpenCV,尝试使用迭代器替代“for”循环,因为对于我的情况,“for”循环速度太慢了。我尝试了一些类似这样的代码:
MatIterator_<uchar> it, end;
for( it = I.begin<uchar>(), end = I.end<uchar>(); it != end; ++it)
{
//some codes here
}
我的问题是:如何将像这样的for循环转换为其他形式:
for ( int i = 0; i < 500; i ++ )
{
exampleMat.at<int>(i) = srcMat>.at<int>( i +2, i + 3 )
}
如何将其转换为迭代器模式?也就是说,如何以迭代器形式进行“i +2、i +3”操作?我只能通过“*it”获取相应的值,但无法获得它的计数编号。 非常感谢。
auto p = img.ptr<int>(row)
,但如何替换该语句中的“int”? - winterlight