Invention content
The main object of the present invention is to provide a kind of lead size detecting method, device and computer readable storage medium,
Aim to solve the problem that the lead size detection difficulty under background colour phase near-ambient in the prior art is big, the high problem of False Rate.
To achieve the above object, the present invention provides a kind of lead size detecting method, the lead size detecting method packet
Include following steps:
When detecting that product to be detected reaches detection station, starts filming apparatus and the lead in product to be detected is carried out
Shooting, to generate pending image;
Image differentiation processing is carried out relative to background where lead to lead in pending image, generates target signature
Picture;
When target signature image is effective, target signature image is detected using the first preset algorithm, and according to inspection
It surveys result and determines the lead size in product to be detected.
Preferably, described that image differentiation processing is carried out relative to background where lead to lead in pending image, it generates
The step of target signature image includes:
Pending image is pre-processed, and determines the profile base of product to be detected in pretreated image to be detected
Standard determines the detection zone of pending image according to profile benchmark;
Image differentiation processing is carried out relative to background where lead to lead in the detection zone of pending image, and to warp
The detection zone that image distinguishes processing carries out feature extraction operation, and target signature image is generated according to each feature of extraction.
Preferably, lead carries out image differentiation relative to background where lead in the detection zone to pending image
Processing, and feature extraction operation is carried out to the detection zone for distinguishing processing through image, it is special to generate target according to each feature of extraction
Levy image the step of include:
Gray proces are carried out to the detection zone of pending image according to gray proces preset value, so that in detection zone
Background is distinguished where lead and lead;
The lead size characteristic parameter in the pending image through gray proces is extracted, and the lead size characteristic is joined
Number is formed by region as characteristic image region, with according to characteristic image Area generation target signature image.
Preferably, described that the lead size characteristic parameter is formed by region as characteristic image region, with basis
The step of characteristic image Area generation target signature image includes:
Each lead size characteristic parameter is judged whether in each corresponding pre-set dimension parameter section, as each lead size spy
When levying parameter in each corresponding pre-set dimension parameter section, it is determined that the elemental area of lead in detection zone;
The elemental area is judged whether in preset area section, when the elemental area is in preset area section
When, then each lead size characteristic parameter is formed by region as characteristic image region, by the image in characteristic image region
It is determined as target signature image.
Preferably, it is described judge the elemental area whether include after the step in preset area section:
When the elemental area is not in preset area section, and elemental area is more than the upper boundary values in preset area section
When, then gray proces preset value is adjusted;
Using the gray proces preset value after after the adjustment as new gray proces preset value, and execute pre- according to gray proces
If being worth the step of carrying out gray proces to the detection zone of each pending image.
Preferably, it is described judge the elemental area whether include after the step in preset area section:
When the elemental area is not in preset area section, and elemental area is less than the lower border value of pre-set interval,
Then judge that the elemental area of lead in detection zone is invalid, the target generated according to lead size characteristic parameter forming region is special
Levy effective image.
Preferably, described when target signature image is effective, target signature image is examined using the first preset algorithm
It surveys, and the step of determining the lead size in product to be detected according to testing result includes:
The validity for identifying target signature image, if target signature image is effective, using the first preset algorithm to target
Characteristic image is detected, and generates testing result;
If target signature image is invalid, pending image is detected using the second preset algorithm, generates detection knot
Fruit;
The testing result and default result section are compared, and the lead in product to be detected is determined according to comparing result
Size.
Preferably, described when detecting that product to be detected reaches detection station, start filming apparatus to each production to be detected
The step of lead in product is shot include:
When detecting that product to be detected reaches detection station, start filming apparatus and bowl light source, control bowl light source is treated
It detects product and illumination is provided, and control filming apparatus and the lead in product to be detected is shot.
In addition, to achieve the above object, the present invention also proposes a kind of lead size detecting device, the lead size detection
Device includes:Memory, processor, communication bus and the lead size detection program being stored on the memory;
The communication bus is for realizing the connection communication between processor and memory;
The processor is for executing the lead size detection program, to realize following steps:
When detecting that product to be detected reaches detection station, starts filming apparatus and the lead in product to be detected is carried out
Shooting, to generate pending image;
Image differentiation processing is carried out relative to background where lead to lead in pending image, generates target signature
Picture;
When target signature image is effective, target signature image is detected using the first preset algorithm, and according to inspection
It surveys result and determines the lead size in product to be detected.
In addition, to achieve the above object, it is described computer-readable the present invention also provides a kind of computer readable storage medium
Storage medium storage there are one either more than one program the one or more programs can by one or one with
On processor execute for:
When detecting that product to be detected reaches detection station, starts filming apparatus and the lead in product to be detected is carried out
Shooting, to generate pending image;
Image differentiation processing is carried out relative to background where lead to lead in pending image, generates target signature
Picture;
When target signature image is effective, target signature image is detected using the first preset algorithm, and according to inspection
It surveys result and determines the lead size in product to be detected.
The lead size detecting method of the present embodiment starts shooting when detecting that product to be detected reaches detection station
Device shoots the lead in product to be detected, to generate pending image;To lead in pending image relative to drawing
Background carries out image differentiation processing where line, generates target signature image;It is effective in the target signature image generated, using
One preset algorithm is detected target signature image, and determines the lead size in product to be detected according to testing result.This
Scheme carries out image differentiation processing by background where the lead and lead in the pending image to product to be detected, generates mesh
Characteristic image is marked, realization is detected target signature image by the first preset algorithm.Because in the target signature image of generation
Background where lead and its is distinguished, to when being detected to it by preset algorithm, can make detection it is more convenient,
And accuracy is high.
Specific implementation mode
It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, it is not intended to limit the present invention.
The present invention provides a kind of lead size detecting method.
Fig. 1 is please referred to, Fig. 1 is the flow diagram of lead size detecting method first embodiment of the present invention.In this implementation
In example, the lead size detecting method includes:
Step S10 starts filming apparatus in product to be detected when detecting that product to be detected reaches detection station
Lead is shot, to generate pending image;
The lead size detecting method of the present invention is primarily adapted for use in the vision-based detection of lead in sound system, is applied to control
Device end, using with leaded and have the product of detection demand as product to be detected, detection demand be detect the size of lead with
Whether track meets product requirement.Control device is connected with sensing device, filming apparatus by wired or wireless mode, sensing
Device can be proximity sensor or range sensor etc., for detecting whether product to be detected reaches detection station;Shooting dress
It can be camera or camera etc. to set, for carrying out image taking to the product to be detected for reaching detection station.When sensing fills
It sets when detecting that product to be detected reaches detection station, prompt message is sent to control device, to prompt control device to be detected
Product arrived detection station.Control device when detection receives this product to be detected and reaches the prompt message of detection station,
Filming apparatus startup is then controlled, is shot, is generated each to be detected with the lead in the product to be detected to reaching detection station
The pending image of product.Because filming apparatus during shooting inevitably to being presented on camera lens before
Article is shot, and also has other components or lead to be mounted on production to be detected other than lead in product to be detected
The enclosure interior of product is waited for using the shell of this other component or product to be detected as the background of lead in pending image
Processing image includes the location context of product to be detected where lead i.e. lead.In addition shooting effect is considered, in the mistake of shooting
It needs to carry out Lighting operations to shooting using light source in journey, and each lighting effect is combined to consider, preferentially carry out light using bowl light source
According to.To when detecting that product to be detected reaches detection station, start filming apparatus to the lead in each product to be detected into
Row shooting the step of include:
When detecting that product to be detected reaches detection station, start filming apparatus and bowl light source, control bowl light source is treated
It detects product and illumination is provided, and control filming apparatus and the lead in product to be detected is shot.
When detecting product arrival detection station to be detected, illustrates there is product to be detected to need to detect, then first carry out image
Shooting starts filming apparatus and bowl light source.Bowl light source is bowl-shape light source-providing device, and multiple lamp beads are arranged at the rim of a bowl,
The light that lamp bead is emitted is reflected through bowl inner face, and the light projected through the rim of a bowl can be made to be more uniformly distributed.Bottom of bowl is provided with aperture, camera shooting
The camera lens of device is placed at aperture, is shot to the lead of product to be detected by aperture.Control device controls bowl light source
While product to be detected to carrying out image taking provides illumination, control filming apparatus carries out the lead in product to be detected
Shooting, to ensure that captured lead image has clear shooting effect.In addition bowl light source is by the lead of product to be detected
While beating bright, the both sides of lead are projected into uniform shadow together, is conducive to the feature extraction of lead, that is, is conducive to treat
Handle the image procossing of image.
Step S20 carries out image differentiation processing relative to background where lead to lead in pending image, generates target
Characteristic image;
Further, after generating pending image, to lead in this pending image relative to background where lead
Image differentiation processing is carried out, lead is distinguished in the background from it.Because of lead in different types of pending product
Position otherness, i.e. lead is located at the different location space of different pending products, such as pending product A and B, A
In lead space on its interior the upper left corner, and the lower right corner in the lead space on its interior in B.And will be pending
During product carries out the pending image of shooting generation, it is to carry out image taking for entire pending product, makes lead position
In the different location of different pending images.If the locational space very little of pending image shared by lead, and image procossing needle
To entire pending image, then so that image procossing is directed to very to useless locational space, reduce the efficiency of image procossing.To
The present embodiment needs the position in pending image where first determining lead in image processing process, by the lead of position
Image differentiation processing is carried out with its background, into line lead feature extraction, to generate target signature image.Specifically, place is treated
Managing the step of lead carries out image differentiation processing relative to background where lead, generates target signature image in image includes:
Step S21 pre-processes pending image, and determines product to be detected in pretreated image to be detected
Profile benchmark, the detection zone of pending image is determined according to profile benchmark;
When position of the present embodiment in pending image where determining lead, can first it identify embodied in pending image
Product to be detected profile benchmark, then to profile benchmark position carry out image recognition to determine lead position, will
This band of position is as detection zone.And it is only needed in the profile benchmark identification process to product to be detected by product to be detected
It is distinguished with environment where it, if be identified using the original image of pending image, because of the original image of pending image
Data volume it is larger, identify needed for data volume to be processed it is larger, reduce image processing efficiency.To first to pending image
It is pre-processed, the data volume of pending image is reduced, to improve the determination efficiency of the profile benchmark of product to be detected.Such as by
10,000,000 pixels originally are reduced to five mega pixels, and profile benchmark knowledge is carried out by pretreated pending image to this
Not, the profile benchmark of product to be detected is determined.After determining the profile benchmark of product to be detected, then further in profile benchmark
Lead position is determined, and lead position is determined as to the detection zone of pending image.
Step S22 carries out at image differentiation lead in the detection zone of pending image relative to background where lead
Reason, and feature extraction operation is carried out to the detection zone for distinguishing processing through image, target signature is generated according to each feature of extraction
Image.
In the detection zone for determining pending image, i.e., behind lead position, to the detection zone of this pending image
Middle lead carries out image differentiation processing relative to background where lead, so that lead is different from background where it, and to this through figure
Detection zone as distinguishing processing carries out feature extraction operation, keeps extraction characteristic manipulation more easy.Because detection zone is lead
It is extracted and is characterized as characteristic value possessed by lead in region, it may include the acyclic offset of lead, extension value, boundary are wide
Degree, border motif etc..It is substantially the position for the place detection zone that lead is determined by lead feature to this extraction operation, i.e., logical
Crossing the acyclic offset of lead, extension value, border width, border motif etc. determines lead in the position of detection zone.By this lead
The image of place detection zone position is realized as target signature image and generates target signature image according to each feature of extraction.
Step S30 is detected target signature image using the first preset algorithm when target signature image is effective,
And the lead size in product to be detected is determined according to testing result.
Understandably, because target signature image according to the lead feature of extraction by generating, and in the mistake of extraction lead feature
In journey there may be failure the case where, if lead and its place background color it is excessively close, and cannot by lead feature from its
It is extracted in background, and feature extraction is caused to fail, it is invalid so as to cause the target signature image generated according to each feature;
And it is successful in extraction lead feature, then the target signature image generated according to each feature is effective.The present embodiment
Lead size detection predominantly detects the size of lead and whether track meets product requirement, in order to lead size and track be
No meet the requirements is judged, the first preset algorithm is previously provided with, using the first preset algorithm to the target signature that is generated
Image is detected, and then determines the lead size in product to be detected according to obtained testing result is detected.In view of institute
The target signature image of generation may effectively may also be invalid, be previously provided with for effective and invalid different situations different
Preset algorithm.Specifically, when target signature image is effective, target signature image is detected using the first preset algorithm,
And the step of determining the lead size in product to be detected according to testing result, includes:
Step S31 identifies the validity of target signature image, if target signature image is effective, using the first pre- imputation
Method is detected target signature image, generates testing result;
Step S32 is detected pending image using the second preset algorithm if target signature image is invalid, raw
At testing result;
The testing result and default result section are compared, and determine product to be detected according to comparing result by step S33
In lead size.
Further, because the target signature image that is generated may effectively may also be invalid, and to effective target signature
The processing mode of image and invalid target signature image is different, to first know to the validity of target signature image
Not.If the feature of lead and elemental area are effective in the mesh characteristic image generated, it can determine that target signature image is effective;
And the feature of lead and elemental area then can determine that target signature there are any one is invalid in the mesh characteristic image generated
As invalid.For effective and invalid target signature image, it is provided with the first preset algorithm and the second preset algorithm, it will be with target
The effectively corresponding preset algorithm of characteristic image is and invalid corresponding default with target signature image as the first preset algorithm
Algorithm is as the second preset algorithm.When target signature image is effective, then use this first preset algorithm to target signature image
It is detected, measures the size and its track position of lead in target signature image, obtained result will be measured as inspection
Survey result.And when target signature image is invalid, because the target signature image of generation cannot be used for the feature of characterization lead, then adopt
Pending image is detected with the second preset algorithm, i.e., directly to product to be detected shoot obtained pending image into
Row detection.Because the graphic element except lead included by pending image is numerous, it is detected using the second preset algorithm
In the process, stringent confirmation is carried out to the color value in pending image to divide, to distinguish lead from pending image, and
The size and its track position for measuring distinguished lead, using this obtained result of measurement as testing result.In addition exist
When the operation distinguished to lead, once there is inconsistent color value, such as being infected on the lead in product to be detected
There are other impurities, then contamination in the pending image of generation is imaged to it the pixel value and lead of wire locations of other impurities
In be not infected with other impurities position pixel value it is inconsistent;It is when there is this inconsistent situation, then pending image institute is right
Lead size discrimination in the product to be detected answered is unqualified, prevents the situation judged by accident occur to lead size.
Further, in order to determine whether the size of this lead meets product requirement with track, it is provided with default result
Section.This default result section is a pre-set interval range, because of same type of difference product to be detected, although two
The production technology of person is identical, but still there are fine errors, to pre-set interval range, as long as in this section model when detection
It is the lead of size qualification in enclosing.Specifically, the size of lead and track in target signature image or pending image
Position measures, and after generating testing result, testing result and default result section are compared, judge generated testing result
Whether in default result section;When testing result is in default result section, then illustrate the lead ruler in product to be detected
Very little and track meets product requirement;And when testing result not in default result section, be more than default result section coboundary or
When person is less than default result section lower boundary, then illustrate that the lead size and track in product to be detected are unsatisfactory for product requirement.
This implementation is detected lead imaging using different preset algorithms, and set pre- according to the validity of target signature image
If result section is realized determines lead size in product to be detected with the comparing result in default result section according to testing result
Qualification improves the accuracy of lead size detection.
The lead size detecting method of the present embodiment starts shooting when detecting that product to be detected reaches detection station
Device shoots the lead in product to be detected, to generate pending image;To lead in pending image relative to drawing
Background carries out image differentiation processing where line, generates target signature image;It is effective in the target signature image generated, using
One preset algorithm is detected target signature image, and determines the lead size in product to be detected according to testing result.This
Scheme carries out image differentiation processing by background where the lead and lead in the pending image to product to be detected, generates mesh
Characteristic image is marked, realization is detected target signature image by the first preset algorithm.Because in the target signature image of generation
Background where lead and its is distinguished, to when being detected to it by preset algorithm, can make detection it is more convenient,
And accuracy is high.
Further, in another embodiment of lead size detecting method of the present invention, the inspection to pending image
Survey in region lead and carry out image differentiation processing relative to background where lead, and to distinguished through image the detection zone of processing into
Row feature extraction operation, according to each feature of extraction generate target signature image the step of include:
Step S221 carries out gray proces, so that inspection according to gray proces preset value to the detection zone of pending image
Background is distinguished where surveying the lead in region and lead;
Step S222 extracts the lead size characteristic parameter in the pending image through gray proces, and by the lead
Size characteristic parameter is formed by region as characteristic image region, with according to characteristic image Area generation target signature image.
Understandably, when the detection zone to pending image carries out feature extraction operation, because pending image is by waiting for
Detection product direct imaging is formed, and the image formed is different and different according to photographic device, may be that coloured image may also
Colored pending image is first converted into gray level image, then to the pending of gray scale when for coloured image for gray level image
Image carries out gray proces.The gray proces of the present embodiment are binary conversion treatment, are set with gray proces preset value, according to this ash
Degree processing preset value carries out gray proces to the detection zone of pending image, by the gray value and gray scale of each point in detection zone
Preset value comparison is handled, judges the magnitude relationship between the gray value of each point and gray proces preset value.Gray value is more than ash
The point of degree processing preset value is set as bright spot or dim spot, and the point that gray value is less than to gray proces preset value accordingly is set as dark
Point or bright spot carry out gray proces by gray proces preset value to the detection zone of pending image, will be in detection zone
Lead and its background are distinguished.Wherein gray proces preset value is set variant for different products to be detected, as certain is waited for
The gray value for detecting lead in the pending image of product is substantially less than k values, then can set gray proces preset value as k, incite somebody to action
Point of the gray value more than k is set as dim spot in pending image, and the point less than k is set as bright spot, to realize lead and background
Differentiation.
Further, gray proces are carried out in the detection zone to pending image, background where lead and its is carried out
After differentiation, then operation can be extracted to the lead size characteristic parameter in the pending image through gray proces.Wherein draw
Linear dimension characteristic parameter includes acyclic offset, extension value, border width, border motif, the shape size for characterizing lead.Cause
Lead and background where it are distinguished by gray proces, so as to determine the other than ring type value of lead by image recognition, prolong
Long value, border width and border motif extract lead size characteristic parameter.Lead size characteristic parameter is for characterizing lead
Shape size, be characterized image-region, i.e. lead size characteristic parameter institute shape with the lead region of this shape size
At region be characterized image-region, and the characteristic image in this region is target signature image, i.e. lead image, to realize
Target signature image is generated according to the image-region that each feature of extraction is formed.
Further, described by lead size spy in another embodiment of lead size detecting method of the present invention
Sign parameter is formed by region as characteristic image region, to be wrapped according to the step of characteristic image Area generation target signature image
It includes:
Step q1 judges each lead size characteristic parameter whether in each corresponding pre-set dimension parameter section, when respectively drawing
When linear dimension characteristic parameter is in each corresponding pre-set dimension parameter section, it is determined that the elemental area of lead in detection zone;
Step q2 judges the elemental area whether in preset area section, when the elemental area is in preset area
When in section, then each lead size characteristic parameter is formed by region as characteristic image region, it will be in characteristic image region
Image be determined as target signature image.
Understandably, for different products to be detected, the lead size having and track differ, in order to ensure being carried
The lead size characteristic parameter taken is consistent with the theory characteristic parameter value of lead, needs the lead size characteristic parameter to being extracted
Validity judged.And in the extraction process to lead size characteristic parameter, although the technological process of extraction is consistent,
The presence for always having error, to judge for the validity to the lead size characteristic parameter extracted, the present embodiment
Theory characteristic parameter value possessed by lead is provided with pre-set dimension parameter region corresponding with each lead size characteristic parameter
Between.As set the acyclic offset of certain lead, extension value, border width, border motif theory characteristic parameter value be respectively a, b,
c、d;40 pixels, the default ruler of extension value are added and subtracted in the other than ring type value of lead in the pre-set dimension parameter section for then setting other than ring type value
10 pixels, the border width of the pre-set dimension parameter section of border width in lead are added and subtracted in the extension value of lead in very little parameter section
10 pixels are added and subtracted in the border motif value of lead in the pre-set dimension parameter section of value 50 pixels of plus-minus, border motif;It is i.e. non-ring-like
Value, extension value, border width, border motif pre-set dimension parameter section be respectively [a-40, a+40], [b-10, b+10],
[c-50, c+50], [d-10, d+10].It is after extracting each lead size characteristic parameter, each lead dimensional parameters are right with its
The pre-set dimension parameter section comparison answered, judges whether in corresponding pre-set dimension parameter section, such as acyclic offset of extraction,
Extension value, border width, border motif are respectively k1, k2, k3 and k4, then by k1, k2, k3 and k4 respectively with pre-set dimension parameter
Section [a-40, a+40], [b-10, b+10], [c-50, c+50], [d-10, d+10] judge whether in corresponding default ruler
In very little parameter section, when each lead size characteristic parameter of extraction is in each corresponding pre-set dimension parameter section, then illustrate
The lead size characteristic parameter of extraction is consistent with the theory characteristic parameter value of lead, and the lead size characteristic parameter of extraction has
Effect.
Further, it is contemplated that there may be lead size characteristic parameters to be formed by region other than lead image
There are impurity, the backgrounds of lead and environment where it in the background image of environment where the also situation of other images, i.e. lead
Image do not distinguish it is clear, and to lead size and track position detection have an impact.Because of the pure background in not impurity effect
The theoretical elemental area of lower lead is certain, to which the present embodiment is provided with preset area area for different types of lead
Between, this preset area section is determined according to lead theory elemental area constant interval, as certain types of leads theory elemental area becomes
It is [area1, area2] to change section, considers that background where lead cannot be removed completely accordingly, and its preset area section is set
It is set to [area1-1000, area2+2000].Determine extraction lead size characteristic parameter it is effective after, need to further determine that through
The elemental area of lead in detection zone after gray proces, and by this elemental area preset area corresponding with its section ratio
Compared with judging the elemental area of lead whether in preset area section.When the elemental area of lead is in preset area section,
Then lead and its background area are distinguished one from the other in detection zone of the explanation after gray proces, and background will not be to lead size and its track
The detection of position has an impact.Each lead size characteristic parameter is formed by region as characteristic image region, is drawn with characterization
Image in characteristic image region is determined as target signature image, i.e. lead image by the shape size of line.By to extraction
The validity of the elemental area of lead size characteristic parameter and lead is judged, it is ensured that the target signature image generated
Accuracy, to improve the accuracy of lead size detection.
Further, described to judge the elemental area in another embodiment of lead size detecting method of the present invention
Whether include after the step in preset area section:
Step q3, when the elemental area is not in preset area section, and elemental area is more than preset area section
When upper boundary values, then gray proces preset value is adjusted;
Step q4 using the gray proces preset value after after the adjustment as new gray proces preset value, and is executed according to ash
The step of degree processing preset value carries out gray proces to the detection zone of each pending image.
Further, and by the elemental area of lead preset area corresponding with its section compare, judge lead
Elemental area not in preset area section, and elemental area be more than preset area section upper boundary values when, then illustrate lead
It is not properly separated with background where it, there are impurity in the background where lead, using the corresponding pixel of this impurity as lead
Pixel calculated, and the elemental area of lead is made to increase.It needs that gray proces preset value is adjusted at this time, will pass through
Gray proces preset value after adjusting is as new gray proces preset value, using this new gray proces preset value to respectively waiting locating
The detection zone of reason image carries out gray proces again, is distinguished again to the lead in detection zone and background where it,
And whether extraction lead size characteristic parameter is detected in corresponding pre-set dimension parameter section again, sentences again if if
The elemental area of lead is determined whether in preset area section, if illustrating to draw in the detection zone after gray proces again if
Line and its background area are distinguished one from the other, and can each lead size characteristic parameter be formed by region as characteristic image region, and will be special
Image in sign image-region is determined as target signature image.And if through judging the elemental area of lead still not default again
In area section, then illustrates that lead is still not properly separated with background where it, need further to gray proces preset value
It is adjusted, using the gray proces preset value after overregulating as new gray proces preset value, executes according to gray proces
The step of preset value carries out gray proces to the detection zone of each pending image.Possible gray proces preset value is through repeatedly adjusting
Section, after carrying out multiple gray proces to the detection zone of pending image, obtained lead elemental area is not still default
In areal extent.If unlimited number of adjusting processing, it is clear that the detection of other products to be detected can be influenced, system resource is expended,
Number empirical value is adjusted so as to set, number empirical value, gained are adjusted when the adjusting number to gray proces preset value reaches
The lead elemental area arrived still not within the scope of preset area when, then will be given birth to according to this lead size characteristic parameter forming region
At target signature image be determined as in vain, to use the second preset algorithm to be detected original pending image, and
Lead size detection is carried out independent of invalid target signature image, improves the accuracy of detection.
Further, described to judge the elemental area in another embodiment of lead size detecting method of the present invention
Whether include after the step in preset area section:
Step q5, when the elemental area is not in preset area section, and elemental area is less than the following of pre-set interval
When dividing value, then judge that the elemental area of each lead size characteristic parameter institute forming region is invalid, according to lead size characteristic parameter
The target signature image that forming region is generated is invalid.
Further, compare by the elemental area of lead preset area corresponding with its section, judge lead
Elemental area not in preset area section, and elemental area be less than preset area section lower border value when, then illustrate lead
Closely similar with background color where it, lead and background are difficult to differentiate between, and the elemental area of lead is unable to indicator in detection zone
Lead, this elemental area is invalid, the target signature image generated accordingly according to lead size characteristic parameter forming region without
Effect.And when elemental area is zero, then illustrate that lead and background combine together, the failure of lead size characteristic parameter extraction, institute
The target signature image of generation is invalid.Original pending image is detected using the second preset algorithm at this time, and is disobeyed
Rely and carry out lead size detection in invalid target signature image, to improve the accuracy of detection
With reference to Fig. 2, Fig. 2 is the device structure schematic diagram for the hardware running environment that the embodiment of the present invention is related to.
As shown in Fig. 2, the lead size detecting device may include:Processor 1001, such as CPU, memory 1005 lead to
Believe bus 1002.Wherein, communication bus 1002 is for realizing the connection communication between processor 1001 and memory 1005.Storage
Device 1005 can be high-speed RAM memory, can also be stable memory (non-volatile memory), such as disk
Memory.Memory 1005 optionally can also be the storage device independently of aforementioned processor 1001.
Optionally, which can also include user interface, network interface, camera, RF (Radio
Frequency, radio frequency) circuit, sensor, voicefrequency circuit, WiFi module etc..User interface may include display screen
(Display), input unit such as keyboard (Keyboard), optional user interface can also include wireline interface, the nothing of standard
Line interface.Network interface may include optionally standard wireline interface and wireless interface (such as WI-FI interface).
It will be understood by those skilled in the art that lead size detecting device structure shown in Figure 2 not structure paired lead
The restriction of size detecting device may include either combining certain components or different than illustrating more or fewer components
Component is arranged.
As shown in Fig. 2, as may include that operating system, network are logical in a kind of memory 1005 of computer storage media
Believe module and lead size detection program.Operating system is management and control lead size detecting device hardware and software resource
Program, support the operation of lead size detection program and other softwares and/or program.Network communication module is for realizing depositing
Communication between each component in the inside of reservoir 1005, and with communicated between other hardware and softwares in lead size detecting device.
In lead size detecting device shown in Fig. 2, processor 1001 is used to execute drawing of storing in memory 1005
Linear dimension detects program, realizes following steps:
When detecting that product to be detected reaches detection station, starts filming apparatus and the lead in product to be detected is carried out
Shooting, to generate pending image;
Image differentiation processing is carried out relative to background where lead to lead in pending image, generates target signature
Picture;
When target signature image is effective, target signature image is detected using the first preset algorithm, and according to inspection
It surveys result and determines the lead size in product to be detected.
Further, described that image differentiation processing is carried out relative to background where lead to lead in pending image, it is raw
Include at the step of target signature image:
Pending image is pre-processed, and determines the profile base of product to be detected in pretreated image to be detected
Standard determines the detection zone of pending image according to profile benchmark;
Image differentiation processing is carried out relative to background where lead to lead in the detection zone of pending image, and to warp
The detection zone that image distinguishes processing carries out feature extraction operation, and target signature image is generated according to each feature of extraction.
Further, lead carries out image district relative to background where lead in the detection zone to pending image
Divide processing, and feature extraction operation is carried out to the detection zone for distinguishing processing through image, according to each feature of extraction generation target
The step of characteristic image includes:
Gray proces are carried out to the detection zone of pending image according to gray proces preset value, so that in detection zone
Background is distinguished where lead and lead;
The lead size characteristic parameter in the pending image through gray proces is extracted, and the lead size characteristic is joined
Number is formed by region as characteristic image region, with according to characteristic image Area generation target signature image.
Further, described that the lead size characteristic parameter is formed by region as characteristic image region, with root
Include according to the step of characteristic image Area generation target signature image:
Each lead size characteristic parameter is judged whether in each corresponding pre-set dimension parameter section, as each lead size spy
When levying parameter in each corresponding pre-set dimension parameter section, it is determined that the elemental area of lead in detection zone;
The elemental area is judged whether in preset area section, when the elemental area is in preset area section
When, then each lead size characteristic parameter is formed by region as characteristic image region, by the image in characteristic image region
It is determined as target signature image.
Further, described to judge the elemental area whether after the step in preset area section, processor
1001, for executing the lead size detection program stored in memory 1005, realize following steps:
When the elemental area is not in preset area section, and elemental area is more than the upper boundary values in preset area section
When, then gray proces preset value is adjusted;
Using the gray proces preset value after after the adjustment as new gray proces preset value, and execute pre- according to gray proces
If being worth the step of carrying out gray proces to the detection zone of each pending image.
Further, described to judge the elemental area whether after the step in preset area section, processor
1001, for executing the lead size detection program stored in memory 1005, realize following steps:
When the elemental area is not in preset area section, and elemental area is less than the lower border value of pre-set interval,
Then judge that the elemental area of lead in detection zone is invalid, the target generated according to lead size characteristic parameter forming region is special
Levy effective image.
Further, described when target signature image is effective, target signature image is carried out using the first preset algorithm
Detection, and the step of determining the lead size in product to be detected according to testing result includes:
The validity for identifying target signature image, if target signature image is effective, using the first preset algorithm to target
Characteristic image is detected, and generates testing result;
If target signature image is invalid, pending image is detected using the second preset algorithm, generates detection knot
Fruit;
The testing result and default result section are compared, and the lead in product to be detected is determined according to comparing result
Size.
Further, described when detecting that product to be detected reaches detection station, start filming apparatus to each to be detected
The step of lead in product is shot include:
When detecting that product to be detected reaches detection station, start filming apparatus and bowl light source, control bowl light source is treated
It detects product and illumination is provided, and control filming apparatus and the lead in product to be detected is shot.
Lead size detecting device specific implementation mode of the present invention and above-mentioned each embodiment of lead size detecting method are basic
Identical, details are not described herein.
The present invention provides a kind of computer readable storage medium, the computer-readable recording medium storage there are one or
More than one program of person, the one or more programs can also be executed by one or more than one processor with
In:
When detecting that product to be detected reaches detection station, starts filming apparatus and the lead in product to be detected is carried out
Shooting, to generate pending image;
Image differentiation processing is carried out relative to background where lead to lead in pending image, generates target signature
Picture;
When target signature image is effective, target signature image is detected using the first preset algorithm, and according to inspection
It surveys result and determines the lead size in product to be detected.
Further, described that image differentiation processing is carried out relative to background where lead to lead in pending image, it is raw
Include at the step of target signature image:
Pending image is pre-processed, and determines the profile base of product to be detected in pretreated image to be detected
Standard determines the detection zone of pending image according to profile benchmark;
Image differentiation processing is carried out relative to background where lead to lead in the detection zone of pending image, and to warp
The detection zone that image distinguishes processing carries out feature extraction operation, and target signature image is generated according to each feature of extraction.
Further, lead carries out image district relative to background where lead in the detection zone to pending image
Divide processing, and feature extraction operation is carried out to the detection zone for distinguishing processing through image, according to each feature of extraction generation target
The step of characteristic image includes:
Gray proces are carried out to the detection zone of pending image according to gray proces preset value, so that in detection zone
Background is distinguished where lead and lead;
The lead size characteristic parameter in the pending image through gray proces is extracted, and the lead size characteristic is joined
Number is formed by region as characteristic image region, with according to characteristic image Area generation target signature image.
Further, described that the lead size characteristic parameter is formed by region as characteristic image region, with root
Include according to the step of characteristic image Area generation target signature image:
Each lead size characteristic parameter is judged whether in each corresponding pre-set dimension parameter section, as each lead size spy
When levying parameter in each corresponding pre-set dimension parameter section, it is determined that the elemental area of lead in detection zone;
The elemental area is judged whether in preset area section, when the elemental area is in preset area section
When, then each lead size characteristic parameter is formed by region as characteristic image region, by the image in characteristic image region
It is determined as target signature image.
Further, described to judge the elemental area whether after the step in preset area section, it is one
Either more than one program can also be executed by one or more than one processor for:
When the elemental area is not in preset area section, and elemental area is more than the upper boundary values in preset area section
When, then gray proces preset value is adjusted;
Using the gray proces preset value after after the adjustment as new gray proces preset value, and execute pre- according to gray proces
If being worth the step of carrying out gray proces to the detection zone of each pending image.
Further, described to judge the elemental area whether after the step in preset area section, it is one
Either more than one program can also be executed by one or more than one processor for:
When the elemental area is not in preset area section, and elemental area is less than the lower border value of pre-set interval,
Then judge that the elemental area of lead in detection zone is invalid, the target generated according to lead size characteristic parameter forming region is special
Levy effective image.
Further, described when target signature image is effective, target signature image is carried out using the first preset algorithm
Detection, and the step of determining the lead size in product to be detected according to testing result includes:
The validity for identifying target signature image, if target signature image is effective, using the first preset algorithm to target
Characteristic image is detected, and generates testing result;
If target signature image is invalid, pending image is detected using the second preset algorithm, generates detection knot
Fruit;
The testing result and default result section are compared, and the lead in product to be detected is determined according to comparing result
Size.
Further, described when detecting that product to be detected reaches detection station, start filming apparatus to each to be detected
The step of lead in product is shot include:
When detecting that product to be detected reaches detection station, start filming apparatus and bowl light source, control bowl light source is treated
It detects product and illumination is provided, and control filming apparatus and the lead in product to be detected is shot.
Computer readable storage medium specific implementation mode of the present invention and each embodiment base of above-mentioned lead size detecting method
This is identical, and details are not described herein.
It should also be noted that, herein, the terms "include", "comprise" or its any other variant are intended to non-
It is exclusive to include, so that process, method, article or device including a series of elements include not only those elements,
But also include other elements that are not explicitly listed, or further include solid by this process, method, article or device
Some elements.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including
There is also other identical elements in the process of the element, method, article or device.
The embodiments of the present invention are for illustration only, can not represent the quality of embodiment.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment side
Method can add the mode of required general hardware platform to realize by software, naturally it is also possible to by hardware, but in many cases
The former is more preferably embodiment.Based on this understanding, technical scheme of the present invention substantially in other words does the prior art
Going out the part of contribution can be expressed in the form of software products, which is stored in one as described above
In storage medium (such as ROM/RAM, magnetic disc, CD), including some instructions use so that a station terminal equipment (can be mobile phone,
Computer, server or network equipment etc.) execute method described in each embodiment of the present invention.
The foregoing is merely the preferred embodiment of the present invention, are not intended to limit the scope of the invention, every at this
Under the design of invention, using equivalent structure transformation made by description of the invention and accompanying drawing content, or directly/it is used in it indirectly
His relevant technical field is included in the scope of patent protection of the present invention.