A method, system, device and storage medium for generating defective morphology of grey cloth

By annotating the grey cloth defect dataset with polygonal boxes and deforming it using the moving least squares method, more defect morphologies are generated, which solves the problem of insufficient defect data and improves the detection capability.

CN115689870BActive Publication Date: 2025-09-16SHANGHAI ZHIJING INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211363040.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-02
Publication Date
2025-09-16
Estimated Expiration
2042-11-02

AI Technical Summary

Technical Problem

In the existing technology of grey cloth defect detection, it is difficult to collect defect data, resulting in insufficient training data for deep learning models, limited changes in the generated defect morphology, and difficulty in improving detection capabilities.

Method used

By annotating the grey cloth defect dataset with polygonal boxes, the minimum circumscribed oblique rectangle and its control points are obtained, and the moving least squares method is used to perform local deformation on the image to generate more defect shapes.

Benefits of technology

It effectively generates a large number of training samples, increases the diversity and complexity of defect morphology, and improves the detection capability of deep learning models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115689870B_ABST
    Figure CN115689870B_ABST
Patent Text Reader

Abstract

The present invention relates to a method, system, device, and storage medium for generating defect morphology of grey cloth. The key points of the technical solution are: polygonal box marking of various defects in an image with marked defects in a grey cloth defect data set, and obtaining the coordinate values ​​of each vertex of the corresponding polygonal box; obtaining the corresponding minimum circumscribed oblique rectangle according to the coordinate values ​​of each vertex of each polygonal box; determining the control points of the minimum circumscribed oblique rectangle and its corresponding polygonal box, and constructing a corresponding control point set; perturbing the control points of each minimum circumscribed oblique rectangle and its corresponding polygonal box according to a preset deformation rate to generate a corresponding target mapping point set; adding the four vertices of the image to all control point sets and the target mapping point set respectively; using the moving least squares method to change the image based on each control point set and the target mapping point set to obtain a corresponding locally deformed image; the present application has the advantage of generating more defect morphologies.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image generation, and more particularly to a method, system, device, and storage medium for generating defective morphology of grey cloth. Background Art

[0002] In recent years, with the development of deep learning technology, computer vision techniques based on deep neural networks have become increasingly widely used in industrial defect detection. Fabric defect detection is a critical task in the textile industry. The Weaving Inspection Robot, an AI-powered robot for automated defect detection in grey fabric, utilizes deep learning models for defect detection.

[0003] However, the supervised training of deep learning models requires reliance on large amounts of manually annotated data, and the types of grey fabric defects in actual production scenarios are numerous, and the frequency of some defects is very low, making the collection of defect data quite difficult. Therefore, using a small number of image samples for each category to generate sufficient defect image data has become an important step in the implementation process. Currently, the data generation methods used for grey fabric defect target detection are mainly based on image processing methods, such as color generation by adjusting the brightness and contrast of the image, or optical geometric transformations such as image flipping, affine transformation, and perspective transformation. However, the defect morphology generated by this global generation method is very close to the original image morphology, and the changes in the defect area are relatively limited. When the sample size is relatively small, these methods have very limited effects on improving the model's defect detection capabilities, so there is still room for improvement. Summary of the Invention

[0004] In view of the shortcomings of the existing technology, the purpose of the present invention is to provide a method for generating defective morphology of grey cloth, which can realize the spatial transformation of defective morphology of grey cloth, generate more defective morphologies, and greatly improve the advantages of defective morphology.

[0005] The above technical objectives of the present invention are achieved through the following technical solutions: A method for generating defective morphology of grey cloth, comprising:

[0006] Mark various defects in the defect-annotated images in the grey fabric defect dataset with polygonal boxes, and obtain the coordinate values ​​of each vertex of the corresponding polygonal boxes;

[0007] Obtain the corresponding minimum circumscribed oblique rectangle according to the coordinate values ​​of each vertex of each polygonal box;

[0008] Determine the control points of the minimum circumscribed oblique rectangle and its corresponding polygonal box, and construct the corresponding control point set;

[0009] Perturb the control points in each minimum circumscribed oblique rectangle and its corresponding polygonal frame according to a preset deformation rate to generate a corresponding target mapping point set;

[0010] Adding the four vertices of the image to all control point sets and the target mapping point set respectively;

[0011] The image is transformed using a moving least squares method based on each control point set and a target mapping point set to obtain a corresponding local deformed image.

[0012] Optionally, obtaining the corresponding minimum circumscribed oblique rectangle according to the coordinate values ​​of each vertex of each polygonal frame includes:

[0013] Use OpenCV's minAreaRect interface to obtain the minimum circumscribed oblique rectangle corresponding to the coordinate values ​​of each vertex of each polygonal box, and return the center point coordinates, width, height, and rotation angle of each minimum circumscribed oblique rectangle;

[0014] The coordinates of the four vertices of each minimum circumscribed oblique rectangle are obtained through the boxPoints interface of OpenCV.

[0015] Optionally, the perturbation of the control points in each minimum circumscribed oblique rectangle and its corresponding polygonal frame according to a preset deformation rate to generate a corresponding target mapping point set includes:

[0016] Select one or more vertices of the polygonal box as control points, perturb the horizontal and vertical coordinates of each control point to obtain the corresponding target mapping point. The specific perturbation formula is as follows:

[0017] qx=px+ / -rw*deform_rate;

[0018] qy=py+ / -rh*deform_rate;

[0019] Among them, qx is the horizontal coordinate of the target mapping point; px is the horizontal coordinate of the control point; rw is the width of the circumscribed oblique rectangle; deform_rate is the deformation rate; qy is the vertical coordinate of the target mapping point; py is the vertical coordinate of the control point; rh is the height of the circumscribed oblique rectangle.

[0020] Optionally, the method for generating a defect morphology of grey fabric according to claim 1 is characterized in that the perturbation of the control points in each minimum circumscribed oblique rectangle and its corresponding polygonal frame according to a preset deformation rate to generate a corresponding target mapping point set further comprises:

[0021] The center point of the minimum circumscribed oblique rectangle is used as the control point, the control point is used as the coordinate origin, the product of the width of the minimum circumscribed oblique rectangle and the deformation rate is used as the major axis a of the ellipse, and the product of the height of the minimum circumscribed oblique rectangle and the deformation rate is used as the minor axis b of the ellipse, and the elliptical orbit is established;

[0022] Select a value in (0, a) as the horizontal coordinate delta_x on the elliptical orbit, and calculate the vertical coordinate delta_y corresponding to the horizontal coordinate using the following formula:

[0023] delta_y=(((a*b)^2-(b*delta_x)^2)^0.5) / a;

[0024] Calculate the target mapping point coordinates based on delta_x and delta_y:

[0025] qx=px+delta_x;

[0026] qy=py+delta_y.

[0027] Optionally, the perturbation of the control points in each minimum circumscribed oblique rectangle and its corresponding polygonal frame according to a preset deformation rate to generate a corresponding target mapping point set further includes:

[0028] The four vertices of the minimum circumscribed oblique rectangle are used as the control point set;

[0029] Adjusting the width, height, and rotation angle of the minimum circumscribed oblique rectangle according to the deformation rate to obtain the width, height, and rotation angle of the deformed minimum circumscribed oblique rectangle;

[0030] A deformed minimum circumscribed oblique rectangle is generated according to the width, height and rotation angle of the deformed minimum circumscribed oblique rectangle, and four vertices of the deformed minimum circumscribed oblique rectangle are obtained as a target mapping point set.

[0031] Optionally, the step of changing the image based on each control point set and the target mapping point set using a moving least squares method to obtain a corresponding locally deformed image includes:

[0032] Transforming the image using a moving least squares method based on each control point set and a target mapping point set, and calculating the sum of the absolute values ​​of the differences between the corresponding control point area and the mapping point area in the transformed image;

[0033] According to the sum of the absolute values ​​of the differences between the control point area and the mapping point area, the area involved in the corresponding control point is moved to the area involved in the target mapping point. Each movement uses the moving least squares method to transform the image to obtain the corresponding local deformed image.

[0034] Optionally, the step of changing the image based on each control point set and the target mapping point set using a moving least squares method to obtain a corresponding locally deformed image includes:

[0035] Performing an affine transformation on the image using a moving least squares method based on each control point set and a target mapping point set to obtain a corresponding local affine deformed image;

[0036] Based on each control point set and the target mapping point set, a moving least square method is used to perform similarity transformation on the image to obtain a corresponding local similar deformed image;

[0037] Based on each control point set and the target mapping point set, the image is rigidly transformed by using a moving least square method to obtain a corresponding local rigid deformed image.

[0038] A method for generating grey cloth defect morphology includes: a polygonal frame annotation module for annotating various defects in all defect-annotated images in a grey cloth defect dataset with polygonal frames, and obtaining coordinate values ​​of each vertex of the corresponding polygonal frame;

[0039] A minimum circumscribed oblique rectangle obtaining module is used to obtain the minimum circumscribed oblique rectangle of the polygonal box corresponding to each image according to the coordinate values ​​of each vertex of the polygonal box corresponding to each image;

[0040] A control point perturbation module is used to construct a control point set based on each minimum circumscribed oblique rectangle and polygonal box, and to perturb the control points of each minimum circumscribed oblique rectangle according to a preset deformation rate to generate a corresponding target mapping point set;

[0041] Vertex alignment module, used to add the four vertices of each image into the control point set and the target mapping point set respectively;

[0042] The defect morphology transformation module is used to transform the image by using the moving least square method based on the control point set and the target mapping point set to obtain a locally deformed image.

[0043] A computer device includes a memory and a processor, wherein the memory stores a computer program and the processor implements the steps of the above method when executing the computer program.

[0044] A computer-readable storage medium stores a computer program, which implements the steps of the above method when executed by a processor.

[0045] In summary, the present invention has the following beneficial effects: first, all images in the collected grey fabric defect dataset are annotated, polygonal boxes corresponding to the defects in the corresponding images are obtained, and the coordinate values ​​of each vertex of the polygonal box are obtained; then, based on the coordinate values ​​of each vertex of each polygonal box, the minimum circumscribed oblique rectangle RotatedRect corresponding to each polygonal box is obtained, and the deformation rate is set; then, corresponding points in the minimum circumscribed oblique rectangle and the polygonal box are selected as control points, the control point perturbation is performed, and the corresponding target mapping points are generated; then, the four vertices of each image are added to the control point set and the target mapping point set respectively, and the image is transformed using the moving least squares method based on the control point set and the target mapping point set to obtain a locally deformed image. Since the moving least squares method can effectively ensure the continuity and smoothness of the extracted contour while deforming the image locally, and through the transformation operations such as translation, rotation, scaling, tilting, and flipping of the extracted contour, the defects in the original image are made more complex and varied, and a large number of effective data samples can be generated from a small number of defect images, thereby realizing the spatial transformation of the grey fabric defect morphology, generating more defect morphologies, and greatly improving the defect morphology. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 It is a schematic diagram of the process of the present invention;

[0047] Figure 2 This is a structural diagram of the present invention when assembled;

[0048] Figure 3 2 is a diagram showing the internal structure of a computer device in an embodiment of the present invention. DETAILED DESCRIPTION

[0049] To make the objectives, features, and advantages of the present invention more readily apparent, the following detailed description of the present invention is provided with reference to the accompanying drawings. The accompanying drawings illustrate several embodiments of the present invention. However, the present invention may be implemented in many different forms and is not limited to the embodiments described herein.

[0050] In the present invention, unless otherwise expressly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or an indirect connection through an intermediate medium, or it can be a communication between the two components. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to the specific circumstances. The terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of such features.

[0051] In the present invention, unless otherwise expressly specified and limited, a first feature being "above" or "below" a second feature may include the first and second features being in direct contact, or may include the first and second features being in contact not directly but through another feature between them. Moreover, a first feature being "above," "above," and "above" a second feature includes the first feature being directly above and obliquely above the second feature, or simply indicates that the first feature is higher in level than the second feature. A first feature being "below," "below," and "below" a second feature includes the first feature being directly below and obliquely below the second feature, or simply indicates that the first feature is lower in level than the second feature. The terms "vertical," "horizontal," "left," "right," "above," "below," and similar expressions are for illustrative purposes only and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operate in a specific orientation, and therefore should not be understood as limiting the present invention.

[0052] The present invention is described in detail below with reference to the accompanying drawings and embodiments.

[0053] The present invention provides a method for generating defective morphology of grey cloth, such as Figure 1 As shown, including:

[0054] Step 100: annotate various defects of the defect-annotated image in the grey fabric defect dataset with polygonal boxes, and obtain the coordinate values ​​of each vertex of the corresponding polygonal boxes;

[0055] Step 200: Obtain the corresponding minimum circumscribed oblique rectangle according to the coordinate values ​​of each vertex of each polygonal frame;

[0056] Step 300: Determine the control points of the minimum circumscribed oblique rectangle and its corresponding polygonal box, and construct a corresponding control point set;

[0057] Step 400: perturb the control points in each minimum circumscribed oblique rectangle and its corresponding polygonal frame according to a preset deformation rate to generate a corresponding target mapping point set;

[0058] Step 500: Add the four vertices of the image to all control point sets and target mapping point sets respectively;

[0059] Step 600: Based on each control point set and the target mapping point set, the image is transformed using a moving least squares method to obtain a corresponding local deformed image.

[0060] In practical applications, the images in the collected grey cloth defect data set are first annotated to obtain polygonal boxes corresponding to each defect in the image. Since each point in the image has its corresponding coordinate value, a coordinate system is generally established with the lower left corner of the image as the coordinate origin and pixels as the unit, so the coordinate values ​​of each vertex of each polygonal box can be obtained; then, based on the coordinate values ​​of each vertex of each polygonal box, the minimum circumscribed oblique rectangle RotatedRect corresponding to each polygonal box is obtained, and the deformation rate is set. Then, the corresponding points in each minimum circumscribed oblique rectangle and its corresponding polygonal box are selected as control points to construct a control point set corresponding to the minimum circumscribed oblique rectangle and its corresponding polygonal box. By perturbing the control points in the control point set, the target mapping points corresponding to each control point are generated. Then, the four vertices of the image are added to the corresponding control point set and the target mapping point set respectively to align the edge and corner areas of the image; and the image is transformed using the moving least squares method based on the control point set and the target mapping point set to obtain a locally deformed image. Since the moving least squares method can effectively ensure the continuity and smoothness of the extracted contour while deforming the local image, and through the transformation operations such as translation, rotation, scaling, tilting, and flipping of the extracted contour, the defects in the original image are made more complex and changeable, and a large number of effective data samples can be generated from a small number of defective images, thereby realizing the spatial transformation of the defect morphology of the grey cloth, generating more defect morphologies, and greatly improving the defect morphology.

[0061] Specifically, the grey cloth defect dataset contains multiple images, and the above operation needs to be performed on each image. Different control point perturbations and image transformation methods can be used for each defect area in each image, so that multiple local deformed images can be generated from one image, that is, multiple valid data samples can be obtained.

[0062] Furthermore, obtaining the corresponding minimum circumscribed oblique rectangle according to the coordinate values ​​of each vertex of each polygonal frame includes:

[0063] Use OpenCV's minAreaRect interface to obtain the minimum circumscribed oblique rectangle corresponding to the coordinate values ​​of each vertex of each polygonal box, and return the center point coordinates, width, height, and rotation angle of each minimum circumscribed oblique rectangle;

[0064] The coordinates of the four vertices of each minimum circumscribed oblique rectangle are obtained through the boxPoints interface of OpenCV.

[0065] In practical applications, the minAreaRect interface of OpenCV is called to obtain the rectangle with the minimum area of ​​the point set formed by the coordinate values ​​of each vertex of the polygonal box. This rectangle is the minimum circumscribed oblique rectangle, which has a deflection angle and may not be parallel to the boundary of the image; the return value of the minAreaRect interface contains the center point coordinates, width, height and tilt angle information of the rectangle; then the coordinates of the four vertices of the rectangle are obtained through the boxPoints interface of OpenCV.

[0066] Optionally, the perturbation of the control points in each minimum circumscribed oblique rectangle and its corresponding polygonal frame according to a preset deformation rate to generate a corresponding target mapping point set includes:

[0067] Select one or more vertices of the polygonal box as control points, perturb the horizontal and vertical coordinates of each control point to obtain the corresponding target mapping point. The specific perturbation formula is as follows:

[0068] qx=px+ / -rw*deform_rate;

[0069] qy=py+ / -rh*deform_rate;

[0070] Among them, qx is the horizontal coordinate of the target mapping point; px is the horizontal coordinate of the control point; rw is the width of the circumscribed oblique rectangle; deform_rate is the deformation rate; qy is the vertical coordinate of the target mapping point; py is the vertical coordinate of the control point; rh is the height of the circumscribed oblique rectangle.

[0071] In practical applications, the deformation rate is pre-set in the range of 0-1. The larger the value, the greater the degree of deformation. In this embodiment, the deformation rate is 0.2. By selecting one or more vertices of the polygonal box as control points, the segmentation point perturbation is used to obtain the corresponding target mapping point.

[0072] Optionally, the perturbation of the control points in each minimum circumscribed oblique rectangle and its corresponding polygonal frame according to a preset deformation rate to generate a corresponding target mapping point set further includes:

[0073] The center point of the minimum circumscribed oblique rectangle is used as the control point, the control point is used as the coordinate origin, the product of the width of the minimum circumscribed oblique rectangle and the deformation rate is used as the major axis a of the ellipse, and the product of the height of the minimum circumscribed oblique rectangle and the deformation rate is used as the minor axis b of the ellipse, and the elliptical orbit is established;

[0074] Select a value in (0, a) as the horizontal coordinate delta_x on the elliptical orbit, and calculate the vertical coordinate delta_y corresponding to the horizontal coordinate using the following formula:

[0075] delta_y=(((a*b)^2-(b*delta_x)^2)^0.5) / a;

[0076] Calculate the target mapping point coordinates based on delta_x and delta_y:

[0077] qx=px+delta_x;

[0078] qy=py+delta_y.

[0079] In practical applications, the center point of the minimum circumscribed oblique rectangle is used to approximate the center point of the defect and is used as the disturbance object. The coordinates of the center point are used as the coordinate origin. The product of the width of the minimum circumscribed oblique rectangle and the deformation rate is used as the major axis a of the ellipse. The product of the height of the minimum circumscribed oblique rectangle and the deformation rate is used as the minor axis b of the ellipse. An elliptical orbit is calculated, and then a value is selected in (0, a) as the abscissa delta_x on the elliptical orbit. The ordinate delta_y corresponding to the abscissa is calculated using the following formula. The above-obtained abscissa and ordinate are added to the coordinates of the control point to obtain the target mapping point.

[0080] Furthermore, the perturbation of the control points in each minimum circumscribed oblique rectangle and its corresponding polygonal frame according to a preset deformation rate to generate a corresponding target mapping point set also includes:

[0081] The four vertices of the minimum circumscribed oblique rectangle are used as the control point set;

[0082] Adjusting the width, height, and rotation angle of the minimum circumscribed oblique rectangle according to the deformation rate to obtain the width, height, and rotation angle of the deformed minimum circumscribed oblique rectangle;

[0083] A deformed minimum circumscribed oblique rectangle is generated according to the width, height and rotation angle of the deformed minimum circumscribed oblique rectangle, and four vertices of the deformed minimum circumscribed oblique rectangle are obtained as a target mapping point set.

[0084] In practical applications, the four vertices of the minimum circumscribed oblique rectangle are used as the control point set. The width, height and rotation angle of the minimum circumscribed oblique rectangle are randomly perturbed based on the deformation rate. The perturbation amplitude is (0, 0.2). Then, four new vertices are generated as the target mapping point set based on the width, height and rotation angle of the newly obtained oblique rectangle.

[0085] Furthermore, the image is transformed using a moving least squares method based on each control point set and the target mapping point set to obtain a corresponding local deformed image, including:

[0086] Transforming the image using a moving least squares method based on each control point set and a target mapping point set, and calculating the sum of the absolute values ​​of the differences between the corresponding control point area and the mapping point area in the transformed image;

[0087] According to the sum of the absolute values ​​of the differences between the control point area and the mapping point area, the area involved in the corresponding control point is moved to the area involved in the target mapping point. Each movement uses the moving least squares method to transform the image to obtain the corresponding local deformed image.

[0088] In practical applications, deformation is controlled by the moving least squares method based on the control point set and the target mapping point set. For each point to be deformed, a local coordinate transformation matrix is ​​first estimated by solving a least squares optimization objective function according to the preset new version type. Then, the coordinate transformation matrix is ​​applied to the current point to calculate the deformed position of the point. After obtaining the deformed coordinates corresponding to each pixel point (forward mapping), it is not difficult to infer the source pixel position corresponding to each pixel point in the deformed image and interpolate to calculate the corresponding pixel value to obtain the deformed image. Since for each point to be deformed, an optimization objective function must be established to solve a local coordinate transformation matrix, and the area where each control point in the control point set is located is moved to the area where the corresponding target mapping point is located, and each movement uses the moving least squares method to transform the image, after all the control points in the control point set are moved to the area where the target mapping point is located, the deformation can be completed and the local deformed image can be obtained.

[0089] Furthermore, the image is transformed using a moving least squares method based on each control point set and the target mapping point set to obtain a corresponding local deformed image, including:

[0090] Performing an affine transformation on the image using a moving least squares method based on each control point set and a target mapping point set to obtain a corresponding local affine deformed image;

[0091] Based on each control point set and the target mapping point set, a moving least square method is used to perform similarity transformation on the image to obtain a corresponding local similar deformed image;

[0092] Based on each control point set and the target mapping point set, the image is rigidly transformed by using a moving least square method to obtain a corresponding local rigid deformed image.

[0093] In practical applications, affine deformation is to translate, rotate, scale, tilt and flip the area where the control point is located; similarity transformation is to translate, rotate and scale the area where the control point is located; rigid transformation is to translate and rotate the area where the control point is located.

[0094] Specifically, after the acquired grey cloth defect image is annotated, the image is annotated with polygonal boxes. Since there may be multiple defects in an image, there may be multiple polygonal boxes in an image. Then, the minimum circumscribed oblique rectangle corresponding to each polygonal box is obtained, and the vertices of each polygonal box and the minimum circumscribed oblique rectangle and the center point of the minimum circumscribed oblique rectangle are used as control points. The control points are perturbed according to the defect type. For example, for defects such as broken defects, the segmentation point perturbation can be used to achieve the external deformation of the broken defect, the center point perturbation can be used to achieve the internal deformation of the broken defect, and the circumscribed oblique rectangle perturbation can be used to achieve the expansion, contraction, rotation and other morphological transformations of the broken defect, thereby generating as many new forms as possible; thus, three defect forms can be generated by perturbing the control points of a polygonal box and the minimum circumscribed oblique rectangle, and then each defect form is transformed by the moving least squares method, such as affine transformation, similarity transformation and rigid transformation, so that nine defects are generated only by a polygonal box and the minimum circumscribed oblique rectangle corresponding to a defect.

[0095] Through the above method, a large number of training samples can be generated from a small number of grey cloth defect images, and as many new forms of defects as possible can be generated through control point perturbation. Through the moving least squares method, the image can be locally deformed while effectively ensuring the continuity and smoothness of the extracted contour. By performing transformation operations such as translation, rotation, scaling, tilting, and flipping on the extracted contour, the defects in the original image can be made more complex and changeable.

[0096] like Figure 2 As shown, the present invention also provides a grey cloth defect morphology generation system, comprising:

[0097] The polygonal box marking module 10 is used to mark various defects in the defect-marked images in the grey fabric defect dataset with polygonal boxes, and obtain the coordinate values ​​of each vertex of the corresponding polygonal box;

[0098] A minimum circumscribed oblique rectangle obtaining module 20 is configured to obtain a corresponding minimum circumscribed oblique rectangle according to the coordinate values ​​of each vertex of each polygonal frame;

[0099] A control point set construction module 30 is used to determine the control points of the minimum circumscribed oblique rectangle and its corresponding polygonal box, and to construct the corresponding control point set;

[0100] A control point perturbation module 40 is used to perturb the control points in each minimum circumscribed oblique rectangle and its corresponding polygonal frame according to a preset deformation rate to generate a corresponding target mapping point set;

[0101] a vertex alignment module 50, configured to add the four vertices of the image to all control point sets and the target mapping point set respectively;

[0102] The defect morphology transformation module 60 is used to transform the image using a moving least square method based on each control point set and a target mapping point set to obtain a corresponding local deformed image.

[0103] Furthermore, the minimum circumscribed oblique rectangle acquisition module includes:

[0104] The minimum circumscribed oblique rectangle obtaining unit is used to obtain the minimum circumscribed oblique rectangle corresponding to the coordinate values ​​of each vertex of each polygonal box through the OpenCV minAreaRect interface, and return the center point coordinates, width, height, and rotation angle of each minimum circumscribed oblique rectangle;

[0105] The minimum circumscribed oblique rectangle information obtaining unit is used to obtain the coordinates of the four vertices of each minimum circumscribed oblique rectangle through the boxPoints interface of OpenCV.

[0106] Furthermore, the defect morphology transformation module includes:

[0107] a change region calculation unit, configured to transform the image using a moving least squares method based on each control point set and a target mapping point set, and calculate the sum of absolute values ​​of differences between corresponding control point regions and mapping point regions in the transformed image;

[0108] The region movement transformation unit is used to move the region involved in the corresponding control point to the region involved in the target mapping point according to the sum of the absolute values ​​of the differences between the regions of each control point and the regions of the mapping point. Each movement uses the moving least squares method to transform the image to obtain the corresponding locally deformed image.

[0109] Furthermore, the change region calculation unit includes:

[0110] an affine transformation region calculation unit, configured to perform an affine transformation on the image using a moving least squares method based on each control point set and a target mapping point set, to obtain a corresponding local affine deformed image;

[0111] a similarity transformation region calculation unit, configured to perform similarity transformation on the image using a moving least squares method based on each control point set and a target mapping point set, to obtain a corresponding local similar deformed image;

[0112] The rigid transformation region calculation unit is used to perform a rigid transformation on the image using a moving least square method based on each control point set and a target mapping point set to obtain a corresponding local rigid deformation image.

[0113] The specific limitations of a grey fabric defect morphology generation system can be found in the limitations of a grey fabric defect morphology generation method described above and will not be further elaborated here. Each module in the aforementioned grey fabric defect morphology generation system can be implemented in whole or in part via software, hardware, or a combination thereof. Each of these modules can be embedded in or independent of a processor in a computer device in hardware form, or stored in a computer device memory in software form, allowing the processor to call and execute the corresponding operations of each module.

[0114] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 3 As shown. The computer device includes a processor, memory, a network interface, and a database connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. When executed by the processor, the computer program implements a method for generating a defect morphology of grey fabric.

[0115] Those skilled in the art will understand that Figure 3 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0116] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the following steps are implemented: annotating various defects in an image of annotated defects in a grey fabric defect dataset with polygonal boxes, and obtaining coordinate values ​​of each vertex of the corresponding polygonal boxes;

[0117] Obtain the corresponding minimum circumscribed oblique rectangle according to the coordinate values ​​of each vertex of each polygonal box;

[0118] Determine the control points of the minimum circumscribed oblique rectangle and its corresponding polygonal box, and construct the corresponding control point set;

[0119] Perturb the control points in each minimum circumscribed oblique rectangle and its corresponding polygonal frame according to a preset deformation rate to generate a corresponding target mapping point set;

[0120] Adding the four vertices of the image to all control point sets and the target mapping point set respectively;

[0121] The image is transformed using a moving least squares method based on each control point set and a target mapping point set to obtain a corresponding local deformed image.

[0122] In one embodiment, obtaining the corresponding minimum oblique circumscribed rectangle according to the coordinate values ​​of each vertex of each polygonal frame includes:

[0123] Use OpenCV's minAreaRect interface to obtain the minimum circumscribed oblique rectangle corresponding to the coordinate values ​​of each vertex of each polygonal box, and return the center point coordinates, width, height, and rotation angle of each minimum circumscribed oblique rectangle;

[0124] The coordinates of the four vertices of each minimum circumscribed oblique rectangle are obtained through the boxPoints interface of OpenCV.

[0125] In one embodiment, the perturbation of the control points in each minimum circumscribed oblique rectangle and its corresponding polygonal frame according to a preset deformation rate to generate a corresponding target mapping point set includes:

[0126] Select one or more vertices of the polygonal box as control points, perturb the horizontal and vertical coordinates of each control point to obtain the corresponding target mapping point. The specific perturbation formula is as follows:

[0127] qx=px+ / -rw*deform_rate;

[0128] qy=py+ / -rh*deform_rate;

[0129] Among them, qx is the horizontal coordinate of the target mapping point; px is the horizontal coordinate of the control point; rw is the width of the circumscribed oblique rectangle; deform_rate is the deformation rate; qy is the vertical coordinate of the target mapping point; py is the vertical coordinate of the control point; rh is the height of the circumscribed oblique rectangle.

[0130] In one embodiment, the perturbation of the control points in each minimum circumscribed oblique rectangle and its corresponding polygonal frame according to a preset deformation rate to generate a corresponding target mapping point set further includes:

[0131] The center point of the minimum circumscribed oblique rectangle is used as the control point, the control point is used as the coordinate origin, the product of the width of the minimum circumscribed oblique rectangle and the deformation rate is used as the major axis a of the ellipse, and the product of the height of the minimum circumscribed oblique rectangle and the deformation rate is used as the minor axis b of the ellipse, and the elliptical orbit is established;

[0132] Select a value in (0, a) as the horizontal coordinate delta_x on the elliptical orbit, and calculate the vertical coordinate delta_y corresponding to the horizontal coordinate using the following formula:

[0133] delta_y=(((a*b)^2-(b*delta_x)^2)^0.5) / a;

[0134] Calculate the target mapping point coordinates based on delta_x and delta_y:

[0135] qx=px+delta_x;

[0136] qy=py+delta_y.

[0137] In one embodiment, the perturbation of the control points in each minimum circumscribed oblique rectangle and its corresponding polygonal frame according to a preset deformation rate to generate a corresponding target mapping point set further includes:

[0138] The four vertices of the minimum circumscribed oblique rectangle are used as the control point set;

[0139] Adjusting the width, height, and rotation angle of the minimum circumscribed oblique rectangle according to the deformation rate to obtain the width, height, and rotation angle of the deformed minimum circumscribed oblique rectangle;

[0140] A deformed minimum circumscribed oblique rectangle is generated according to the width, height and rotation angle of the deformed minimum circumscribed oblique rectangle, and four vertices of the deformed minimum circumscribed oblique rectangle are obtained as a target mapping point set.

[0141] In one embodiment, the image is transformed using a moving least squares method based on each control point set and a target mapping point set to obtain a corresponding locally deformed image, including:

[0142] Transforming the image using a moving least squares method based on each control point set and a target mapping point set, and calculating the sum of the absolute values ​​of the differences between the corresponding control point area and the mapping point area in the transformed image;

[0143] According to the sum of the absolute values ​​of the differences between the control point area and the mapping point area, the area involved in the corresponding control point is moved to the area involved in the target mapping point. Each movement uses the moving least squares method to transform the image to obtain the corresponding local deformed image.

[0144] In one embodiment, the image is transformed using a moving least squares method based on each control point set and a target mapping point set to obtain a corresponding locally deformed image, including:

[0145] Performing an affine transformation on the image using a moving least squares method based on each control point set and a target mapping point set to obtain a corresponding local affine deformed image;

[0146] Based on each control point set and the target mapping point set, a moving least square method is used to perform similarity transformation on the image to obtain a corresponding local similar deformed image;

[0147] Based on each control point set and the target mapping point set, the image is rigidly transformed by using a moving least square method to obtain a corresponding local rigid deformed image.

[0148] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchl ink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0149] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0150] The above description is merely a preferred embodiment of the present invention. The scope of protection of the present invention is not limited to the above embodiment. All technical solutions based on the concept of the present invention are within the scope of protection of the present invention. It should be noted that for those skilled in the art, various improvements and modifications that do not depart from the principles of the present invention should also be considered within the scope of protection of the present invention.

Claims

1. A method for generating defective morphology of grey cloth, characterized in that: include: Mark various defects in the defect-annotated images in the grey fabric defect dataset with polygonal boxes, and obtain the coordinate values ​​of each vertex of the corresponding polygonal boxes; Obtain the corresponding minimum circumscribed oblique rectangle according to the coordinate values ​​of each vertex of each polygonal box; Determine the control points of the minimum circumscribed oblique rectangle and its corresponding polygonal box, and construct the corresponding control point set; Perturb the control points in each minimum circumscribed oblique rectangle and its corresponding polygonal frame according to a preset deformation rate to generate a corresponding target mapping point set; Adding the four vertices of the image to all control point sets and the target mapping point set respectively; Based on each control point set and the target mapping point set, the image is transformed using a moving least squares method to obtain a corresponding local deformed image; The method of obtaining the corresponding minimum circumscribed oblique rectangle according to the coordinate values ​​of each vertex of each polygonal box includes: obtaining the minimum circumscribed oblique rectangle corresponding to the coordinate values ​​of each vertex of each polygonal box through the minAreaRect interface of OpenCV, and returning the center point coordinates, width, height, and rotation angle of each minimum circumscribed oblique rectangle; obtaining the coordinates of the four vertices of each minimum circumscribed oblique rectangle through the boxPoints interface of OpenCV; The method of perturbing the control points of each minimum circumscribed oblique rectangle and its corresponding polygonal box according to a preset deformation rate to generate a corresponding target mapping point set includes: selecting one or more vertices of the polygonal box as control points, perturbing the horizontal and vertical coordinates of each control point, and obtaining the corresponding target mapping point. The specific perturbation formula is as follows: qx = px + / - rw*deform_rate; qy = py + / - rh*deform_rate; Among them, qx is the horizontal coordinate of the target mapping point; px is the horizontal coordinate of the control point; rw is the width of the circumscribed oblique rectangle; deform_rate is the deformation rate; qy is the vertical coordinate of the target mapping point; py is the vertical coordinate of the control point; rh is the height of the circumscribed oblique rectangle; The method of perturbing the control points of each minimum circumscribed oblique rectangle and its corresponding polygonal frame according to a preset deformation rate to generate a corresponding target mapping point set further includes: using the center point of the minimum circumscribed oblique rectangle as a control point, using the control point as a coordinate origin, using the product of the width of the minimum circumscribed oblique rectangle and the deformation rate as the major axis a of the ellipse, and using the product of the height of the minimum circumscribed oblique rectangle and the deformation rate as the minor axis b of the ellipse to establish an elliptical orbit; Select a value in (0, a) as the horizontal coordinate delta_x on the elliptical orbit, and calculate the vertical coordinate delta_y corresponding to the horizontal coordinate using the following formula: delta_y = (((a*b)^2 - (b*delta_x)^2) ^ 0.5) / a; Calculate the target mapping point coordinates based on delta_x and delta_y: qx = px + delta_x; qy = py + delta_y; The method of perturbing the control points of each minimum circumscribed oblique rectangle and its corresponding polygonal frame according to a preset deformation rate to generate a corresponding target mapping point set also includes: using the four vertices of the minimum circumscribed oblique rectangle as the control point set; adjusting the width, height and rotation angle of the minimum circumscribed oblique rectangle according to the deformation rate to obtain the width, height and rotation angle of the deformed minimum circumscribed oblique rectangle; generating a deformed minimum circumscribed oblique rectangle according to the width, height and rotation angle of the deformed minimum circumscribed oblique rectangle, and obtaining the four vertices of the deformed minimum circumscribed oblique rectangle as the target mapping point set.

2. A method for generating defective morphology of grey cloth according to claim 1, characterized in that: The step of changing the image based on each control point set and the target mapping point set using a moving least squares method to obtain a corresponding local deformed image includes: Transforming the image using a moving least squares method based on each control point set and a target mapping point set, and calculating the sum of the absolute values ​​of the differences between the corresponding control point area and the mapping point area in the transformed image; According to the sum of the absolute values ​​of the differences between the control point area and the mapping point area, the area involved in the corresponding control point is moved to the area involved in the target mapping point. Each movement uses the moving least squares method to transform the image to obtain the corresponding local deformed image.

3. The method for generating defective morphology of grey cloth according to claim 2, characterized in that: The step of changing the image based on each control point set and the target mapping point set using a moving least squares method to obtain a corresponding local deformed image includes: Performing an affine transformation on the image using a moving least squares method based on each control point set and a target mapping point set to obtain a corresponding local affine deformed image; Based on each control point set and the target mapping point set, a moving least square method is used to perform similarity transformation on the image to obtain a corresponding local similar deformed image; Based on each control point set and the target mapping point set, the image is rigidly transformed by using a moving least square method to obtain a corresponding local rigid deformed image.

4. A grey cloth defect morphology generation system, characterized in that: include: The polygonal box annotation module is used to annotate various defects in the defect-annotated images in the grey fabric defect dataset with polygonal boxes and obtain the coordinate values ​​of each vertex of the corresponding polygonal box; A minimum circumscribed oblique rectangle obtaining module is used to obtain the corresponding minimum circumscribed oblique rectangle according to the coordinate values ​​of each vertex of each polygonal box; A control point set construction module is used to determine the control points of the minimum circumscribed oblique rectangle and its corresponding polygonal box, and to construct the corresponding control point set; A control point perturbation module is used to perturb the control points in each minimum circumscribed oblique rectangle and its corresponding polygonal frame according to a preset deformation rate to generate a corresponding target mapping point set; a vertex alignment module, configured to add four vertices of the image to all control point sets and target mapping point sets respectively; A defect morphology transformation module is used to transform the image using a moving least squares method based on each control point set and a target mapping point set to obtain a corresponding local deformed image; The grey cloth defect morphology generation system is used to execute the method according to any one of claims 1 to 3.

5. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 3 are implemented.

6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 3 are implemented.

Citation Information

Patent Citations

  • SAB safety airbag size visual measurement method

    CN109978940A

  • Automatic generation method and device of jade engraving path

    CN110356151A