Summary of the invention
In view of this, the application provides detection method of surface flaw, device, equipment and the storage medium of a kind of moulding,
It is intended to be promoted the detection efficiency and accuracy of moulding surface defect.
To achieve the above object, the application first aspect provides a kind of defect inspection method of moulding, comprising:
Acquire the product picture of moulding;
First pretreatment is carried out to the product picture, obtains picture to be detected;
The picture to be detected is detected using detection model trained in advance, obtains the moulding surface with the presence or absence of scarce
Sunken testing result.
Optionally, described that first pretreatment is carried out to the product picture, obtain picture to be detected, comprising:
Gray scale and binary conversion treatment are carried out to the product picture, obtain picture to be detected.
Optionally, described that gray scale and binary conversion treatment are carried out to product picture, obtain picture to be detected, comprising:
Separate the three primary colors of each pixel in the product picture;
The three primary colors of each pixel are weighted, the gray value of each pixel is obtained;
Judge whether the gray value is more than gray value threshold value;
If the determination result is YES, then the first preset value is set by corresponding pixel;
If judging result be it is no, set the second preset value for corresponding pixel.
Optionally, the method also includes:
The first sample picture of the tape label of moulding is obtained, the label includes for identifying the first sample picture
Moulding whether there is defect;
Second pretreatment is carried out to the first sample picture, obtains the second samples pictures of tape label, second sample
The label of this picture is identical as the label of corresponding first sample picture;
Second samples pictures are trained, the detection model is obtained.
Optionally, the second pretreatment is carried out to the first sample picture, obtains the second samples pictures of tape label, wrapped
It includes:
Generate the deformation picture of the first sample picture, the label of the deformation picture and corresponding first sample picture
Label it is identical;
Gray scale and binary conversion treatment are carried out to the deformation picture, obtain the second samples pictures.
Optionally, the deformation picture for generating the first sample picture, comprising:
According to default bias unit, each first sample picture is displaced, obtains the position of each first sample picture
Move picture;
According to default rotation angle angle, each displacement picture is rotated, each first sample picture is obtained
Rotating image;
According to pre-set zoom ratio, each rotating image is zoomed in and out, obtains the contracting of each first sample picture
Put picture.
Optionally, second samples pictures are trained, obtain the detection model, comprising:
According to default division proportion, trained picture and test picture are divided into after second samples pictures are upset;
The trained picture is trained, initial model is obtained;
Using initial model described in the test chart built-in testing, the accuracy rate of the initial model is obtained;
When the accuracy rate is less than default accuracy rate, initial model is further trained;
When the accuracy rate is not less than default accuracy rate, using corresponding initial model as detection model.
To achieve the above object, the application second aspect provides a kind of defect detecting device of moulding, comprising:
Acquisition module, for acquiring the product picture of moulding;
First preprocessing module obtains picture to be detected for carrying out the first pretreatment to the product picture;
Detection module obtains the moulding for detecting the picture to be detected using detection model trained in advance
Surface whether there is the testing result of defect.
To achieve the above object, the application third aspect provides a kind of electronic equipment, comprising: memory and processor;
It is stored with computer program on the memory, when the computer program is executed by the processor, is realized
Method as described in the application first aspect.
To achieve the above object, the application fourth aspect provides a kind of computer readable storage medium, is stored thereon with meter
Calculation machine program realizes the method as described in the application first aspect when the computer program is executed by processor.
In the technical solution of the application, by advance combining computer vision with neural network, detection model is obtained,
And the first pretreatment is carried out to the product picture of the moulding of acquisition and obtains detection picture, to use detection model to figure to be detected
Piece is detected, and realizing moulding surface whether there is the quick and precisely detection of defect;Which effective solution is current
Manual Visual Inspection can be because of the problem of extraneous factors such as the emotional change of testing staff lead to detection error and traditional computer vision
Low compatibility and the problem of new demand cannot be rapidly adapted to;Meanwhile corporate training and management cost are greatly reduced, effectively
Defect ware is avoided to come into the market the problem of bringing loss to enterprise.
Specific embodiment
The illustrative embodiments of the disclosure are more fully described below with reference to accompanying drawings.Although showing this public affairs in attached drawing
The illustrative embodiments opened, it being understood, however, that may be realized in various forms the disclosure without the reality that should be illustrated here
The mode of applying is limited.It is to be able to thoroughly understand the disclosure on the contrary, providing these embodiments, and can be by this public affairs
The range opened is fully disclosed to those skilled in the art.
Attached drawing 1 is a kind of flow chart of the detection method of surface flaw for moulding that some embodiments of the application provide, such as
Shown in Fig. 1, the defect inspection method of moulding includes:
Step 101: acquiring the product picture of moulding;
Specifically, passing through the product picture that computer vision apparatus shoots moulding, wherein computer vision apparatus includes
Light source, softbox, camera lens, industrial camera, controller etc..In the application, the various injecting products that injection molding machine produces are referred to as
Moulding.In the production process of moulding, often due to raw material selection, temperature setting, technological design, human error etc.
And surface defect is generated, such as edge missing, dent, scratch, current mark.By acquiring the product picture of moulding, subsequent
By handling the product picture, obtaining the moulding that product picture includes whether there is the testing result of defect.
Step 102: the first pretreatment being carried out to the product picture of acquisition, obtains picture to be detected;
In some embodiments of the present application, step 102 includes: to carry out at gray scale and binaryzation to the product picture of acquisition
Reason, obtains picture to be detected.
Further, gray scale and binary conversion treatment are carried out to the product picture of acquisition, obtain picture to be detected, comprising:
Step A1: the three primary colors of each pixel in the product picture of acquisition are separated;
Specifically, separating the value of three kinds of colors of red, green, blue of each pixel in the product picture of acquisition.
Step A2: being weighted the three primary colors of each pixel, obtains the gray value of each pixel;
Specifically, according to the weight of preset three kinds of colors of red, green, blue, to three kinds of face of red, green, blue of each pixel
The value of color is weighted, and obtains the gray value of each pixel.Wherein, the weight of three kinds of colors of red, green, blue can be in reality
Sets itself as needed in the application of border;For example, red weight is 0.3, green weight is 0.6, and blue weight is
0.11, the gray value of each pixel can be expressed as gray=0.3*r+0.6*g+0.11*b, wherein r is isolated red
Value, g is the value of the green of separation, and b be the blue value of separation.
Step A3: whether the gray value for judging each pixel is more than gray value threshold value, if the determination result is YES, then will be right
The pixel answered is set as the first preset value;If judging result be it is no, set the second preset value for corresponding pixel.
Wherein, gray value threshold value is the critical value of binaryzation, and the first preset value indicates that corresponding pixel is black, the
Two preset values indicate that corresponding pixel is white.First preset value and the second preset value can in practical applications as needed
Sets itself, for example, the first preset value is 1, the second preset value is 0.
Step 103: picture to be detected being detected using detection model trained in advance, obtains moulding surface with the presence or absence of scarce
Sunken testing result.
In the application, computer vision is combined in advance with neural network, it is scarce to obtain having for the same position of moulding
Sunken picture and do not have defective picture, and the picture of acquisition is trained, obtains detection model;The mapping to be checked that will be obtained
Piece is input to the detection model and is detected, and obtaining moulding whether there is the testing result of defect.Wherein, the instruction of detection model
Practice process to be described in detail later.
As a result, by advance combining computer vision with neural network, detection model, and the injection molding to acquisition are obtained
The product picture of part carries out the first pretreatment and obtains detection picture, to be detected using detection model to detection picture, realizes
Moulding whether there is the quick and precisely detection of defect;The current manual's visual inspection of which effective solution can because of testing staff
The extraneous factors such as emotional change the problem of leading to detection error and the low compatibility of traditional computer vision and cannot quickly fit
The problem of answering new demand;Meanwhile corporate training and management cost are greatly reduced, it effectively avoids defect ware and comes into the market
The problem of bringing loss to enterprise.
Based on aforementioned any embodiment, in some embodiments of the present application, method further includes trained detection model;Specifically
, training process schematic diagram as shown in Figure 2, including following operation:
Step B1: the first sample picture of the tape label of moulding is obtained, wherein label is for identifying first sample picture
Including moulding whether there is defect;
Specifically, shooting the figure of the same position existing defects of moulding by computer vision apparatus such as industrial cameras
Piece and picture there is no defect, and manually mark the moulding in each picture and whether there is the label of defect, obtain first
Samples pictures.It should be pointed out that for for lack material moulding, lack material region background as far as possible it is pure not have it is variegated;It is right
In the scratch, flow liner the defects of, it should be noted that reasonable polishing, it is ensured that defect can clearly reflect in the picture taken;Meanwhile when shooting
It should be noted that keeping the angles and positions of moulding in every picture consistent or approximate as far as possible.
In some embodiments of the present application, to reduce the training time of subsequent detection model training, improving prediction accurately
Rate can also mark " area-of-interest " in each first sample picture, be somebody's turn to do " area-of-interest " i.e. surface defect and often go out
Existing place, the region other than " area-of-interest " can then be ignored in the training process.
Step B2: the second pretreatment is carried out to first sample picture, the second samples pictures of tape label are obtained, wherein second
The label of samples pictures is identical as the label of corresponding first sample picture;
In some embodiments of the present application, step B2 includes:
Step B2-1: the deformation picture of first sample picture is generated, wherein the label of deformation picture and corresponding first sample
The label of this picture is identical;
In some embodiments of the present application, step B2-1 includes:
Step C1: according to default bias unit, each first sample picture is displaced, obtains each first sample figure
The displacement picture of piece;
Specifically, after each first sample picture is directed into coordinate system, according to preset offset coordinates mobile first
Samples pictures obtain at least one displacement picture of each first sample picture.
For example, preset offset coordinates be (- 25, -25), (- 25, -24), (- 25, -23) ... (- 25 ,+25), (- 24, -
25), (- 24, -24), (- 24, -23) ... (- 24 ,+25), (- 23, -25), (- 23, -24), (- 23, -23) ... (- 23 ,+25) ...
First sample picture is moved -25 pictures by (+25, -25), (+25, -24) (+25, -23) ... (+25 ,+25) etc. on transverse axis
Element moves -25 pixels on longitudinal axis, obtains first displacement picture of first sample picture;By first sample picture in cross
- 25 pixels are moved on axis, move -24 pixels on longitudinal axis, second displacement picture of first sample picture are obtained, with this
Analogize, until first sample picture is moved+25 pixels on transverse axis, moves+25 pixels on longitudinal axis, obtain the first sample
The last one displacement picture of this picture;Wherein, label and the label phase of corresponding first sample picture of each displacement picture
Together, and it is denoted as original tag.
Step C2: according to default rotation angle angle, each displacement picture is rotated, each first sample picture is obtained
Rotating image;
Specifically, each displacement picture is rotated around its central point, obtains each first sample according to preset rotation angle
The rotating image of this picture.
Wherein, preset rotation angle can sets itself as needed in practical applications, such as rotation angle be-
5, some displacement picture is obtained corresponding first sample picture around -5 degree of its central point rotation by -4, -3 ...+4 ,+5 degree
First rotating image obtains second of corresponding first sample picture by the displacement picture around -4 degree of its central point rotation
Rotating image obtains the third rotation figure of corresponding first sample picture by the displacement picture around -3 degree of its central point rotation
Piece, and so on, until the displacement picture is obtained last of corresponding first sample picture around+5 degree of its central point rotation
A rotating image;Wherein, the label of each rotating image is identical as the label of corresponding first sample picture, and is denoted as original mark
Label.
Step C3: according to pre-set zoom ratio, zooming in and out each rotating image, obtains each first sample picture
Scaling pictures.
Specifically, point is to each rotating image on the basis of the central point of each rotating image according to pre-set zoom ratio
Whole scaling is carried out, the scaling pictures of corresponding each first sample picture are obtained.
Wherein, pre-set zoom ratio can in practical applications, sets itself as needed;Such as pre-set zoom ratio is
0.90,0.91,0.92 ... 1.11, wherein the ratio less than 1 is diminution ratio, the ratio greater than 1 is magnification ratio, i.e., by some
Rotating image reduces 0.90 times, obtains first diminution picture of corresponding first sample picture, which is reduced
0.91 times, second diminution picture of corresponding first sample picture is obtained, and so on, until the rotating image is expanded
1.11 times, obtain the last one amplification picture of corresponding first sample picture;Wherein, the label of each scaling pictures with it is corresponding
First sample picture label it is identical, and be denoted as original tag.
By generating displacement picture, rotating image and the scaling pictures of each first sample picture, on the one hand effectively keep away
Exempt to shoot the picture of the same position existing defects of moulding in use computer vision apparatus and there is no the pictures of defect
During, cause moulding included by the picture of shooting to be subjected to displacement and light because of the swing of the mechanical arm of equipment
The factors such as strong and weak difference, and cause trained detection model accuracy rate decline the problem of;So that the detection model that training obtains
Mobile to the small range of moulding and light change has good compatibility.On the other hand, according to a small amount of first sample
Picture generates the training sample that largely can be used as following model training, reduces the acquisition time of training sample.
Step B2-2: gray scale and binary conversion treatment are carried out to the deformation picture of generation, obtain the second samples pictures.
Specifically, carrying out gray scale and binary conversion treatment to each deformation picture of each first sample picture, and will processing
Each picture afterwards is as the second samples pictures.Wherein, the process of gray scale and binary conversion treatment can be found in abovementioned steps A1 to step
Process described in rapid A3, details are not described herein.
Step B3: the second samples pictures are trained, detection model is obtained.
In some embodiments of the present application, step B3 includes:
Step B3-1: according to default division proportion, trained picture and test chart are divided into after the second samples pictures are upset
Piece;
Wherein, preset ratio can according to need sets itself in practical applications, such as preset division proportion is 8:
2, that is, 80% in the second samples pictures is chosen as training picture, and 20% as test picture.
Step B3-2: training picture is trained, initial model is obtained;
Specifically, training picture and its original tag are input to neural network, pass through the convolutional layer of neural network, Quan Lian
It connects layer and pond layer etc. to learn the label of training picture and training picture, obtains initial model.
Step B3-3: test chart built-in testing initial model is used, the accuracy rate of initial model is obtained, when accuracy rate is not less than
When default accuracy rate, using corresponding initial model as detection model;If being less than default accuracy rate, need to initial model into
The further training of row.
Specifically, when being trained to obtain initial model to training picture every time, it will be without the test chart of original tag
Piece is input in initial model and is predicted, obtains the prediction label of test picture, will test the original tag and prediction of picture
Label compares, and obtains the number for comparing consistent prediction label, number and prediction label of the calculating ratio to consistent prediction label
The ratio of total number obtains the accuracy rate of initial model;Judge whether obtained accuracy rate is not less than default accuracy rate, and is sentencing
Disconnected result is when being, using current initial model as trained obtained detection model;If judging result is no, to introductory die
Type is further trained.
As a result, by combining computer vision with neural network, the deformation picture of each first sample picture is generated,
Gray scale is carried out to deformation picture and binary conversion treatment obtains the second samples pictures, and based on the training of the second samples pictures for detecting
The moulding that product picture includes whether there is the detection model of defect, so that the detection model that training obtains is to note to be detected
The mobile change with light of the small range of plastic has good compatibility.In turn, the surface for needing to detect moulding whether
When existing defects, acquires the product picture of moulding and the first pretreatment of progress obtains after detecting picture, using the detection model
Detection picture is detected, moulding, which can be realized, whether there is the quick and precisely detection of defect;It can not only effectively solve
Certainly current manual's visual inspection can be because of the problem of extraneous factors such as the emotional change of testing staff lead to detection error and traditional calculations
The low compatibility of machine vision and the problem of new demand cannot be rapidly adapted to;And corporate training and management cost are greatly reduced,
Effectively defect ware is avoided to come into the market the problem of bringing loss to enterprise.
It is the defect inspection method of a moulding provided by the embodiments of the present application above, corresponds to the above method, this
Invention also provides a kind of defect detecting device of moulding, the implementation and above method phase solved the problems, such as due to described device
Seemingly, therefore the content with method partial response, the detailed description that reference can be made to the above method embodiment are subsequent not repeat them here.It can
With understanding, device provided by the present application may include the unit or mould for being able to carry out each step in above method example
Block, these units or module can realize that the present invention does not limit by way of hardware, software or soft or hard combination.Below
It is specifically described in conjunction with attached drawing 3.
Attached drawing 3 is a kind of surface defect detection apparatus for moulding that some embodiments of the application provide, as shown in figure 3,
The defect detecting device of moulding includes:
Acquisition module 201, for acquiring the product picture of moulding;
First preprocessing module 202, the product picture for acquiring to acquisition module 201 carry out the first pretreatment, obtain
Picture to be detected;
Detection module 203, the mapping to be checked for being obtained using detection model detection preprocessing module 202 trained in advance
Piece, obtaining moulding surface whether there is the testing result of defect.
In some embodiments of the present application, preprocessing module 202 is specifically used for:
Gray scale and binary conversion treatment are carried out to product picture, obtain picture to be detected.
In some embodiments of the present application, preprocessing module 202 is specifically used for:
Separate the three primary colors of each pixel in product picture;
The three primary colors of each pixel are weighted, the gray value of each pixel is obtained;
Judge whether gray value is more than gray value threshold value;
If the determination result is YES, then the first preset value is set by corresponding pixel;
If judging result be it is no, set the second preset value for corresponding pixel.
In some embodiments of the present application, device further include:
Module 204 is obtained, the first sample picture of the tape label for obtaining moulding, wherein label is for identifying first
The moulding that samples pictures include whether there is defect;
Second preprocessing module 205 obtains the second sample of tape label for carrying out the second pretreatment to first sample picture
This picture, wherein the label of the second samples pictures is identical as the label of corresponding first sample picture;
Training module 206 obtains detection model for being trained to the second samples pictures.
In some embodiments of the present application, the second preprocessing module 205 includes:
Generate submodule, for generating the deformation picture of first sample picture, wherein the label of deformation picture with it is corresponding
The label of first sample picture is identical;
Submodule is pre-processed, for carrying out gray scale and binary conversion treatment to deformation picture, obtains the second sample of tape label
Picture.
In some embodiments of the present application, generates submodule and is specifically used for:
According to default bias unit, each first sample picture is displaced, obtains the position of each first sample picture
Move picture;
According to default rotation angle angle, each displacement picture is rotated, the rotation of each first sample picture is obtained
Picture;
According to pre-set zoom ratio, each rotating image is zoomed in and out, obtains the scaling figure of each first sample picture
Piece.
In some embodiments of the present application, training module 206 is specifically used for:
According to default division proportion, the second samples pictures are divided into trained picture and test picture;
Training picture is trained, initial model is obtained;
Using test chart built-in testing initial model, the accuracy rate of initial model is obtained;
When accuracy rate is not less than default accuracy rate, using corresponding initial model as detection model.
The defect detecting device of moulding provided by the embodiments of the present application, the defect of the moulding provided with previous embodiment
Detection method has the same effect for identical inventive concept.
The application embodiment also provides a kind of defect inspection method pair with moulding provided by aforementioned embodiments
The electronic equipment answered, the electronic equipment can be server, including independent server and distributed server cluster etc.;The electricity
Sub- equipment can also be electronic equipment for client, such as mobile phone, laptop, tablet computer, desktop computer etc.,
To execute the defect inspection method of above-mentioned moulding.
If Fig. 4 is the schematic diagram of a kind of electronic equipment that some embodiments of the application provide, as shown in Figure 4, comprising: storage
Device 301, processor 302, bus 303 and communication interface 304;
Wherein, memory 301, processor 302 and communication interface 304 are connected by bus 303;It is stored in memory 301
There is the computer program that can be run on processor 302, when processor 302 executes when running the computer program, realizes aforementioned
The defect inspection method of moulding provided by any embodiment.
Further, memory 301 may include high-speed random access memory (RAM:Random Access
It Memory), can also further include non-labile memory (non-volatile memory), a for example, at least disk is deposited
Reservoir.
Processor 302 can be a kind of IC chip, the processing capacity with signal.It is above-mentioned during realization
Each step of method can be completed by the integrated logic circuit of the hardware in processor 302 or the instruction of software form.Place
Reason device 302 can also be general processor, including central processing unit (Central Processing Unit, abbreviation CPU), net
Network processor (Network Processor, abbreviation NP) etc.;It can also be digital signal processor (DSP), specific integrated circuit
(ASIC), ready-made programmable gate array (FPGA) either other programmable logic device, discrete gate or transistor logic,
Discrete hardware components.
Bus 303 can be ISA (English: Industry Standard Architecture;Chinese: industrial standard body
Architecture) bus, PCI (English: Peripheral Component Interconnect;Chinese: Peripheral Component Interconnect standard)
Bus or EISA (English: Extended Industry Standard Architecture;Chinese: extension industrial standard knot
Structure) bus etc..
The defect inspection method of electronic equipment provided by the embodiments of the present application and moulding provided by the embodiments of the present application goes out
In identical inventive concept, there is the identical beneficial effect of the method for using, running or realizing with it.
The embodiment of the present application also provides a kind of corresponding with the defect inspection method of moulding provided by aforementioned embodiments
Computer-readable medium, be stored thereon with computer program (i.e. program product), which runs by processor
When, realize the defect inspection method of moulding provided by aforementioned any embodiment.
Wherein, computer readable storage medium includes but is not limited to phase change memory (PRAM), static random access memory
(SRAM), dynamic random access memory (DRAM), other kinds of random access memory (RAM), read-only memory
(ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other optics, magnetic-based storage media, herein
No longer repeat one by one.
The defect of computer readable storage medium provided by the embodiments of the present application and moulding provided by the embodiments of the present application
Detection method has the method for using, running or realizing with the application program that it is stored identical for identical inventive concept
Beneficial effect.
It should be understood that
Herein, the terms "include", "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, from
And to include process, method, article or the system of a series of elements not only to include those elements, but also including not bright
The other element really listed, or further include for this process, method, article or the intrinsic element of system.Do not having
In the case where more limitations, the element that is limited by sentence "including a ...", it is not excluded that including process, the side of the element
There is also other identical elements in method, article or system.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment side
Method can be realized by means of software and necessary general hardware platform, naturally it is also possible to by hardware, but in many cases
The former is more preferably embodiment.Based on this understanding, technical solution of the present invention substantially in other words does the prior art
The part contributed out can be embodied in the form of software products, which is stored in one as described above
In storage medium (such as ROM/RAM, magnetic disk, CD), including some instructions are used so that terminal device (it can be mobile phone,
Computer, server or network equipment etc.) execute method described in each embodiment of the present invention.
The preferable specific embodiment of the above, only the application, but the protection scope of the application is not limited thereto, and is appointed
Within the technical scope of the present application, any changes or substitutions that can be easily thought of, all by what those familiar with the art
It should cover within the scope of protection of this application.Therefore, the protection scope of the application should be subject to the protection scope in claims.