@Namespace(value="cv") @NoOffset @Properties(inherit=opencv_imgproc.class) public class LineIterator extends Pointer
The class LineIterator is used to get each pixel of a raster line connecting two specified points. It can be treated as a versatile implementation of the Bresenham algorithm where you can stop at each pixel and do some extra processing, for example, grab pixel values along the line or draw a line with an effect (for example, with XOR operation).
The number of pixels along the line is stored in LineIterator::count. The method LineIterator::pos returns the current position in the image:
{.cpp}
// grabs pixels along the line (pt1, pt2)
// from 8-bit 3-channel image to the buffer
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;
// alternative way of iterating through the line
for(int i = 0; i < it2.count; i++, ++it2)
{
Vec3b val = img.at<Vec3b>(it2.pos());
CV_Assert(buf[i] == val);
}
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter
Constructor and Description |
---|
LineIterator(Mat img,
Point pt1,
Point pt2) |
LineIterator(Mat img,
Point pt1,
Point pt2,
int connectivity,
boolean leftToRight)
\brief Initializes iterator object for the given line and image.
|
LineIterator(Pointer p)
Pointer cast constructor.
|
LineIterator(Point pt1,
Point pt2) |
LineIterator(Point pt1,
Point pt2,
int connectivity,
boolean leftToRight) |
LineIterator(Rect boundingAreaRect,
Point pt1,
Point pt2) |
LineIterator(Rect boundingAreaRect,
Point pt1,
Point pt2,
int connectivity,
boolean leftToRight) |
LineIterator(Size boundingAreaSize,
Point pt1,
Point pt2) |
LineIterator(Size boundingAreaSize,
Point pt1,
Point pt2,
int connectivity,
boolean leftToRight) |
Modifier and Type | Method and Description |
---|---|
int |
count() |
LineIterator |
count(int setter) |
int |
elemSize() |
LineIterator |
elemSize(int setter) |
int |
err() |
LineIterator |
err(int setter) |
LineIterator |
increment()
\brief Moves iterator to the next pixel on the line.
|
LineIterator |
increment(int arg0)
\brief Moves iterator to the next pixel on the line.
|
void |
init(Mat img,
Rect boundingAreaRect,
Point pt1,
Point pt2,
int connectivity,
boolean leftToRight) |
int |
minusDelta() |
LineIterator |
minusDelta(int setter) |
int |
minusShift() |
LineIterator |
minusShift(int setter) |
int |
minusStep() |
LineIterator |
minusStep(int setter) |
BytePointer |
multiply()
\brief Returns pointer to the current pixel.
|
Point |
p() |
LineIterator |
p(Point setter) |
int |
plusDelta() |
LineIterator |
plusDelta(int setter) |
int |
plusShift() |
LineIterator |
plusShift(int setter) |
int |
plusStep() |
LineIterator |
plusStep(int setter) |
Point |
pos()
\brief Returns coordinates of the current pixel.
|
boolean |
ptmode() |
LineIterator |
ptmode(boolean setter) |
BytePointer |
ptr() |
LineIterator |
ptr(BytePointer setter) |
BytePointer |
ptr0() |
LineIterator |
ptr0(BytePointer setter) |
int |
step() |
LineIterator |
step(int setter) |
address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, getDirectBufferAddress, getPointer, getPointer, getPointer, getPointer, hashCode, interruptDeallocatorThread, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetAddress, offsetof, offsetof, parseBytes, physicalBytes, physicalBytesInaccurate, position, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, sizeof, toString, totalBytes, totalCount, totalPhysicalBytes, withDeallocator, zero
public LineIterator(Pointer p)
Pointer(Pointer)
.public LineIterator(@Const @ByRef Mat img, @ByVal Point pt1, @ByVal Point pt2, int connectivity, @Cast(value="bool") boolean leftToRight)
The returned iterator can be used to traverse all pixels on a line that connects the given two points. The line will be clipped on the image boundaries.
img
- Underlying image.pt1
- First endpoint of the line.pt2
- The other endpoint of the line.connectivity
- Pixel connectivity of the iterator. Valid values are 4 (iterator can move
up, down, left and right) and 8 (iterator can also move diagonally).leftToRight
- If true, the line is traversed from the leftmost endpoint to the rightmost
endpoint. Otherwise, the line is traversed from \p pt1 to \p pt2.public LineIterator(@ByVal Point pt1, @ByVal Point pt2, int connectivity, @Cast(value="bool") boolean leftToRight)
public LineIterator(@ByVal Size boundingAreaSize, @ByVal Point pt1, @ByVal Point pt2, int connectivity, @Cast(value="bool") boolean leftToRight)
public LineIterator(@ByVal Rect boundingAreaRect, @ByVal Point pt1, @ByVal Point pt2, int connectivity, @Cast(value="bool") boolean leftToRight)
public void init(@Const Mat img, @ByVal Rect boundingAreaRect, @ByVal Point pt1, @ByVal Point pt2, int connectivity, @Cast(value="bool") boolean leftToRight)
@Cast(value="uchar*") @Name(value="operator *") public BytePointer multiply()
@ByRef @Name(value="operator ++") public LineIterator increment()
This is the prefix version (++it).
@ByVal @Name(value="operator ++") public LineIterator increment(int arg0)
This is the postfix version (it++).
@Cast(value="uchar*") public BytePointer ptr()
public LineIterator ptr(BytePointer setter)
@Cast(value="const uchar*") public BytePointer ptr0()
public LineIterator ptr0(BytePointer setter)
public int step()
public LineIterator step(int setter)
public int elemSize()
public LineIterator elemSize(int setter)
public int err()
public LineIterator err(int setter)
public int count()
public LineIterator count(int setter)
public int minusDelta()
public LineIterator minusDelta(int setter)
public int plusDelta()
public LineIterator plusDelta(int setter)
public int minusStep()
public LineIterator minusStep(int setter)
public int plusStep()
public LineIterator plusStep(int setter)
public int minusShift()
public LineIterator minusShift(int setter)
public int plusShift()
public LineIterator plusShift(int setter)
public LineIterator p(Point setter)
public LineIterator ptmode(boolean setter)
Copyright © 2024. All rights reserved.