Disclosure of Invention
The invention provides a cloth seam detection method and device, electronic equipment and a storage medium, aiming at overcoming the defect that the flaw detection is influenced by the seam of cloth in the cloth flaw detection process in the prior art.
The invention solves the technical problems through the following technical scheme:
a method of cloth seam detection, the method comprising:
collecting a cloth image of a cloth to be detected, and converting the cloth image into a gray image;
carrying out binarization processing on the gray level image;
counting the pixel distribution of the image subjected to binarization processing;
and judging whether a seam exists in the cloth to be detected according to the statistical result.
Optionally, the cloth to be detected comprises a plurality of pieces of cloth, and the pieces of cloth are spliced by seam lines with different color systems;
before the cloth image is collected, the method comprises the following steps:
starting the cloth guiding and conveying equipment under the condition of receiving the detection request;
collecting the cloth image, including:
and periodically collecting the cloth image in the process that the cloth guiding and conveying equipment guides and conveys the cloth to be detected from one end of the cloth guiding and conveying equipment to the other end of the cloth guiding and conveying equipment.
Optionally, acquiring the cloth image includes:
collecting a plurality of cloth images of a target area in the cloth to be detected at the same collecting moment;
judging whether a seam exists in the cloth to be detected according to the statistical result, comprising the following steps:
and if judging that at least two images in the cloth images have seams according to the statistical result, determining the target area as a seam area.
Optionally, the cloth seam detection method further includes:
and determining the number of the cloth in the cloth to be detected according to the judgment result.
A cloth seam detection apparatus, comprising:
the camera module is used for collecting a cloth image of the cloth to be detected;
the image processing module is used for converting the cloth image into a gray level image and carrying out binarization processing on the gray level image;
the statistical module is used for counting the pixel distribution of the image subjected to binarization processing;
and the judging module is used for judging whether a seam exists in the cloth to be detected according to the statistical result.
Optionally, the cloth to be detected comprises a plurality of pieces of cloth, and the pieces of cloth are spliced by seam lines with different color systems;
the cloth seam detection device further comprises: a cloth guide module;
the cloth guiding and conveying module is used for guiding and conveying the cloth to be detected from one end to the other end under the condition of receiving the detection request;
the camera module is specifically used for periodically collecting the cloth image in the process of conveying the cloth to be detected by the cloth conveying module.
Optionally, the number of the camera modules is multiple;
the plurality of camera modules are arranged above the cloth guiding and conveying module and are distributed on a straight line perpendicular to the guiding and conveying direction of the cloth to be detected.
Optionally, the plurality of camera modules acquire the cloth images at the same period;
the judging module is specifically used for judging that at least two images in a plurality of cloth images collected at the same collecting moment have seams according to the statistical result, and determining that the area corresponding to the cloth images in the cloth to be detected is a seam area.
An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the cloth seam detection method of any of the above when executing the computer program.
A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method of piece goods seam detection as set forth in any of the preceding claims.
The positive progress effects of the invention are as follows: the invention realizes accurate detection of the seam in the cloth and can eliminate the interference of the seam area on the flaw detection of the cloth.
Detailed Description
The invention is further illustrated by the following examples, which are not intended to limit the scope of the invention.
In the related art, when a textile mill detects a defect in a cloth, several or even more than ten pieces of cloth are usually spliced together with a seam line. During the perching, only need to put cloth inspection machine on the first piece of cloth, subsequent and preceding cloth link together, pass through cloth inspection machine in order, can realize the flaw detection to the cloth based on machine vision technique. However, when the machine vision automatic cloth inspection is performed, the seam of the cloth is mistaken for a flaw, which affects the accuracy of the cloth flaw detection on one hand and the efficiency of the cloth detection on the other hand.
Accordingly, the embodiment of the invention provides a cloth seam detection device, which is used for detecting whether a seam exists in cloth so as to eliminate interference of a seam area on flaw detection of the cloth. It should be noted that, in order to facilitate seam detection, the color of the seam line of the spliced cloth should be greatly different from the color of the cloth, for example, if the cloth is of a light color system, the seam line of a dark color system such as dark blue, black, etc. is selected; if the cloth is dark color, the seam line is white or apricot.
Fig. 1 is a schematic block diagram of a piece goods seam detection apparatus according to an exemplary embodiment of the present invention, the piece goods seam detection apparatus including: the device comprises a camera module 11, an image processing module 12, a statistic module 13, a judgment module 14 and a cloth guiding and conveying module 15.
The number of the camera modules 11 may be multiple, referring to fig. 2, the multiple camera modules are arranged above the cloth guiding and conveying module 15 and distributed on a straight line, and the straight line is perpendicular to the guiding and conveying direction of the cloth to be detected (arrow direction in the figure). At the same acquisition moment, the set of areas corresponding to the cloth images acquired by the plurality of camera modules in the cloth to be detected is called a target area of the area to be detected.
In the case that the cloth seam detecting device receives the detection request, the cloth guiding and conveying module guides the cloth to be detected from one end of the cloth guiding and conveying device to the other end of the cloth guiding and conveying device, that is, the cloth guiding and conveying module guides the cloth to be detected along the arrow direction shown in fig. 2.
In the process of guiding and conveying the cloth by the cloth guiding and conveying equipment, the camera module 11 periodically collects the cloth image of the cloth to be detected. It can be understood that, in the cloth guiding process, the cloth moves along one direction, and the camera module 11 is fixed, and for each period, the camera module 11 collects cloth images of different areas in the cloth to be detected. And through the guide of the cloth to be detected, the camera module can collect the cloth images of all the areas to be detected of the cloth to be detected so as to comprehensively detect the cloth to be detected.
For each cloth image collected by the camera module, the image processing module 12 takes the cloth image as a gray level image and performs binarization processing on the gray level image. Specifically, the binarization may be performed by, but not limited to, a threshold method, and the threshold may be set to about 200 according to experience.
The statistical module 13 counts the pixel distribution of each image subjected to the binarization processing.
If a light color system seam line is used, only the seam line of the binarized image is white, and the rest is black, fig. 3 is a schematic diagram of the binarized image according to an exemplary embodiment of the present invention, and the statistical module 13 performs statistics on white pixel distribution. As can be seen, the black and white pixels are always present at intervals and are substantially uniform in width (due to the machine stitching the piece of cloth with a flat seam), and the white pixels are present at a certain length.
If a dark color system of seam lines is used, the image after binarization processing is opposite to the schematic diagram shown in fig. 3, only the seam lines are black, the rest are white, and the statistical module 13 performs statistics on the black pixel distribution.
The judging module 14 is configured to judge whether a seam exists in the to-be-detected fabric according to the statistical result. Specifically, if the pixel distribution is similar to the shape distribution characteristics of the seam, judging that the seam exists in the area corresponding to the cloth image in the cloth to be detected; and if the pixel distribution is not similar to the shape distribution characteristics of the seam, judging that no seam exists in the area corresponding to the cloth image in the cloth to be detected.
The judgment of whether the pixel distribution is similar to the shape distribution of the seam or not can be realized by counting the number of black and white pixels in one embodiment; in another embodiment, the image similarity may also be determined by presetting a binarized seam image and calculating the similarity between the binarized image and the preset binarized seam image.
It should be noted that, for a certain area in the fabric, seam detection may be performed on the area first, and if there is a seam, flaw detection is not performed; if no seam exists, performing flaw detection; the flaw detection and the seam detection can be carried out simultaneously, and if the seam detection exists, even if the detection result has flaws in the flaw detection process, errors are not reported. Therefore, on one hand, the detection accuracy can be improved, and on the other hand, the detection efficiency can be improved.
Under the condition that the cloth seam detection device is provided with a plurality of cameras, image processing and pixel distribution statistics are respectively carried out on cloth images collected by each camera, if the judgment module 14 judges that at least two cloth images have seams in the cloth images collected at the same collecting moment, the seams in the areas corresponding to the cloth images in the cloth to be detected are determined, and misjudgment caused by the fact that the cloth has patterns similar to the seams is avoided.
In another embodiment, the judging module calls the counting module when judging that the seam exists in the area corresponding to the cloth image in the cloth to be detected, so that the counting module determines the number of the cloth in the cloth to be detected according to the judging result. Specifically, each judging module detects that a seam exists in the cloth to be detected, and then the seam is +1 on the basis of the original quantity. It can be understood that the initial value of the counting module is 1, and if the judging module detects that 1 seam exists, the counting module is 1+1, and it is determined that the cloth to be detected is formed by splicing 2 pieces of cloth.
In another embodiment, the number of pieces may correspond to the piece number of the piece, and is used to determine the piece number of the piece currently detected according to the number of the piece currently counted, for example, if the number of the piece currently counted is 5, the piece number of the piece currently detected is "005" (here, the representation of the piece number is only exemplified). Therefore, when each piece of cloth is detected, the cloth inspection report can be automatically generated according to the piece number of the cloth and the detection result.
Corresponding to the embodiment of the cloth seam detection device, the invention also provides an embodiment of a cloth seam detection method.
Fig. 4 is a flowchart illustrating a method for detecting a seam of a piece of cloth according to an exemplary embodiment of the present invention, where the method is implemented by using the cloth detecting apparatus illustrated in the above embodiment, and referring to fig. 4, the method includes the following steps:
step 401, collecting a cloth image of a cloth to be detected.
Step 402, converting the cloth image into a gray level image, and performing binarization processing on the gray level image.
And step 403, counting the pixel distribution of the image subjected to the binarization processing.
And step 404, judging whether a seam exists in the cloth to be detected according to the statistical result.
In another embodiment, before collecting the cloth image of the cloth to be detected, the method includes:
under the condition of receiving the detection request, controlling the cloth guiding and conveying equipment to guide the cloth to be detected from one end of the cloth guiding and conveying equipment to the other end of the cloth guiding and conveying equipment;
the cloth image of the cloth to be detected is collected, and the method comprises the following steps:
and in the process of guiding and conveying the cloth by the cloth guiding and conveying equipment, periodically collecting cloth images.
In another embodiment, collecting a cloth image of a cloth to be detected comprises:
collecting a plurality of cloth images of a target area in the cloth to be detected at the same collecting moment;
judging whether a seam exists in the cloth to be detected according to the statistical result, comprising the following steps:
and if at least two seams exist in the multiple cloth images according to the statistical result, determining that the seams exist in the target area.
In another embodiment, the cloth seam detection method further comprises:
and determining the number of the cloth to be detected according to the judgment result.
For the method embodiments, since they substantially correspond to the apparatus embodiments, reference may be made to the apparatus embodiments for relevant portions of the description.
Fig. 5 is a schematic diagram of an electronic device according to an exemplary embodiment of the present invention, and shows a block diagram of an exemplary electronic device 50 suitable for implementing an embodiment of the present invention. The electronic device 50 shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 5, the electronic device 50 may be embodied in the form of a general purpose computing device, which may be, for example, a server device. The components of the electronic device 50 may include, but are not limited to: the at least one processor 51, the at least one memory 52, and a bus 53 connecting the various system components (including the memory 52 and the processor 51).
The bus 53 includes a data bus, an address bus, and a control bus.
The memory 52 may include volatile memory, such as Random Access Memory (RAM)521 and/or cache memory 522, and may further include Read Only Memory (ROM) 523.
Memory 52 may also include a program tool 525 (or utility) having a set (at least one) of program modules 524, such program modules 524 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may comprise an implementation of a network environment.
The processor 51 executes various functional applications and data processing, such as the methods provided by any of the above embodiments, by running a computer program stored in the memory 52.
The electronic device 50 may also communicate with one or more external devices 54 (e.g., a keyboard, a pointing device, etc.). Such communication may be through an input/output (I/O) interface 55. Moreover, the model-generated electronic device 50 may also communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet) via a network adapter 56. As shown, network adapter 56 communicates with the other modules of model-generated electronic device 50 over bus 53. It should be appreciated that although not shown in the figures, other hardware and/or software modules may be used in conjunction with the model-generating electronic device 50, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (disk array) systems, tape drives, and data backup storage systems, etc.
It should be noted that although in the above detailed description several units/modules or sub-units/modules of the electronic device are mentioned, such a division is merely exemplary and not mandatory. Indeed, the features and functionality of two or more of the units/modules described above may be embodied in one unit/module according to embodiments of the invention. Conversely, the features and functions of one unit/module described above may be further divided into embodiments by a plurality of units/modules.
An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps of any one of the above-mentioned cloth seam detection methods.
While specific embodiments of the invention have been described above, it will be appreciated by those skilled in the art that this is by way of example only, and that the scope of the invention is defined by the appended claims. Various changes and modifications to these embodiments may be made by those skilled in the art without departing from the spirit and scope of the invention, and these changes and modifications are within the scope of the invention.