Disclosure of Invention
In order to solve the technical problems, the invention discloses a paper defect detection method, a paper defect detection device and a computer storage medium, aiming at solving the problems that in the prior art, the speed is low, the efficiency is low, the labor cost is high and the misjudgment rate is high due to the fact that the defect detection is carried out through a mode of observing the defects through manual vision.
In order to achieve the above object, the present invention discloses a paper defect detecting method, comprising:
shooting a color image of the paper to be detected;
carrying out image processing and feature extraction by adopting an Opencv algorithm and a Hough transformation method;
converting a color image of the paper to be detected into an HSV model, setting corresponding parameters through color characteristics of various flaws to extract different colors, and generating a corresponding binary image;
judging whether the corresponding color exists on the surface of the paper by calculating the number of white pixel points in the binary image, and further judging whether black spots, oil spots and holes exist;
graying, Gaussian blurring, graduating and binaryzation are carried out on the color image of the paper to be detected, isolated points and interference points are removed through functions, then expansion processing is carried out, finally, straight lines in the image are extracted through a Hough transformation method, and whether scratches exist or not is judged.
In one embodiment, the paper defect detecting method further includes: and summarizing the detection conditions of all the defects, and broadcasting the types and states of the detected paper defects by voice.
In one embodiment, a color image of the paper to be detected is converted into an HSV model, different colors are extracted by setting corresponding parameters according to color characteristics of various flaws, and a corresponding binary image is generated; the method comprises the following steps:
setting the dividing threshold of HSV values of various colors, and converting the RGB space model into an HSV space model;
searching for the color of different spots in the required interval, obtaining the required color information,
other unwanted colors are filtered to identify the defect type.
In one embodiment, the graying processing, filtering and denoising, image binarization processing, removing isolated points and interference points by a function, performing expansion processing, and finally extracting straight lines in the image by a Hough transform method to determine whether scratches exist or not includes:
carrying out gray processing on the color graph of the paper to be detected, selecting Gaussian kernel filtering and denoising, adopting a sobel operator to carry out edge extraction on the scratch defect, and judging whether the scratch edge point is the scratch edge point; carrying out binarization processing on the image, mapping the image to a Hough space, taking a local maximum value, setting a threshold value, and filtering an interference straight line; drawing a straight line, calibrating an angular point and detecting the scratch defect.
In one embodiment, the graying process comprises: carrying out Gray processing on the image by using a single-channel algorithm, and taking only G component in RGB three channels of each pixel point as a Gray value, wherein the Gray conversion formula is G.
In one embodiment, the edge extraction of the scratch defect by using the sobel operator includes:
carrying out weighted difference operation on gray values of upper, lower, left and right adjacent areas of each pixel in the image; the extreme value reached by the edge is used for realizing the detection of the edge;
calculating the convolution of the pixel in the x direction and the convolution of the pixel in the y direction according to the following formula 1 and formula 2;
wherein the convolution template of the Sobel operator is:
in one embodiment, the extracting the straight line in the image by the Hough transform method includes: carrying out binarization processing on the gradient image subjected to sobel operator processing again; recording the label of the inspection state of each pixel point, and removing isolated points and interference points; expanding the point-removed scratch binary image to enable the scratch characteristics to be more obvious; and (4) carrying out Hough linear detection on the expanded image to obtain a linear line of the scratch outline.
An embodiment of the present invention further provides a paper defect detecting system, where the system includes:
an image acquisition module: the color image shooting device is used for shooting a color image of the paper to be detected;
the image processing and feature extraction module: the method is used for image processing and feature extraction by adopting an Opencv algorithm and a Hough transformation method;
a defect detection module; the system comprises a color image acquisition module, a color image generation module, a color image acquisition module and a color image acquisition module, wherein the color image acquisition module is used for acquiring color images of paper to be detected;
judging whether the corresponding color exists on the surface of the paper by calculating the number of white pixel points in the binary image, and further judging whether black spots, oil spots and holes exist;
graying, Gaussian blurring, graduating and binaryzation are carried out on a color image of the paper to be detected, isolated points and interference points are removed through functions, then expansion processing is carried out, finally, straight lines in the image are extracted through a Hough transformation method, and whether scratches exist or not is judged;
voice broadcast module: the method is used for summarizing the detection conditions of all the defects and broadcasting the types and states of the detected paper defects through voice.
An embodiment of the present invention further provides a paper defect detecting apparatus, including: the system comprises an AM5708 main control chip, an RS232 driving chip, a voice broadcasting module, a NAND Flash memory, an RAM chip, an HDMI interface protection chip, an HDMI display, a PHY chip, a network port, an SD card, a camera, a mouse, a keyboard, a relay module and a light source;
the voice broadcasting module is electrically connected with the AM5708 main control chip through an RS232 driving chip;
the NAND Flash memory is electrically connected with the AM5708 main control chip;
the RAM chip is electrically connected with the AM5708 main control chip;
the HDMI display is electrically connected with the AM5708 main control chip through an HDMI interface protection chip;
the network port is electrically connected with the AM5708 main control chip through the PHY chip;
the SD card is electrically connected with the AM5708 main control chip;
the camera is electrically connected with the AM5708 main control chip through a USB interface;
the mouse and the keyboard are electrically connected with the AM5708 main control chip through a USB interface;
the light source is electrically connected with the AM5708 main control chip through the relay module;
the voice broadcast module includes: the device comprises a controller, a serial port transceiving module, a voice synthesis module, a voice line output module, a power amplifier and a loudspeaker;
the AM5708 main control chip stores program instructions and executes any one of the paper defect detection methods.
Embodiments of the present invention also provide a computer-readable storage medium, in which a computer program is stored, where the computer program includes program instructions, and the program instructions, when executed by a processor, execute any one of the foregoing paper defect detection methods.
The embodiment of the invention has the following beneficial effects:
the invention provides a paper defect detection method, which adopts a machine vision surface detection method based on Opencv, uses different detection methods aiming at different defect types, and detects the paper defects of black spots, oil spots and holes by extracting color characteristics; aiming at the scratched paper defects, a defect image is acquired through an image acquisition system, the image is preprocessed firstly, the preprocessing comprises gray processing and median filtering, the shape features are extracted by adopting a Hough transformation method and are matched, and finally the defects are identified and classified, so that the detection efficiency is high, the labor cost is low, and the detection accuracy is high. The problem of among the prior art paper defect's detection pass through artifical visual inspection defect mode, it is slow, inefficiency, the cost of labor is high, the erroneous judgement rate is high is solved.
According to the paper defect detection device provided by the embodiment of the invention, under the illumination of a light source, a paper defect is shot by a camera, an optical signal is converted into an electric signal and then converted into a signal processed by a computer, the signal is transmitted to an AM5708 main control chip for identifying the paper defect, and an HDMI (high definition multimedia interface) displayer is used for displaying the type, position, size and shape of the defect; defects of mouse and keyboard control calibration; the network port is used for connecting the device with a network and transmitting defect data; the voice broadcast module is used for broadcasting the paper defect kind that discerns, adopts AM5708 main control chip can reduce industrial controller's size to smart mobile phone that is so big or small, carries out image processing through the image of shooting at the ARM platform, judges to detect and detects whether there is the defect in the paper, and the embedded architecture scheme that this system adopted compares in PC platform consumption and cost lower, detection efficiency is higher, the cost of labor is lower, and it is higher to detect the rate of accuracy.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or server that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Referring to fig. 1, in order to achieve the above object, the present invention provides a method for detecting a paper defect, including:
the invention discloses a paper defect detection method, which comprises the following steps:
s101, shooting a color image of paper to be detected;
s102, image processing and feature extraction are carried out by adopting an Opencv algorithm and a Hough transformation method;
s103, converting the color image of the paper to be detected into an HSV model, setting corresponding parameters through the color characteristics of various flaws to extract different colors, and generating a corresponding binary image;
the image is first converted from the RGB color space to a visually equalized color space (e.g., HSV space) and the color space is quantized into bins. The image is then divided into regions using a color segmentation technique, each region being indexed by a color component of the quantized color space, thereby expressing the image as a binary set of color indices. In image matching, the distances between different image color sets and the spatial relationship of the color regions are compared. Because the color set is expressed as a binary characteristic vector, the retrieval speed is accelerated, and the method is very beneficial to the real-time detection of paper defects;
s104, judging whether the corresponding color exists on the surface of the paper by calculating the number of white pixel points in the binary image, and further judging whether black spots, oil spots and holes exist;
and S105, graying, Gaussian blurring, graduating and binaryzation are carried out on the color image of the paper to be detected, isolated points and interference points are removed through functions, then expansion processing is carried out, finally, straight lines in the image are extracted through a Hough transformation method, and whether scratches exist is judged.
In one illustrative embodiment, the paper defect detection method further includes: and summarizing the detection conditions of all the defects, and broadcasting the types and states of the detected paper defects by voice.
As shown in fig. 5 and fig. 6, in an embodiment of the specification, a color image of a paper to be tested is converted into an HSV model, different colors are extracted by setting corresponding parameters according to color characteristics of various flaws, and a corresponding binary image is generated; the method comprises the following steps:
setting the dividing threshold of HSV values of various colors, and converting the RGB space model into an HSV space model;
searching for the color of different spots in the required interval, obtaining the required color information,
other unwanted colors are filtered to identify the defect type.
For example, the color of different spot colors within a required interval is found, the paper to be detected is placed under a blue background, the black spot index color is black, the oil spot index color is orange (the oil spot is generally orange or yellow), and the hole index color is blue (the currently selected background is blue, and once a hole exists, the hole area is the background color).
As shown in fig. 7 to 13, in an embodiment of the specification, the graying, filtering, denoising, image binarization, removing isolated points and interference points by a function, performing dilation, and finally extracting a straight line in the image by a Hough transform method to determine whether there is a scratch includes:
carrying out gray processing on the color graph of the paper to be detected, selecting Gaussian kernel filtering and denoising, adopting a sobel operator to carry out edge extraction on the scratch defect, and judging whether the scratch edge point is the scratch edge point; carrying out binarization processing on the image, mapping the image to a Hough space, taking a local maximum value, setting a threshold value, and filtering an interference straight line; drawing a straight line, calibrating an angular point, and detecting a scratch defect;
before Hough transformation detection is carried out on a scratch defect image, preprocessing work needs to be carried out on an acquired original image in advance, the requirement of Hough linear transformation on image processing is met, the image quality is improved, unnecessary image features are filtered, the data volume of Hough transformation detection processing is reduced, and the requirements on accurate identification and system real-time performance are met.
In one illustrative embodiment, the graying process comprises: carrying out Gray processing on the image by using a single-channel algorithm, and taking only G component in RGB three channels of each pixel point as a Gray value, wherein the Gray conversion formula is G.
In an embodiment of the specification, the edge extraction of the scratch defect by using a sobel operator includes:
carrying out weighted difference operation on gray values of upper, lower, left and right adjacent areas of each pixel in the image; the extreme value reached by the edge is used for realizing the detection of the edge;
calculating the convolution of the pixel in the x direction and the convolution of the pixel in the y direction according to the following formula 1 and formula 2;
wherein the convolution template of the Sobel operator is:
in one illustrative embodiment, the extracting straight lines in the image by the Hough transform method includes: carrying out binarization processing on the gradient image subjected to sobel operator processing again; recording the label of the inspection state of each pixel point, and removing isolated points and interference points; expanding the point-removed scratch binary image to enable the scratch characteristics to be more obvious; hough straight line detection can be carried out on the expanded image to obtain a straight line of the scratch outline;
the expansion is an operation of solving a local maximum, as shown in fig. 14, which is an expansion schematic diagram, where a kernel B is convolved with a graph, that is, a maximum value of a pixel point in a region covered by the kernel B is calculated, and the maximum value is assigned to a pixel specified by a reference point, so that a highlight region in an image is gradually increased.
As shown in fig. 2, an embodiment of the present invention further provides a paper defect detecting system, including:
an image acquisition module: the color image shooting device is used for shooting a color image of the paper to be detected;
the image processing and feature extraction module: the method is used for image processing and feature extraction by adopting an Opencv algorithm and a Hough transformation method; a defect detection module; the system comprises a color image acquisition module, a color image generation module, a color image acquisition module and a color image acquisition module, wherein the color image acquisition module is used for acquiring color images of paper to be detected; judging whether the corresponding color exists on the surface of the paper by calculating the number of white pixel points in the binary image, and further judging whether black spots, oil spots and holes exist; graying, Gaussian blurring, graduating and binaryzation are carried out on a color image of the paper to be detected, isolated points and interference points are removed through functions, then expansion processing is carried out, finally, straight lines in the image are extracted through a Hough transformation method, and whether scratches exist or not is judged;
voice broadcast module: the method is used for summarizing the detection conditions of all the defects and broadcasting the types and states of the detected paper defects through voice.
As shown in fig. 3 and 4, an embodiment of the present invention further provides a paper defect detecting apparatus, including:
1-1 part of an AM5708 main control chip, 1-2 parts of an RS232 driving chip, 1-3 parts of a voice broadcasting module, 1-4 parts of an NAND Flash memory, 1-5 parts of an RAM chip, 1-6 parts of an HDMI interface protection chip, 1-7 parts of an HDMI display, 1-8 parts of a PHY chip, 1-9 parts of a network interface, 1-10 parts of an SD card, 1-12 parts of a camera, 1-11 parts of a mouse, 1-11 parts of a keyboard, 1-13 parts of a relay module and 1-14 parts of a light source;
the voice broadcasting module 1-3 is electrically connected with the AM5708 main control chip 1-1 through an RS232 driving chip 1-2;
the NAND Flash memory 1-4 is electrically connected with the AM5708 main control chip 1-1;
the AM5708 main control chip can be selected from: the industrial core board is an AM5708, AM5708 industrial core board, and integrates TI DSP C66x + ARM Cortex-A15 industrial control and a programmable audio/video processor;
the model of the NAND Flash memory 1-4 can be a three-star NAND Flash K9K8G08U 0M;
the NAND Flash memories 1-4 are nonvolatile memories for storing programs and data;
the RAM chip 1-5 is electrically connected with the AM5708 main control chip 1-1;
the type of the RAM chip 1-5 can be Samsung K4B4G 1646B;
the HDMI display 1-7 is electrically connected with the AM5708 main control chip 1-1 through an HDMI interface protection chip 1-6;
the HDMI interface protection chips 1-6 can be selected from the following chip types: a CM 2020;
the network ports 1-9 are electrically connected with an AM5708 main control chip 1-1 through PHY chips 1-8; for performing detection device data networking
The SD card 1-10 is electrically connected with the AM5708 main control chip 1-1;
the camera 1-12 is electrically connected with the AM5708 main control chip 1-1 through a USB interface and used for shooting paper defects;
the mouse and the keyboard 1-11 are electrically connected with the AM5708 main control chip 1-1 through a USB interface and used for defect image control and calibration;
the light sources 1-14 are electrically connected with an AM5708 main control chip 1-1 through relay modules 1-13, and the light sources 1-14 are used for assisting the cameras 1-12 in shooting defects; the AM5708 main control chip 1-1 controls the cameras 1-12 to shoot the paper defects through the relay modules 1-13.
In an embodiment of the specification, the voice broadcasting module 1-3 includes: the device comprises a controller 2-1, a serial port transceiving module 2-2, a voice synthesis module 2-3, a voice line output module 2-4, a power amplifier 2-5 and a loudspeaker 2-6;
the voice broadcasting module can select a SYN6288 chip of science and technology Limited company under Beijing Yuyin heaven.
In one illustrative embodiment, the light sources 1-14 may be:
annular light sources, dome light sources, coaxial light sources, parallel backlights, annular shadowless light sources.
In an embodiment of the specification, the AM5708 main control chip stores program instructions to execute any one of the above-described paper defect detection methods.
Embodiments of the present invention also provide a computer-readable storage medium, in which a computer program is stored, where the computer program includes program instructions, and the program instructions, when executed by a processor, execute any one of the foregoing paper defect detection methods.
The embodiment of the invention has the following beneficial effects:
the invention provides a paper defect detection method, which adopts a machine vision surface detection method based on Opencv, uses different detection methods aiming at different defect types, and detects the paper defects of black spots, oil spots and holes by extracting color characteristics; aiming at the scratched paper defects, a defect image is acquired through an image acquisition system, the image is preprocessed firstly, the preprocessing comprises gray processing and median filtering, the shape features are extracted by adopting a Hough transformation method and are matched, and finally the defects are identified and classified, so that the detection efficiency is high, the labor cost is low, and the detection accuracy is high. The problem of among the prior art paper defect's detection pass through artifical visual inspection defect mode, it is slow, inefficiency, the cost of labor is high, the erroneous judgement rate is high is solved.
According to the paper defect detection device provided by the embodiment of the invention, under the illumination of a light source, a paper defect is shot by a camera, an optical signal is converted into an electric signal and then converted into a signal processed by a computer, the signal is transmitted to an AM5708 main control chip for identifying the paper defect, and an HDMI (high definition multimedia interface) displayer is used for displaying the type, position, size and shape of the defect; defects of mouse and keyboard control calibration; the network port is used for connecting the device with a network and transmitting defect data; the voice broadcast module is used for broadcasting the paper defect kind that discerns, adopts AM5708 main control chip can reduce industrial controller's size to smart mobile phone that is so big or small, carries out image processing through the image of shooting at the ARM platform, judges to detect and detects whether there is the defect in the paper, and the embedded architecture scheme that this system adopted compares in PC platform consumption and cost lower, detection efficiency is higher, the cost of labor is lower, and it is higher to detect the rate of accuracy.
It should be noted that: the precedence order of the above embodiments of the present invention is only for description, and does not represent the merits of the embodiments. And specific embodiments thereof have been described above. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the device and server embodiments, since they are substantially similar to the method embodiments, the description is simple, and the relevant points can be referred to the partial description of the method embodiments.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
While the invention has been described in connection with what is presently considered to be the most practical and preferred embodiment, it is to be understood that the invention is not to be limited to the disclosed embodiment, but on the contrary, is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.