System of error detection in the manufacture of garments using artificial vision

A computer vision system is implemented to detect errors in the cutting stage within the manufacturing process of garments in the textile industry. It provides solution to errors within the process that cannot be easily detected by any employee, in addition to significantly increase the speed of quality review. In the textile industry as in many others, quality control is required in manufactured products and this has been carried out manually by means of visual inspection by employees over the years. For this reason, the objective of this project is to design a quality control system using computer vision to identify errors in the cutting stage within the garment manufacturing process to increase the productivity of textile processes by reducing costs.


1.
Introduction In the textile industry, quality control is required in manufactured products and this has been carried out manually by means of visual inspection by employees over the years, observing the product, analysing it, classifying it and discovering its imperfections. However, people may overlook several errors because of various external factors, in addition to the human visual inspection has drawbacks such as distraction and fatigue of the operators to be a repetitive task or they are simply very slow when doing the inspection, which generates losses of product replacement or a decrease in profits when selling the products at lower prices. It is necessary to evaluate methods to increase the efficiency of these processes, focusing on the use of automatic machines to find small details that those in charge of the inspection cannot observe, so that the quality control is a competitive advantage in the textile industry [1]. A system of quality control is proposed using computer vision, to increase the precision in the inspection of the manufactured products and thus to achieve speed in the process of inspection and to increase the production. As for the device being implemented for processing, it is an embedded system Raspberry Pi 3, which has an operating system based Linux, Raspbian, in which an application compiled in OpenCV or free software to make it possible the implementation of complete computer vision system [2,3]. The Raspberry Pi 3 system has been chosen due to its hardware performance and the relative ease of using Raspbian for the intended implementation; some other development boards, such as Arduino, would force a more complex computer vision program with no apparent benefit compared to Raspberry Pi 3, in turn, the low consumption and small dimensions of the Raspberry Pi 3 make it ideal for its handling, assembly and operation, compared to a conventional computer.

2.
Historical With the success of the technological revolution or second industrial revolution in the late nineteenth and early twentieth century, mankind has always sought to adopt technology to streamline its processes. Thus, with the advance of the creation of digital images that emerged in the decade of the twenties and continues to the present day, computer vision took a lot of interest in researchers and entrepreneurs. The idea of obtaining information through the analysis of an image revolutionized the way of seeing many processes, one of them, the process of detecting errors in quality control, which began to take increasing importance. During the time of the craft era in the nineteenth century, products had been sought to meet the quality attributes that the end-user desired, with the passage of time and increase in production volume, the piece-by-piece inspection became impossible to perform, in consequently, Harold F. Dodge and Harry Roming, quality researchers, implemented acceptance sampling, thus only inspecting several products within the total. However, this solution was not sufficient to obtain the total quality, although the costs for errors in the products were reduced significantly, still exist errors that represented costs for the companies. Technology applied to quality was necessary, so computer vision systems became important in quality control posts for the most delicate processes. From this background, a large variety of research and applications have been made on the use of computer vision and image processing for error detection. On the other hand, having food, clothing and a home to live are human physical needs. Clothing has been taking on more and more meaning for humanity, to the point of becoming a representation of us, our personality and our way of life. It is for this reason that the manufacture of garments has evolved notably from periods such as the Neolithic period. Currently the design and manufacture of garments not only covers the most basic needs of users, but also offers technologies ranging from waterproof fabrics to wearables, smart devices that can be worn. Being necessary even in the design and construction of automobiles and airplanes. Textile production has become essential. Therefore, the textile industry is one of the largest industries in the world at the sales level only behind industries such as tourism and information [4].

Basic Manufacturing Process in the Textile Industry
In order to carry out the fabrication process of textile products, various steps are represented by stages, Figure 1. Raw Materials: These can be divided into natural fibres and synthetic fibres, such as cotton, wool, silk and nylon, polyester, rayon, respectively. Naturally, with the exponential growth of processes and the world population, the need for textiles has grown in the same way. It is believed that an economically stable person consumes between 20 and 25kg of textile products annually. This has created the need to produce more and more synthetic fibres to meet the needs. Yarn: Process through which the fibres are either natural or synthetic are transformed into fine, resistant, flexible and extremely long thread that allows to create fabrics.
Fabric: This is a process that has not changed since the origins of the first garments. However, it is also the most complex due to the large number of fabrics that exist. organization, positioning of tissues in parallel, Drawn, and Twisting. The process at its most basic level tries to organize the fibres strategically according to the type of fabric desired and to interlace them in such a way that they maintain a consistency throughout the process. Finish: This process is responsible for 3 main tasks: 1) Remove impurities that may appear on the fabric. 2) Dyeing and stamping determined by the use that will be given to the fabric. 3) Modifications in the surface of the fabric, either to improve the physical properties of the product which translates into greater comfort or simply aesthetic improvements. Cut and confection: It is the last stage of the manufacturing process of a textile product, in this, the fabrics treated in the previous stages are transformed into a final product, passing through sub-stages, such as: Cutting: The goal of this stage is to turn the fabric into pieces with specific shapes to be joined later through the sewing stage. Depending always on the type of technology used the cutting stage can be divided into 7 basic steps:1) A cut design is established for the parts of the product to be processed. 2) An optimization pattern is created to reduce waste as much as possible. 3) Prepare the fabric to cut. 4) Raw cuts are made that will serve for a next fine cut of contours 5) A mark is made on the pieces that will aid in fine cutting. These marks are imperceptible in the final product. 6) Fine cuts are made. The piece takes the final shape. 7) Parts are prepared for future steps. Then, Sewing: It is made the union of the pieces in 2 or 3 dimensions that shapes the final product. At this stage, the technology has been limited by the complexity that implies the union of pieces in 3 dimensions. Finally, Detailed: Here you can apply the formulas (buttons, locks, etc.). This process then comprises a systematic and orderly succession of steps, the last cannot be performed without having done all the previous ones. Therefore, in processes as dependent as this is necessary to have a control of errors in each of the stages of the process, otherwise these errors would represent costs for manufacturing companies.

Analysis of a digital image
It is common to hear that the term quality is associated or used when talking about high definition images, however this is not totally true. While the current formats present large amounts of pixels, 980x720 pixels for the High Definition (HD), this does not guarantee the image quality. This is simply the size of the image. The true quality of the image is directly related to the colour depth of each pixel, namely its representation, the more bits to represent a pixel, the longer the colour palette. This way our images will have as much quality as we want. Also, the quality of the image will depend on external factors, such as lighting, it is not the same to take an image in an open place where the irregularities of light are constant, that a closed place with lighting controls. To solve these problems of quality and thus extract the information of the image with more facility exist methods as they are the smoothing and enhanced. By one hand, the purpose of smoothing is to eliminate noise, which is presented as colour irregularities between pixels. Some smoothing techniques are: Average neighbourhood environment and Medium, fashion, maximum and minimum filtering. By the other hand Enhanced methods for the study of this work, these methods of improvement are not necessary, since being a quality control the lighting conditions will be optimal. Furthermore, Histogram is a representation of an image in the form of discrete function, that is, with a finite number of values. This represents the number of pixels that are in the image according to its intensity level. For example, the histogram of a grayscale image whose intensity levels oscillate between 0 and 255, results in a bar graph from which we can obtain valuable information according to its distribution at the moment of analysing digital images [5]. Finally, for the analysis of the image it is necessary of the segmentation that is the process through which we will obtain the information of the edges and regions, being based in this way in the discontinuity and the similarity. An edge will be represented by a drastic change in intensity levels, i.e. there will be discontinuity in the image, in a region there will be similarity [6].

4.
Main Algorithm In the manufacture of garments, garments that go through the cutting process, come from a previous process of dyeing, so that the colour posed a challenge in obtaining the correct image for analysis and detect errors. So, it is necessary to contrast the background with the garment in our acquisition of the image. Due to these colour variations in the garments, it was necessary to add a dynamic background with RGB LEDs. Step 1; Acquisition of the image, the image of the garment is captured. Step 2; Average image, it averages each channel of the complete image, red, green and blue. That is, we will have an average of red, green and blue. Step 3; Change background colour, with these values the colour that is less present in the image is determined, this will be the new colour of the background. For electrical convenience (less current consumption) only combinations that have a single voltage level will be used in each RGB led. That is, the primary colours of the model, red, green, blue, Table 1. Finally, Step 4; Acquisition of the new image, With the background well contrasted with the garment a new image is taken to verify the correct contrast with the garment [7][8]. The number of RGB LED's in the matrix, 100 in our case, requires a certain current, each LED has a working current I 0 of 20mA, so our matrix needs to be fed with 2A of current to work properly, with a proper luminescence for our application. To achieve this luminescence, it is necessary to adequately saturate the circuit, for that we used TIP100 transistors with current handling up to 8A. Considering a future expansion of the LED array [9]. To make possible the colour change in the RGB matrix, it is necessary to have a control for each RGB primary colour (red, green, blue), using the output ports of the Raspberry Pi 3 that must be connected to each Transistor to exert the switch function and power the circuit with the 2A current. However, a problem arises here, because the base-emitter voltage (V BE ) that most transistors handle is 5v and the maximum output voltage of the Raspberry Pi 3 is 3.3v. This prevents the saturation of the transistor and therefore represents a malfunction. The solution to this is the implementation of an photocoupler, which allows to use the 3.3v voltage level of the Raspberry Pi 3 as a switch to power the transistors with a voltage level of 5v. The next step is the comparison of histogram and binarization. Then, any histogram analyses pixel by pixel the intensity of the image, in our case, the acquired image will be transformed into grayscale, with intensity values from 0 to 255, i.e. with 8 bits of depth. The histogram shows us the concentration of pixels according to their tonalities, in our case the garment takes a dark tone due to the illumination, this helps us, since these dark colours will always be found at the beginning of the histogram, Figure  2(a). For each model, a mask is defined that represents the final pixel intensity value to be taken so that the garment is binarized and thus perfectly segmented from the colour background, Figure 2(b). The comparison will then be made with two images that in theory should be the same, one will be the original model to repeat in the cutting process and another will be the garment in production line, Figure 2(c). A great advantage of using this method for the analysis is that a prior alignment of the garment is not necessary, since no matter the location within the image, the garment contributes the same number of pixels. For this to be true care must be taken that the distance from the sensor to the garments is the same, otherwise, the objects in the image appear different sizes, changing the histogram [10].

Experimental Results
Thus, the acquired image of the garment in production line is compared with the image of the model, stored in the system. The comparison will result in the following scenarios, depending on their similarity or difference expressed as a percentage: 1) Similarity between 100-95%; It is the ideal scenario and means that the garment in production line is the same as the desired model. The percentage difference is due to lighting defects that come to be presented. So, the process continues without interruption.
2) Similarity between 95-80%; In this scenario, there is a clear difference, which can mean 2 errors: a) Garments of different sizes have been mixed. b) The garment presents bad cuts or ruptures in the fabric of previous processes. In this case, a check indicator is illuminated for the operator. This person will determine, depending on the severity of the error, the use of the defective garment.
3) Similarity less than 80%; Here the difference is remarkable and can represent 2 errors: a) The garment in production line has been mixed from another process, which explains the little similarity. b) The change of the model analysis has undergone some error there is a problem in the prototype, having thus to enter in the equation the operator. In the 3 cases the proposed algorithm responds with a 98.07% of success. The errors were found when proposed algorithm processes a garment with similarity less than 80\%, i.e. the third case.

6.
Conclusions A broad investigation of the topics was developed within different areas that are related by this work, areas such as the textile, such as medicine and computational. Then, Raspberry Pi 3 embedded system was implemented along with the Ubuntu operating system and the OpenCV compiler for the development of computer vision codes. It was possible to make a perfect segmentation of garments regardless of the colour that was given them in previous processes within the textile manufacturing, this was possible thanks to the implementation of a dynamic opaque background composed of RGB LEDs that change colour depending on contrast with the garment. The error detection performed by this system improves performance by finding errors that are difficult to detect by employees, which undoubtedly results in an improvement in the quality control of any company.