1、cv::Ptr
https://docs.opencv.org/3.4/d0/de7/structcv_1_1Ptr.html
A Ptr pretends to be a pointer to an object of type T. Unlike an ordinary pointer, however, the object will be automatically cleaned up once all Ptr instances pointing to it are destroyed.
2、迭代器
Mat img = Mat::eye(3,3,CV_8U);
cout<<img<<endl;
Mat_::iterator it = img.begin();
Mat_::iterator itend = img.end();//end是最后一行最后一列的再后一位
for(; it != itend; ++it)
{
*it = *it * 2 + 1;
cout<<(int)*it<<endl;
}
Mat img = Mat::eye(3,3,CV_8UC3);
cout<<img<<endl;
MatIterator_ it = img.begin();
MatIterator_ itend = img.end();//end是最后一行最后一列的再后一位
for(; it != itend; ++it)
{
(*it)[1] = (*it)[1] * 2 + 3;
//cout<<(int)(*it)<<endl;
}
cout << img<<endl;
In case of color images we have three uchar items per column. This may be considered a short vector of uchar items, that has been baptized in OpenCV with the Vec3b name. To access the n-th sub column we use simple operator[] access. It’s important to remember that OpenCV iterators go through the columns and automatically skip to the next row. Therefore in case of color images if you use a simple uchar iterator you’ll be able to access only the blue channel values.