Class LineIterator
- Namespace
- OpenCvSharp
- Assembly
- OpenCvSharp.dll
Iterates over the pixels that lie on a line segment of an image, mirroring
cv::LineIterator. The instance describes the scan (its length is available
through Count immediately after construction); enumerating it
walks the pixels from pt1 to pt2.
public sealed class LineIterator : CvObject, IDisposable, IEnumerable<LineIterator.Pixel>, IEnumerable
- Inheritance
-
LineIterator
- Implements
- Inherited Members
Remarks
Enumeration is independent of the instance state, so a single LineIterator can be iterated more than once. Prefer AsValues<T>() to read pixel values safely: it dereferences each pixel while the source image is guaranteed to be alive. The raw Ptr exposed by GetEnumerator() points directly into the image buffer and is only valid while that image has not been disposed.
Constructors
LineIterator(Mat, Point, Point, PixelConnectivity, bool)
Constructor
public LineIterator(Mat img, Point pt1, Point pt2, PixelConnectivity connectivity = PixelConnectivity.Connectivity8, bool leftToRight = false)
Parameters
imgMatpt1Pointpt2PointconnectivityPixelConnectivityleftToRightbool
Properties
Count
Number of pixels along the line.
public int Count { get; }
Property Value
ElemSize
Size of one pixel in bytes.
public int ElemSize { get; }
Property Value
Err
Bresenham error term of the current position.
public int Err { get; }
Property Value
MinusDelta
public int MinusDelta { get; }
Property Value
MinusStep
public int MinusStep { get; }
Property Value
PlusDelta
public int PlusDelta { get; }
Property Value
PlusStep
public int PlusStep { get; }
Property Value
Ptr
Pointer to the current pixel (into the image buffer).
public nint Ptr { get; }
Property Value
Ptr0
Pointer to the first pixel of the image.
public nint Ptr0 { get; }
Property Value
Step
Number of bytes between two consecutive rows of the image.
public int Step { get; }
Property Value
Methods
AsValues<T>()
Enumerates the pixel values along the line as T.
Each value is read while the source image is kept alive, so the result is
safe to use after enumeration (unlike the raw Ptr).
public IEnumerable<T> AsValues<T>() where T : struct
Returns
- IEnumerable<T>
Type Parameters
TPixel type (e.g. Vec3b).
GetEnumerator()
Enumerates the pixels along the line. Each LineIterator.Pixel carries its position and a raw pointer into the image buffer; that pointer is only valid while the source image is alive. Use AsValues<T>() for safe access.
public IEnumerator<LineIterator.Pixel> GetEnumerator()