Clothing pattern contour extraction based on computer vision and Canny algorithm
Objective In order to improve the accuracy and convenience in collecting and converting two-dimensional pattern contour information,a method for garment pattern contour extraction based on computer vision was proposed.This research aimed to extract digitally the clothing patterns based on the use of two-dimensional pattern contour obtained from scanners or cameras.It was expected that the original physical template in the form of pattern card would be accurately transformed into a computer pattern contour image.Method This method involved both hardware and software.The hardware part was composed of a bracket,a smart phone,a quadrupod,a background plate and a calibration plate.The smart phone's camera was used as the image acquisition device.The part of software consists of image processing and contour extraction.The distortion parameters were obtained using the chessboard camera calibration method for image correction,and the corrected image was gray-scale processed and the matrix was simplified.The contrast between the target image and the background was improved by gamma transform ation of the gray image.The improved Canny algorithm was applied to extract the edge information of paper pattern image,and adaptive bilateral filtering was used for better edge-preserving denoising.The gradient templates in the 45° and 135° directions were added to the original Sobel convolution to calculate the gradient so as to improve the accuracy of position weighting coefficient.Non-maximum suppression and adaptive double threshold selection were carried out to refine and determine the edge.Double edge filling,smoothing and reprocessing of contour map were carried out by morphology closing operation.Finally,the skeleton was extracted from the contour map.Results After multiple experiments,the accuracy and effect of contour extraction were verified.In order to verify the accuracy of the contours,the function cv2.findContours()in the python library was adopted to extract the contour information which was then drawn on a white screen using Matplotlib library.The contour image was vectorized and saved as a PDF format,and the contour length was measured by the tool included in the PDF.The measurement results showed that the error was 0.15-1.50 cm compared to the length measured in reality,and the overall error was in line with the clothing error standard.More optical distortions and aberrations may be introduced when the object was placed at the edge of the camera for imaging,resulting in a larger imaging error than the central position.Therefore,it was necessary to place the paper pattern in the center of the camera during the operation to reduce the extraction error.In order to verify the effect of contour extraction,the extracted outer contour map,inner contour map and inner-outer contour map were compared with the contour map extracted by the traditional Canny edge detection algorithm.Both the conventional algorithm and the algorithm in this paper were able to outline roughly the contour map of the paper pattern.For the extraction of the outer outline of the paper pattern,both algorithms could achieve the same extraction effect by changing the sigma value and the parameters of the high and low threshold.However,a big difference existed between the two algorithms in the extraction of inner and inner-outer contours of paper patterns.When extracting the local details of the image,the effect of the conventional algorithm was not ideal,because the extracted internal symbol contour was not smooth enough,causing some small burrs and information lost.The proposed algorithm obtained the extraction of internal symbols without distinction,and the extraction effect of details such as cut,buckle and connector was good.For the whole image extraction,the effect of the conventional algorithm was not satisfactory in causing a large number of breakpoints and a small amount of noise points,especially for the inner contour extraction of paper pattern.Compared with the conventional algorithms,the proposed algorithm was found more prominent in removing noise and preserving edges and in creating clear extraction of the outer contour,inner contour and inner-outer contour of the paper pattern.It was suitable for the contour extraction of two-dimensional paper pattern,offering improved extraction efficiency.Conclusion The proposed improved pattern extraction algorithm combining the knowledge of camera calibration and image processing,can conveniently and efficiently achieve digital extraction of clothing pattern.Computer vision detection technology and improved Canny edge detection technology were adopted to design a non-contact two-dimensional clothing pattern contour extraction method to extract the outer contour,inner contour and inner-outer contour of paper patterns.The two-dimensional pattern contour extraction was based on the use of scanner or camera,and this technology is applicable to the garment manufacturing industry,advanced customization industry,and individual studios,with high practical application value.