Class DrawLine
DrawLine provides flexible line drawing capabilities for creating connections, boundaries, and
visual indicators on screenshots and visualizations. Unlike DrawArrow
, these lines have
no directional indicators, making them suitable for showing relationships, boundaries, or general
connections.
Visual Output Structure:
- Straight line between two points
- Customizable thickness (1-10+ pixels typical)
- Various line types (solid, anti-aliased)
- No directional indicators or endpoints
Configuration Parameters:
- Thickness: Customizable line width in pixels
- Line type: 8 (anti-aliased), 4 (4-connected), 16 (anti-aliased)
- Shift: Fractional bits for sub-pixel precision (typically 0)
- Color: Fully customizable BGR color values
Use Cases:
- Drawing borders around regions of interest
- Connecting related UI elements visually
- Creating grid lines or visual guides
- Drawing histogram bars (as in
DrawHistogram
) - Showing non-directional relationships between points
- Creating custom shapes by combining multiple lines
Relationships:
- Complements
DrawArrow
for non-directional connections - Used by
DrawHistogram
to create vertical bars - Often combined with
DrawPoint
to connect marked locations - Works with both
Location
andPoint
for coordinate flexibility
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
draw
(org.bytedeco.opencv.opencv_core.Mat scene, Location start, Location end, org.bytedeco.opencv.opencv_core.Scalar color, int thickness, int lineType, int shift) Draws a line between two Location objects.void
draw
(org.bytedeco.opencv.opencv_core.Mat scene, org.bytedeco.opencv.opencv_core.Point start, org.bytedeco.opencv.opencv_core.Point end, org.bytedeco.opencv.opencv_core.Scalar color, int thickness, int lineType, int shift) Draws a line between two Point objects.
-
Constructor Details
-
DrawLine
public DrawLine()
-
-
Method Details
-
draw
public void draw(org.bytedeco.opencv.opencv_core.Mat scene, Location start, Location end, org.bytedeco.opencv.opencv_core.Scalar color, int thickness, int lineType, int shift) Draws a line between two Location objects.Creates a straight line from start to end using Location objects, which automatically handle coordinate calculations. This method is convenient when working with Brobot's Location-based coordinate system.
Line Type Options:
- 4: 4-connected line (faster, less smooth)
- 8: 8-connected line (default, good quality)
- 16: Anti-aliased line (LINE_AA, smoothest)
- Parameters:
scene
- the background Mat to draw on, typically a screenshotstart
- the starting location of the lineend
- the ending location of the linecolor
- the line color in BGR format (e.g., new Scalar(0,255,0) for green)thickness
- the line thickness in pixels (1 for thin, 5+ for bold)lineType
- the algorithm for line drawing (4, 8, or 16/LINE_AA)shift
- number of fractional bits in coordinates (0 for integer precision)
-
draw
public void draw(org.bytedeco.opencv.opencv_core.Mat scene, org.bytedeco.opencv.opencv_core.Point start, org.bytedeco.opencv.opencv_core.Point end, org.bytedeco.opencv.opencv_core.Scalar color, int thickness, int lineType, int shift) Draws a line between two Point objects.Direct OpenCV Point-based line drawing for when you have exact pixel coordinates. This overload bypasses Location calculations for maximum performance and precision.
Common Usage Patterns:
- Thickness 1-2: Thin lines for subtle connections
- Thickness 3-5: Standard lines for clear visibility
- Thickness 6+: Bold lines for emphasis
- LineType 8: Standard quality for most uses
- LineType 16: When smooth anti-aliasing is needed
- Parameters:
scene
- the background Mat to draw onstart
- the exact starting point coordinatesend
- the exact ending point coordinatescolor
- the line color in BGR formatthickness
- the line thickness in pixelslineType
- the line drawing algorithmshift
- fractional bits (typically 0)
-