1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

LineIterator witout a Mat (#13843)

* LineIterator witout a Mat

cv::LineIterator can be used without being attached to any cv::Mat, it only needs the size and type of data. An alternative constructor has been defined for that.
In that case, a LineIterator can no more be dereferenced with the * operator, but pos() still returns valid pixel positions.
It can be useful when LineIterator is just used to compute positions of pixels on a line, without requiring to build a Mat just for that.
Use case : with a dataset that would represent a huge image, pixel positions can be pre-computed before querying the dataset API.

* Update imgproc.hpp

removed trailing spaces

* Update drawing.cpp

fixed warning
This commit is contained in:
Pierre Chatelier
2019-02-19 11:44:41 +01:00
committed by Vadim Pisarevsky
parent a6160b6994
commit 00e8c7810f
2 changed files with 23 additions and 15 deletions
+10 -2
View File
@@ -4689,7 +4689,15 @@ public:
not to depend on the ordering of pt1 and pt2 parameters
*/
LineIterator( const Mat& img, Point pt1, Point pt2,
int connectivity = 8, bool leftToRight = false );
int connectivity = 8, bool leftToRight = false ) {
init(img.size(), img.type(), (uchar*)img.ptr(), img.step1()*img.elemSize1(), pt1, pt2, connectivity, leftToRight);
}
LineIterator( const Size& size, int type, Point pt1, Point pt2,
int connectivity = 8, bool leftToRight = false ) {
init(size, type, 0, CV_ELEM_SIZE(type)*size.width, pt1, pt2, connectivity, leftToRight);
}
void init(const Size& size, int type, uchar* data, size_t dataStep, Point pt1, Point pt2, int connectivity = 8, bool leftToRight = false);
/** @brief returns pointer to the current pixel
*/
uchar* operator *();
@@ -4718,7 +4726,7 @@ public:
inline
uchar* LineIterator::operator *()
{
return ptr;
return !ptr0 ? 0 : ptr;//when no Mat is attached, ptr is just a dummy address and should not be dereferenced
}
inline