FabricVision : System of Error Detection in the Manufacture of Garments

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. Keywords—Computer vision; histogram of oriented gradient; segmentation; object detection; image capture


I. 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 (Fig. 1), 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.
For the acquisition of images use of a sensor with maximum resolution of 720 pixels and 24 bits of color depth is made.

II. HISTORICAL FRAMEWORK
With the success of the technological revolution or second industrial revolution in the late 19th and early 20th 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 [4].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 [5], [6], [7].

A. Basic Manufacturing Process in the Textile Industry
In order to carry out the fabrication process of textile products, various steps are represented by stages (Fig. 2).Raw Materials: These can be divided into natural fibers and synthetic fibers, 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 fibers to meet the needs.
Yarn: Process through which the fibers 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 in essence 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.It consists of four basic steps: Tissue organization, Positioning of tissues in parallel, Drawn, and Twisting.The process at its most basic level tries to organize the fibers 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 three 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 seven 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.
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.
Detailed: Here you can apply the formulas (buttons, locks, etc.).This process then comprises a systematic and orderly succession of steps, the last can not be performed without having done all the previous ones.This is why 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.

B. 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 Defenition (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 color depth of each pixel, namely, its representation, the more bits to represent a pixel, the longer the color 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 color irregularities between pixels.Some smoothing techniques are: Average neighborhood 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 analyzing digital images [8].
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 [9].

1) Smoothing:
The purpose of this operation is to eliminate the noise, which appears as color irregularities between the pixels.Some smoothing techniques are: • Averaged neighborhood environment.
• Filtering the median, fashion, maximum and minimum.
From (1): • g (i, j) is the value of an output pixel.
• f (i + k, j + l) is the sum of input pixel values.
• h (h, l) is the kernel, the filter coefficients.
2) Enhancing: For the study of this thesis, these methods of improvement are not necessary, since when it is a quality control the lighting conditions will be optimal.
3) Histogram: It is a representation of an image in the form of a discrete function, that is, with a finite number of values.This represents the number of pixels that are in the image according to their intensity level.
As we observed in Fig. 3, the histogram of a digital image, in this case, at a gray scale 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 to analyze digital images.

IV. MAIN ALGORITHM
In the manufacture of garments, garments that go through the cutting process, come from a previous process of dyeing, so that the color 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.
The block diagram of the project is shown in Fig. 4.
Thus, due to these color variations in the garments, it was necessary to add a dynamic background with RGB LEDs.The process is the following: 1) Acquisition of the image: The image of the garment is captured, Fig. 5. 2) Identification of the Region of Interest: The image is transformed to gray scale and binarized using an adaptive threshold.This works by comparing a pixel with a certain number N of pixels that surround it.I, this will be the new color of the background to increase the contrast (Fig. 7).
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.In order to make possible the color change in the RGB matrix, it is necessary to have a control for each RGB primary color (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 baseemitter 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 analyzes 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 colors will always be found at the beginning of the histogram (Fig. 8(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 color background (Fig. 8(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 (Fig. 8(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 amount 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.

V. 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 exactly 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, that is to say, there is a problem in the prototype, having thus to enter in the equation the operator.
In 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.

VI. 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.A variety of resources such as books, internet articles and even image editors were used in order to achieve a theoretical basis as robust as possible.Also 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 color 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 color depending on contrast with the garment.The main process was based on the comparison of histograms of two images that in the ideal case should be exactly the same, one is the model to replicate within the production process and another is the garment in turn within the process.This analysis then represents a way of detecting not only whether the garment is the same to the model, but also to determine what the possible error is.The set of all these processes resulted in an extremely useful computer vision system for the cutting stage within the textile manufacturing process.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.

Fig. 2 .
Fig. 2. Stages of the manufacturing process of textile products.

Fig. 3 .
Fig. 3. Image with its histogram (a) Image with good contrast (b) Very dark image (c) Image with a lot of brightness.

TABLE I .
COLOR COMBINATIONS IN RGB LEDS