# An Intelligent Solution for Automatic Garment Measurement Using Image Recognition Technologies
## 2 Materials and Methods
### Garment Key Points Detection  
The segmentation process is only the first step in determining the measurements of garments. Which measurements are relevant depends on the type of garment: for a skirt, for example, it is important to know the waist and length, but for a shirt or jacket you should also measure the length of the sleeves, the width of the shoulders, etc. Segmentation should then be followed by a classification task which allows identifying the necessary dimensions. Finally, once the type of garment has been identified, it is possible to identify the measurement key points which is the most challenging task and directly depends on segmentation results. An incorrect segmentation result can reduce the accuracy of key points detection or stop the algorithm altogether. In this study different key points detection algorithms have been created. The principle of the developed algorithms is to identify the edge points of the garment in the image that are necessary to determine the relevant dimensions in certain areas. In Figure 2 the basic key points for blazers, skirts and dresses are provided. For the blazers, it is important to capture the left and right shoulders' fall bottom points as the distance between these points (1 and 8) is the measure of shoulders width. To measure the total length of the blazer we need to find the midpoint of the shoulder strap and the midpoint of the bottom of the blazer. These points are captured on both sides, left (2,11) and right (7,10). Finally, the average value of these distances is calculated. Points 3 and 6 are used to determine where the shoulder line starts. To measure the length of the left and right sleeves we have the \begin{table}
\begin{tabular}{l l} \hline \hline
**UNet Model** & **Pretraining Dataset** \\ \hline UNet & DeepFashion2+ our dataset \\ UNet & Carvana + our dataset \\ UNet & our dataset \\ UNet 128 \(\times\) 128 & our dataset \\ UNet 256 \(\times\) 256 & our dataset \\ UNet 512 \(\times\) 512 & our dataset \\ \hline \hline \end{tabular}
\end{table} 
Table 1: UNet models with different pre-trained datasets. shoulders' fall bottom points (1,8) and the mid-points on the bottom of the sleeves (12,9). To measure the neck width, points (4) and (5) are included. It can be noticed from Figure 2 that for the dresses and skirts fewer key points are required. For the sleeveless dresses, 6 key points are included in order to measure the shoulder width, waist and total length. In addition, the width of the bottom of the dress can be calculated from points 5 and 4. To obtain a measurement for the skirt only four points are included: (1) top left point; (2) top right point; (3) bottom right point and (4) bottom left point. These points are sufficient to calculate the skirt waist, overall bottom length and width. Some general points that do not depend on the type of garment are included such as angle finder point, middle left and right points, bounding box, edge points, etc. The algorithms of such point detection can facilitate the finding process of the main key points. For example, the algorithm \"ClothBoundariesCalculator\" captures information on the position of the garment and the points of the bounding box. In this study we have performed experiments with the three types of garments, thus 26 key-point estimation algorithms have been created. The decisions in the algorithms are based on a threshold value applied for the pixel. For instance, Algorithm 1 represents the pseudo-code of the algorithm that finds the left and right side of the neckline with the generated mask and corresponds to the blazer's key point (4). This algorithm requires initial data on the position of the garment. All starting points have \((x,y)\) coordinates indicating their position on the garment. The top point of the garment is defined as \(T_{x,y}\). The middle point of the garment on the left side is annotated as \(L_{x,y}\) and the right as \(R_{x,y}\). The upper point of the collar on the left side is annotated as \(CL_{x,y}\) and the right as \(CR_{x,y}\).