Summary of the invention
The object of the present invention is to provide a kind of method, apparatus of piece test, equipment and computer readable storage medium,
Solve the problems, such as that piece test is influenced to cause piece test efficiency lower by part pose in the prior art.
In order to solve the above technical problems, the present invention provides a kind of method of piece test, including:
Part image to be detected is acquired, the current template matching area in the part image to be detected is searched;According to institute
The original template matching area of the part to be detected of current template matching area and pre-selection is stated, affine transformation matrix is calculated;It utilizes
After the affine transformation matrix corrects the image of the part to be detected, according to the original template matching area and initial rectangular
Corresponding relationship between measured zone determines the current rectangle measurement rectangular area of the part to be detected;It calculates described current
The size of rectangle measured zone judges whether the part to be detected is qualified according to the size.
Preferably, the original template Matching band according to the current template matching area and the part to be detected of pre-selection
Domain, calculating affine transformation matrix includes:The model silhouette of the original template matching area of the part to be detected of pre-selection is obtained, is calculated
The centre coordinate of the original template matching area;The original template matching area and described is aligned using the centre coordinate
Current template matching area, to establish the imitative of the rigidity of the original template matching area and the current template matching area
Penetrate transformation matrix.
Preferably, the size for calculating the current rectangle measured zone, judges described to be detected according to the size
Whether qualification includes part:Utilize the row coordinate, column coordinate and magnitude determinations on each boundary of the current rectangle measured zone
Width between each boundary of current matrix measured zone;By between each boundary of current matrix measured zone
Width judges whether the part to be detected is qualified.
Preferably, the acquisition part image to be detected, searches the current template Matching band of the part image to be detected
Domain includes:Part image to be detected is acquired, after pre-processing using halcon to the part image to be detected, described in determination
Current template matching area in part image to be detected.
Preferably, the original template matching area of the part to be detected of the pre-selection includes:The piece surface to be detected
Printing Marks.
The present invention also provides a kind of devices of piece test, including:
Acquisition module searches the current template in the part image to be detected for acquiring part image to be detected
With region;
Computing module, for being matched according to the original template of the current template matching area and the part to be detected of pre-selection
Region calculates affine transformation matrix;
Rectification module, after the image for correcting the part to be detected using the affine transformation matrix, according to described in
Corresponding relationship between original template matching area and initial rectangular measured zone determines the current rectangle of the part to be detected
Measure rectangular area;
Judgment module judges described to be checked for calculating the size of the current rectangle measured zone according to the size
Whether qualified survey part.
Preferably, the computing module is specifically used for:
The model silhouette for obtaining the original template matching area of the part to be detected of pre-selection calculates the original template matching
The centre coordinate in region;
It is aligned the original template matching area and the current template matching area using the centre coordinate, to build
Found the affine transformation matrix of the rigidity of the original template matching area and the current template matching area.
Preferably, the judgment module is specifically used for:
Current square described in row coordinate, column coordinate and magnitude determinations using each boundary of the current rectangle measured zone
Width between each boundary of battle array measured zone;
Judge whether the part to be detected is qualified by the width between each boundary of current matrix measured zone
The present invention also provides a kind of equipment of piece test, including:
Memory, for storing computer program;Processor realizes above-mentioned one kind when for executing the computer program
The step of method of piece test.
The present invention also provides a kind of computer readable storage medium, meter is stored on the computer readable storage medium
The step of calculation machine program, the computer program realizes a kind of method of above-mentioned piece test when being executed by processor.
Part detection method provided by the present invention chooses original template matching area in advance for part to be detected, establishes
Corresponding relationship between original template matching area and initial measurement rectangular area.When being detected in production to part, first
The image of part to be detected is acquired, the current template matching area in the part image to be detected is searched;It calculates described current
The affine transformation matrix in template matching region and the original template Matching band;Using the affine transformation matrix correct it is described to
After detecting part image, using the original template matching area and the direct corresponding relationship in initial measurement rectangular area,
Determine the current measurement rectangular area of the part to be detected;The size of the current measurement rectangular area is calculated, thus according to
The size of the current measurement rectangular area judges whether the part is qualified.The method of piece test provided by the present invention,
The requirement in terms of part pose is eliminated, makes the achievable measurement in any placement position of the part on assembly line, improves
The efficiency of piece test and the production efficiency of part.
Specific embodiment
Core of the invention is to provide the method, apparatus, equipment and computer readable storage medium of a kind of piece test,
Improve the efficiency of piece test.
In order to enable those skilled in the art to better understand the solution of the present invention, with reference to the accompanying drawings and detailed description
The present invention is described in further detail.Obviously, described embodiments are only a part of the embodiments of the present invention, rather than
Whole embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art are not making creative work premise
Under every other embodiment obtained, shall fall within the protection scope of the present invention.
Referring to FIG. 1, Fig. 1 is the process of the first specific embodiment of the method for piece test provided by the present invention
Figure;Concrete operation step is as follows:
Step S101:Part image to be detected is acquired, the current template Matching band in the part image to be detected is searched
Domain;
Part image to be detected is acquired, after pre-processing using halcon to the part image to be detected, determines institute
State the current template matching area in part image to be detected.
Step S102:According to the original template Matching band of the current template matching area and the part to be detected of pre-selection
Domain calculates affine transformation matrix;
When the original template matching area of the part to be detected of pre-selection, the standard picture of part to be detected is obtained first.It adopts
Selection area source and part contrast preferable background when collecting the standard picture need to select acquisition image according to available accuracy
Camera.
After the standard picture for collecting the part to be detected, adjustment shows the size of image according to demand.From the mark
After having selected ROI region by the way of rectangular picture frame in the base image region of quasi- image, given area image is reduced
To the original template matching area of specified needs, the original template matching area can for part to be detected certain features or
The Printing Marks etc. of person's piece surface.
Selected template area is created as a model, can search and use at any time in piece test later
The model.
Step S103:After the image for correcting the part to be detected using the affine transformation matrix, according to described initial
Corresponding relationship between template matching region and initial rectangular measured zone determines the current rectangle measurement of the part to be detected
Rectangular area;
After selected original template matching area, the measurement range of rectangle delimited, as initial measurement rectangular area, due to
Measurement range has required, therefore does not need the initial measurement rectangular area being created as model.
In order to facilitate comparison, by the original template matching area and the initial measurement rectangular area in Same Part figure
It is shown as in, obtains the corresponding relationship of the original template matching area and the initial measurement rectangular area.
Step S104:The size for calculating the current rectangle measured zone judges described to be detected zero according to the size
Whether part is qualified.
In the present embodiment, using the general features of part to be detected as the template matching region of measurement, according to described first
Affine transformation matrix between beginning template matching region and the current template matching area corrects the image of part to be detected, from
And requirement of the part in terms of position is eliminated, it can detecte each position of the part on assembly line, improve part
The efficiency of detection.
On the basis of the above embodiments, the present embodiment utilizes the current square after determining current measurement rectangular area
Between each boundary of current matrix measured zone described in the row coordinate on each boundary of shape measured zone, column coordinate and magnitude determinations
Width, to judge whether the part to be detected closes by the width between each boundary of current matrix measured zone
Lattice.The concrete operation step of the present embodiment is as follows:
Step S201:Part image to be detected is acquired, the current template Matching band in the part image to be detected is searched
Domain;
Step S202:The model silhouette of the original template matching area of the part to be detected of pre-selection is obtained, is calculated described first
The centre coordinate in beginning template matching region;
Step S203:The original template matching area and the current template Matching band are aligned using the centre coordinate
Domain, to establish the affine transformation matrix of the rigidity of the original template matching area and the current template matching area;
Step S204:After the image for correcting the part to be detected using the affine transformation matrix, according to described initial
Corresponding relationship between template matching region and initial rectangular measured zone determines the current rectangle measurement of the part to be detected
Rectangular area;
Step S205:Utilize the row coordinate, column coordinate and magnitude determinations on each boundary of the current rectangle measured zone
Width between each boundary of current matrix measured zone;
Step S206:The part to be detected is judged by the width between each boundary of current matrix measured zone
It is whether qualified.
The method of piece test provided by the present embodiment can be eliminated in piece test and be wanted to placing part position
It asks, to improve the efficiency of piece test;It avoids in intermittent part detection method in the prior art to waste of time, mentions
The high production efficiency of product.The method of piece test provided by the present embodiment can be right in the gapless situation of assembly line
Part carries out real-time monitoring.
Referring to FIG. 3, Fig. 3 is a kind of structural block diagram of the device of piece test provided in an embodiment of the present invention;Specific dress
It sets and may include:
Acquisition module 100 searches the current template in the part image to be detected for acquiring part image to be detected
Matching area;
Computing module 200, for the original template according to the current template matching area and the part to be detected of pre-selection
Matching area calculates affine transformation matrix;
Rectification module 300, after the image for correcting the part to be detected using the affine transformation matrix, according to institute
The corresponding relationship between original template matching area and initial rectangular measured zone is stated, determines the current square of the part to be detected
Shape measures rectangular area;
Judgment module 400, for calculating the size of the current rectangle measured zone, according to size judgement it is described to
Whether qualified detect part.
Method of the device of the piece test of the present embodiment for realizing piece test above-mentioned, therefore the dress of piece test
The embodiment part of the method for the visible piece test hereinbefore of specific embodiment in setting, for example, acquisition module 100, meter
Module 200, rectification module 300 are calculated, judgment module 400 is respectively used to step S101 in the method for realizing above-mentioned piece test,
S102, S103 and S104, so, specific embodiment is referred to the description of corresponding various pieces embodiment, herein not
It repeats again.
The specific embodiment of the invention additionally provides a kind of equipment of piece test, including:Memory, for storing computer
Program;Processor, the step of a kind of method of above-mentioned xx piece test is realized when for executing the computer program.
The specific embodiment of the invention additionally provides a kind of computer readable storage medium, the computer readable storage medium
On be stored with computer program, the computer program realizes a kind of step of the method for above-mentioned piece test when being executed by processor
Suddenly.
Each embodiment in this specification is described in a progressive manner, the highlights of each of the examples are with it is other
The difference of embodiment, same or similar part may refer to each other between each embodiment.For being filled disclosed in embodiment
For setting, since it is corresponded to the methods disclosed in the examples, so being described relatively simple, related place is referring to method part
Explanation.
Professional further appreciates that, unit described in conjunction with the examples disclosed in the embodiments of the present disclosure
And algorithm steps, can be realized with electronic hardware, computer software, or a combination of the two, in order to clearly demonstrate hardware and
The interchangeability of software generally describes each exemplary composition and step according to function in the above description.These
Function is implemented in hardware or software actually, the specific application and design constraint depending on technical solution.Profession
Technical staff can use different methods to achieve the described function each specific application, but this realization is not answered
Think beyond the scope of this invention.
The step of method described in conjunction with the examples disclosed in this document or algorithm, can directly be held with hardware, processor
The combination of capable software module or the two is implemented.Software module can be placed in random access memory (RAM), memory, read-only deposit
Reservoir (ROM), electrically programmable ROM, electrically erasable ROM, register, hard disk, moveable magnetic disc, CD-ROM or technology
In any other form of storage medium well known in field.
Above to the method, apparatus, equipment and computer readable storage medium of piece test provided by the present invention into
It has gone and has been discussed in detail.Used herein a specific example illustrates the principle and implementation of the invention, the above implementation
The explanation of example is merely used to help understand method and its core concept of the invention.It should be pointed out that for the general of the art
, without departing from the principle of the present invention, can be with several improvements and modifications are made to the present invention for logical technical staff, this
A little improvement and modification are also fallen within the protection scope of the claims of the present invention.