**3.2 Artificial vision system**

An algorithm of computational vision is implemented in the welding process to locate spatially the pieces respect to the robot coordinates. The camera is set perpendicular to the working area at a fixed coordinate XYZAB with respect to the center robot position; the CCD makes the capture of the image that contains the pieces to be weld. OpenCV is used for the segmentation process and it is performed applying filters and morphological operation to determine the area of contact to be weld; this area becomes a straight line and the points that will be used for the creation of G code will be loaded in the numerical control.

For the processing of the images, the capture of the pieces to be weld is made, as can be seen in **Figure 6**. The working pieces are located on a surface that

**Figure 6.** *Original image.*

*Implementation of an Artificial Vision System for Welding in the Retrofitting Process… DOI: http://dx.doi.org/10.5772/intechopen.88360*

contrasts with the color of the pieces to facilitate the segmentation and identification of the edges.

Subsequently, the image is converted to a gray scale, and a Sobel filter is applied to create an image emphasizing edges. The resulting image can be observed in **Figure 7**; this process was made with the aim of being able to identify the possible closeness of the working pieces.

Before the pieces are segmented to highlight the edges, a morphological operation of closing is made to eliminate small gaps (filling them) and join components connected nearby. The kernel used is the structuring element of a rectangle of 1 8 pixels. The result is presented in **Figure 8**, where the space that separates the two pieces was totally filled.

In the last process, it is possible to highlight the suitable area for the welding process; the algorithm is able to do it due to a Gaussian filter that is applied to eliminate the rest of the edges of the piece and leave only the highlighted union of both. With the segmentation process done, the line that traces the union of the pieces is transformed into points that will be used to coordinate to which the arm must reach to carry out the welding process.

To verify the precision of the algorithm, several probes are made to check the real coordinates and the coordinates calculated from the computer vision. In this process, the values of the location of the camera and the relationship of the pixels and the location XYZAB change according to the precision of each servomotor.

**3.2 Artificial vision system**

**Figure 5.** *Digital indicator.*

*Digital Imaging*

**Table 3.** *Movements.*

**Figure 6.** *Original image.*

**70**

An algorithm of computational vision is implemented in the welding process to locate spatially the pieces respect to the robot coordinates. The camera is set perpendicular to the working area at a fixed coordinate XYZAB with respect to the center robot position; the CCD makes the capture of the image that contains the pieces to be weld. OpenCV is used for the segmentation process and it is performed applying filters and morphological operation to determine the area of contact to be weld; this area becomes a straight line and the points that will be used for the

**Displacement Axis (X) Axis (Y) Axis (Z)** To 1 (mm) 0.98 0.96 0.99 To 1.5 (mm) 1.48 1.46 1.47 To 2.5 (mm) 2.46 2.45 2.47 To 5 (mm) 4.88 4.84 4.90

For the processing of the images, the capture of the pieces to be weld is made,

as can be seen in **Figure 6**. The working pieces are located on a surface that

creation of G code will be loaded in the numerical control.

**Figure 8.** *Welding trajectory.*
