Line Tracking Example

HUSKYLENS 2 line tracking measures line length, angle, X/Y components and branches. It’s like a smart ruler that follows drawn paths and reports geometry data for each detected line or branch.

1. Line Tracking Code Example

Before You Start:

1.1 Line Tracking and Output Data

Under the Line Tracking function, HUSKYLENS 2 can mark the trajectory of the line in the frame and obtain the current line length, angle, and X/Y components. When branches appear on the line, it can also obtain the number of branches at the intersection and the corresponding data of each branch in a counterclockwise order.Please refer to Line Tracking.

The example program is shown below.

Interface Diagram

The displayed line length and angle are the results calculated through geometric computation after the line is mapped onto the HUSKYLENS 2 screen.

Interface Diagram

Next, the calculation methods for the X/Y components, angle, and length read in Line Tracking are explained:

As shown in the figure below, the black line recognized in Line Tracking is used as an example.

Angle:
The angle between the straight line formed by the line start point and end point and the X-axis corresponds to the “Angle” value read in Line Tracking. The angle range is -90 to 90, where clockwise is a positive value and counterclockwise is a negative value.

Length:
The straight-line distance from the line start point to the end point corresponds to the “Length” value read in Line Tracking.

X Component:
The straight-line distance from the line start point to the center of the HUSKYLENS 2 screen (coordinates [320, 480]) is the X component value. If the direction from the start point to the screen center is to the right, the X component is positive; if to the left, the X component is negative.

Y Component:
The vertical distance from the line end point to the X-axis is the Y component value.

Interface Diagram

1.2 Line Tracking Blocks Description

block Description
Used to obtain one set of Line Tracking data under the Line Tracking function of HUSKYLENS 2.
Determines whether lines exist in the current frame.
Obtains data for the line closest to the crosshair, including X component,Y component,angle,length.
Gets the total number of detected lines on the screen.
When multiple lines appear, obtaining datas of a specified branch.

Was this article helpful?

TOP