In this section, we present the methods developed for a human operator to indicate to the robot, using finger pointing, the weld seams to be welded. The flow chart of the approach is shown in
Figure 1.
Section 2.1 outlines the process of fingertip tracking to localise the weld seam, and different image processing techniques to detect the seam (Contributions 1 and 2). In
Section 2.2, we present a search algorithm that computes a continuous weld seam path for robot implementation and backtracks to avoid getting stuck in local spurs or offshoots of the seam edge (Contribution 3). In
Section 2.4, we illustrate the developed workflow that enables multiple seam line detections for composite welding (Contribution 4). In
Section 2.5, we outline a detailed approach for weld path implementation on the robot while considering different constraints.
2.1. Fingertip Tracking and Seam Detection
In previous work [
8], we developed an end-to-end deep learning method that can detect fingertips. In this paper, we first track the fingertip in each video frame to obtain the tracking coordinates. These coordinates are used to isolate a region of interest for detecting the weld seam. This section is performed in two major steps, as shown in
Figure 1: fingertip tracking and seam detection. Fingertip tracking uses a tracking-by-detection approach, whereas the seam detection process involves stereo image rectification, image distortion removal, region-of-interest isolation, edge detection, image patching, morphological operations, and removal of non-seam edges. All these methods were developed or improved in this paper.
2.1.1. Fingertip Tracking
Fingertip tracking is performed by using a tracking-by-detection approach [
7]. The tracking-by-detection approach is chosen because no occlusion occurs within the camera’s field of view during the demonstration, and the detection time from the trained deep learning network is approximately 70 ms. A live tracking process is performed, in which the demonstrator views rendered live footage of the hand poses in real time on a screen. The index finger is tracked to identify the region of interest (ROI) for seam line locations. The tracking coordinates form the image plane coordinates as
where
is a set of image plane coordinates
for
n hand tracking points.
A stereo image of the weldment is captured before the hand-tracking process begins. The seam detection process uses the hand-tracking coordinates in Equation (
1) to isolate the ROI for potential seam detection. Once the seam region is isolated, the following image-processing operations are applied to detect the seam.
2.1.2. Rectification and Distortion Removal
The captured image
may contain lens distortion and must be undistorted [
43,
44] and rectified [
45] to generate a rectified image
. Similarly, the hand tracking image plane points from Equation (
1) must also be rectified to obtain
such that
.
2.1.3. Region of Interest
Finger tracking defines the region-of-interest coordinates in
and is important because it isolates the seam line in the image. The first step in identifying the region of interest is to obtain a set of box coordinates
. Due to the discrete nature of the image, we select a scaling factor
f in pixels and form a square box of size
corresponding to each coordinate in
such that
To select the patch size, we first consider the hand box ratio
from [
8], which indicates the ratio of hand-to-image size. The hand box ratio ranges from
, with an average value equal to
[
8], and is given as
where
and
are the width and height of the hand bounding box and image, respectively. Assuming that the hand bounding box is a square,
. Since we are interested in the area around the fingertip, we consider a tenth of the bounding box length as
. Substituting
and re-arranging the terms in Equation (
3), we get
Therefore, a scaling factor
is used to develop image patches to isolate the region of interest, where the symbol
is used to round down the value.
The box coordinates in
for each tracking point are used to crop a patch of size
. First, the rectified image
is converted to a grayscale image
. A set of image patches
P is then obtained by cropping the grey image
with the box coordinates from Equation (
2). These image patches are represented as
where
is a set of image patches
, and
from Equation (
2) are the top-left coordinates of the image patch in the image
. The top-left coordinates of the image patch are useful for patching the image.
2.1.4. Edge Detection and Image Patching
Canny edge detection [
32] is performed on each of the image patches in
in Equation (
5), similarly to [
15,
17]. The first step in patching these edge-detected image patches is to create an all-black coloured image
such that
where
is the
i-th row and
j-th column element of the matrix
, corresponding to
y and
x axes of the image coordinates, respectively. The patching of the image is done by using Algorithm 1. Once image patching is performed, the binary image
will contain image patches that correspond to seam edges.
| Algorithm 1 Image patching algorithm takes the edge-detected image patches of size s in from Equation (5) and a black coloured image from Equation (6) and sequentially patches the image to construct a continuous edge line for the seam detection |
-
Require:
, the set of edge-detected image patches along with their top-left coordinates -
Require:
, the black-coloured single-channel image matrix initialised with all zero elements -
Ensure:
reconstructed with contiguous edge segments - 1:
for
do - 2:
▹ Extract top-left row origin - 3:
▹ Extract top-left column origin - 4:
for y to s do - 5:
for x to s do - 6:
- 7:
end for - 8:
end for - 9:
end for - 10:
return
|
2.1.5. Morphological Operations
After edge detection and image patching, morphological operations are performed to ensure that the seam is connected. The first morphological operation performed on the image is dilation [
46]. The purpose of the dilation operation is to expand the white pixels, thereby filling any gaps in the seam line. The dilation operation requires a kernel
to perform the convolution operation over the image. Each element of the matrix
is 1. The dilation function provides a new image
.
After the dilation operation, the image is filtered using a cross-correlation filtering [
46] procedure with kernel
. The thinning operation [
47] is performed after dilation and filtering to obtain a new binary image
of a single pixel line for the detected edges.
2.1.6. Removing Non-Seam Edges
The edges in the image may also contain some superfluous edges from scratches or other defects on the weldment. This could also be due to the line patterns of the welding table or the boundary edges of the weldment. Since our developed continuous weld seam search path is based on the seam edge, the other edge clusters must be removed. Therefore, an isolated cluster removal process must be performed to remove the smaller edges in the image that are not part of the weld seam.
For the binary edge-detected image
, there will be a set of pixels that defines the edges where the value of the pixel is 1. These foreground pixels form the set
of disjoint clusters
such that
. These clusters are defined by the adjacency relations among pixel values, such as the 8-connectivity [
46]. Each cluster
will contain the pixel coordinate that will not be part of any other cluster group such that
for all
.
The seam cluster selection process identifies the largest cluster. The largest size is defined by considering the area of the cluster
. The area of the cluster is computed by counting the number of pixels in each cluster. After calculating the area of each cluster, the cluster with the largest area is selected. The index
k of the largest cluster is determined as
The largest cluster
from the index
k in Equation (
7) is the set of seam coordinates
. The seam coordinates
are the set of
r image coordinates used to find the continuous weld path for robot path following. For the continuous search, a search map can be created by first creating a black image
where each element is 0, similar to Equation (
6). The seam edge pixels for each pixel coordinate
can be obtained by setting these pixel values in image
.
2.2. Weld Seam Search Path
The continuous weld seam path is essential for the robot to perform the welding operation. A search algorithm is developed to find the continuous weld path. The first step in searching for the weld seam path is to determine the start and end coordinates of the seam. Once the start and end points of the seam edge are obtained, a path data structure is created to identify the continuous path. Finally, the data structure can be accessed to obtain a set of continuous coordinates.
2.2.1. Seam End Points
The finger tracking coordinates
can be used to determine the true start and end pixel coordinates of the seam. The approach assumes that the demonstrator starts and stops the demonstration slightly outside the true start and end locations of the weld seam, respectively. It is also assumed that the demonstrator does not move the finger back to the start location as an end position. The tracking coordinates do not need to be exactly on the weld seam, thus relaxing the constraints and permitting potential human errors due to tremor or human eyesight issues that can impact tracking. The start and end tracking coordinates can be obtained by using the first and last coordinates from
as
where
and
are the start and the end rectified coordinates of fingertip tracking in the image coordinate plane, respectively.
The next step is to find the true start and end coordinates of the seam edge. The true start and end coordinates of the seam edges are the closest points to
and
. Therefore, calculating the Euclidean distance between each of the seam coordinates
and Equation (
8) for
can be expressed as
and similarly for
as
where
is a set of Euclidean distances between the tracking start and the coordinates in
, and
is a set of Euclidean distances between the tracking end and the coordinates in
. After calculating the Euclidean distances, the index of the shortest distance can be calculated as
where
and
are the indices of the shortest distance between the true start and end coordinates of the seam. Finally, the true start
and end
coordinates of the seam can be determined as
2.2.2. Search for Continuous Seam Path
After obtaining the start and the end coordinates of the seam edge from Equation (
12), a search is performed using
as the start point,
as the goal point, and the binary seam edge image
as the map where the white pixels with a value of 1 form the path.
Algorithm 2 is used to find the continuous path of the weld seam edge. This algorithm uses the start and end positions from Equation (
12) and the binary image
. The algorithm uses a data structure called
Node that contains two attributes: position, which indicates the pixel’s coordinate, and parent, which points to the previous
Node in the path sequence.
In lines 1 and 2 of Algorithm 2, the Node() and Node() represents the start and end coordinates given to the position attribute of Node. Line 3 records all the nodes visited by the search algorithm, while line 4 only maintains the record of the continuous final path, which is the output of the algorithm. Line 8 uses a kernel N centred at the current pixel coordinate, and line 9 extracts the pixels with non-zero values to create a kernel_path. The kernel_path is an array of non-zero pixel coordinates within the confines of the kernel N created in line 8.
The function
sort_points_by_distance() sorts the coordinates in the
kernel_path in descending order of the Euclidean distance from the goal
, similar to Equation (
9). Line 11 checks if
local_path is a subset of
node_visited, and if this condition is true, then the last node is removed from
path. Lines 11 to 14 are an important and novel part of the search algorithm, as they backtrack the path to avoid getting stuck in the local spurs or edges.
From line 16 onwards, the coordinate positions
in the
local_path are assigned as the next node and the current node is assigned as the
next_node’s parent. The algorithm returns an array
path that consists of nodes from the
Node data structure. The first node (the start point) in
path will have no parent (the root node). Therefore, the next step will be to process the
path array to obtain a set of continuous weld seam path coordinates.
| Algorithm 2 Seam search path algorithm takes the start and end coordinate positions along with binary seam edge image as a map to find the seam path |
-
Require:
, the start coordinate position of the seam edge -
Require:
, the end coordinate position of the seam edge -
Require:
, the binary seam edge image as the search map - 1:
start_node ← Node() - 2:
goal_node ← Node() - 3:
node_visited ← {start_node.position} - 4:
path ← {start_node} - 5:
current_node ← start_node - 6:
while current_node.position ≠ do - 7:
x, y ← current_node.position - 8:
N ← - 9:
kernel_path ← - 10:
local_path ← sort_points_by_distance(kernel_path, ) - 11:
if local_path ⊂ node_visited = true then - 12:
remove_last(path) - 13:
current_node ← get_last(path) - 14:
continue - 15:
end if - 16:
for local_path do - 17:
if node_visited = true then - 18:
next_node ← Node() - 19:
next_node.parent ← current_node - 20:
node_visited.add() - 21:
path.add(next_node) - 22:
end if - 23:
end for - 24:
current_node ← next_node - 25:
end while - 26:
return path
|
2.2.3. Path Coordinates Extraction
The path obtained using Algorithm 2 contains an array of data structures. This can be further processed by using another algorithm that traces the Node ancestry using its parent attribute.
Algorithm 3 provides a way to extract the coordinates of the
path data structure. The process first uses the end coordinate value
from Equation (
12) and traces the parent
Node until it reaches the start
Node with position
.
Line 1 in Algorithm 3 uses the
path and the goal
to find the
Node of the goal position. Then, the algorithm runs in a continuous loop from the goal node to keep tracing its parent node, and while doing so extracts the coordinate from the
position attribute and adds it to the continuous seam path
such that
where
is the coordinates of the seam, and
is the continuous set of
seam coordinates.
The continuous seam path coordinates from Equation (
13) are useful for tracing the seam path from the start and finish points of the curve, as demonstrated by the human hand tracking. These path coordinates are still in the image plane of the rectified image. These points will be mapped in the robot coordinate space for the robot implementation. Therefore, with Equation (
13), the seam path detection process is complete.
| Algorithm 3 Path ancestry tracing process that takes the array of Node data structure along with the goal position to return an array of path coordinates from the start to the end of the seam edge |
-
Require:
, the end coordinate position of the seam edge -
Require:
path, the array of Node indicating each coordinate position and its parent Node. - 1:
goal_node ← find_goal_in_path(, path) - 2:
current_node ← goal_node - 3:
- 4:
while true do - 5:
← current_node.position - 6:
.add() - 7:
current_node ← current_node.parent - 8:
if current_node = NULL then - 9:
break - 10:
end if - 11:
end while - 12:
.reverse() - 13:
return
|
2.3. Seam Detection Evaluation
Robot path following for the welding process requires a specified number of points to complete the operation. The minimum points required to perform welding on
line segments is
. A single-line weld seam would require two points, whereas a saw tooth with three line segments would require four points. A curve can be broken into smaller
line segments and will also require
points. Considering the minimum number of
points required to perform the welding operation, a set of user-defined ground truth checkpoints
for
points is required such that
The set of checkpoints mentioned in Equation (
14) forms the ground truth for evaluation. The seam path developed in Equation (
13) must pass through these checkpoints. Since there is a permissible tolerance of a few millimetres in the welding operation [
16], a square bounding box is developed for each checkpoint of size
, where
p is the tolerance value in pixels. Given the user-defined ground-truth checkpoint
and a bounding box of size
b, an algorithm is developed to determine the number of checkpoints visited by the seam path.
Algorithm 4 uses the continuous seam path , the user-defined ground-truth checkpoints , and the tolerance in pixel size p. In line 1, is a subset of all the checkpoints , where the continuous seam path passes through its bounding box. is initially set to the empty set and is populated as the seam path passes through the corresponding checkpoints.
Line 2 in Algorithm 4 uses a function
checkpoint_bounding_box() that takes
and
p as input. This function creates a set of bounding box
for each
coordinate value in
as
Line 5 in Algorithm 4 uses a function
checkpoint_pass_check() that takes
and
and returns a boolean
true if the coordinates
are within the area defined by bounding box
by performing logical operation
where ∧ is the symbol for the logical
AND operation.
In line 6 of Algorithm 4, if the seam path passes through one of the checkpoints, then the checkpoint is added to the set of visited checkpoints. In line 7, the index of the coordinate is assigned to the index variable . In lines 8 and 9, the values associated with the index in and for bounding boxes and ground truth checkpoints, respectively, are removed. Finally, the algorithm returns the set of checkpoints passed by the continuous seam path .
The set of passed checkpoints
obtained as the output of Algorithm 4 and the total number of user-defined ground truth checkpoints
can be used to calculate a passing accuracy as
where
is the passing accuracy,
is the number of passed checkpoints, and
is the total number ground truth checkpoint. The suffix
p indicates the tolerance in pixels such that
,
, and
represent the passing accuracy of checkpoints for 0,
, and
pixels, respectively. Using the passing accuracy
, the detection accuracy can be evaluated. Furthermore, the tolerance value
p can be adjusted according to the strictness of the evaluation criteria.
| Algorithm 4 Checkpoint seam detection evaluation algorithm that takes a set of continuous weld seam path coordinates , a set of user-defined ground truth in the form of checkpoints , and the tolerance in pixel size p |
-
Require:
, a set of continuous weld seam path coordinates -
Require:
, a set of user-defined ground truth checkpoint coordinates of size -
Require:
p, tolerance in pixel size to create a bounding box over checkpoints - 1:
- 2:
checkpoint_bounding_box(, p) - 3:
for
do - 4:
for do - 5:
if checkpoint_pass_check(, b) = true then - 6:
.add() - 7:
.index() - 8:
.remove() - 9:
.remove() - 10:
break - 11:
end if - 12:
end for - 13:
end for - 14:
return
|
2.4. Composite Weld Seam Detection
The hand-tracking-to-weld-seam detection process can be incorporated to detect composite weld seams. The composite weld seams are defined as weldments with multiple weld lines or curves. The process for composite weld seam detection is similar to that for single-weld seam detection, as shown so far in this section. Therefore, the process remains the same for multiple-line detection, with the addition of multiple hand tracking.
The hand tracking will be performed on multiple seam lines and stored as
where
is a set of the set of hand tracking points
for
n weld seams. Each one of the
represents the tracking coordinates, as shown in Equation (
1). The seam path coordinates can be obtained for the composite weld seams by following the methods developed in this research for individual seam detection. These seams can be merged to obtain a composite weld seam.
2.5. Robot Seam Path Implementation
The continuous path coordinates for the seam
obtained from Equation (
13) are in the image coordinate space. These coordinates must be transformed into the robot’s coordinate frame. The weld path implementation requires a fixed robot coordinate frame
and another coordinate frame at the tip of the end-effector (welding torch)
, as shown in
Figure 2. To avoid “welding from underneath”, the welding table was set as the constraint for the “floor”. This “floor constraint” prevents the robot from approaching the weld path from underneath the weld table.
The continuous weld seam path
consists of a set of
seam pixel coordinates in the image plane. The continous seam path coordinates
in the image plane are transformed to the robot space coordinates
, consisting of
robot space coordinates by performing stereo camera and hand-to-eye calibration presented in previous work [
24] to obtain camera re-projection matrix
Q and camera to robot transformation matrix
.
The continuous weld seam path coordinates
along with the corresponding disparity values, obtained from the stereo disparity map
for depth extraction, can be used to form a vector
. The camera coordinates are obtained as
where
, and
is the camera frame coordinate of the respective continuous path coordinate in
. The point
can be projected in the robot’s coordinate frame as
where
is the equivalent continuous path coordinate in the robot’s coordinate frame.
The continuous path coordinates of the torch can be obtained as
where
is a welding path point in the robot coordinate space
,
is equivalent welding point in frame
, and
is the transformation matrix from robot
to
obtained using [
48]. Once
is obtained, the robot can be controlled to move to the point for welding.