In object-oriented programming, looping over a data collection is usually done using iterators. Iterators are specialized classes that are built to go over each element of a collection, hiding how the iteration over each element is specifically done for a given collection. This application of the information-hiding principle makes scanning a collection easier and safer. In addition, it makes it similar in form no matter what type of collection is used. The
Standard Template Library (STL) has an iterator class associated with each of its collection classes. OpenCV then offers a
cv::Mat iterator class that is compatible with the standard iterators found in the C++ STL.
In this recipe, we again use the ...