Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You should use LineIterator class: http://docs.opencv.org/modules/core/doc/drawing_functions.html?highlight=lineiterator#LineIterator

E.g. if you want to get pixel values failing on that line:

LineIterator it(img, pt1, pt2, 8);
LineIterator it2 = it;
vector<Vec3b> buf(it.count);

for(int i = 0; i < it.count; i++, ++it)
    buf[i] = *(const Vec3b)*it;

You should use LineIterator class: http://docs.opencv.org/modules/core/doc/drawing_functions.html?highlight=lineiterator#LineIterator

E.g. if you want to get pixel values failing on that line:

LineIterator it(img, pt1, pt2, 8);
LineIterator it2 = it;
vector<Vec3b> buf(it.count);

for(int i = 0; i < it.count; i++, ++it)
    buf[i] = *(const Vec3b)*it;

it.count in this sample is pixels count for the line between pt1 and pt2 if we use 8 neighbors.