A kind of elliptical aperture group detection method and system based on maximum inscribed circle
Technical field
The invention belongs to workpiece sensing technical field, a kind of more particularly to elliptical aperture group based on maximum inscribed circle is detected
Method and system.
Background technology
In mechanical part processing, it is an indispensable ring that the dimensions of the part to producing carries out detection
Section.Traditional detection method has receiver ga(u)ge measurement and three coordinate machine detection.But, receiver ga(u)ge measurement inspection is to measured hole group
Actual size and shape measurement sensitivity it is not high.Three coordinate machine detection has higher technical requirements to operating personnel, and
It is relatively costly.With the continuous improvement of scientific and technological level, machine vision technique is progressively applied to the on-line monitoring of workpiece.For ellipse
The machine vision of circular Curve is processed, and researcher is constantly explored in terms of various, by using oval symmetry, string
The technologies such as the geometric propertieses such as midpoint, gradient information, random Hough transformation and method, effectively reduce from different perspectives oval inspection
The space-time consumption of survey.But ellipse is detected using geometric properties and gradient information, its accuracy of detection is easily made an uproar by image background
The interference of sound, and random Hough transformation there is also invalid accumulation that parameter space is caused because of the randomness of sampled point etc. no
Foot.
The content of the invention
In order to solve the technical problem that above-mentioned background technology is proposed, the present invention is intended to provide a kind of based on maximum inscribed circle
Elliptical aperture group detection method and system, overcome that conventional holes group detection method high cost, time loss be big, the low shortcoming of precision.
In order to realize above-mentioned technical purpose, the technical scheme is that:
A kind of elliptical aperture group detection method based on maximum inscribed circle, comprises the following steps:
(1) workpiece image information is gathered;
(2) image information to gathering carries out Image semantic classification;
(3) piecemeal is carried out to image information according to the oval pore size distribution in image information, there is 1 ellipse on every block of image
Hole;
(4) semi-minor axis length, major semiaxis length and the inclination of elliptical aperture in every block of image are gone out using maximum inscribed circle Algorithm for Solving
Angle;
(5) the semi-minor axis length of elliptical aperture, major semiaxis length and inclination angle and standard ellipse hole size are contrasted, is judged work
Whether the elliptical aperture group on part is qualified.
Wherein, be followed successively by image denoising, to image the step of Image semantic classification described in step (2) carry out binaryzation and
Rim detection is carried out to image.
Wherein, the rim detection is Canny rim detections.
Wherein, the particular content of step (4) is as follows:
A () calculates oval m bar horizontal scanning lines, and by i-th horizontal scanning line and oval intersection point ai1、ai2Count collection
Close S, i=1,2 ..., m;
B () calculates all in S set | ai1ai2| midpoint ai, horizontal sweep dotted line is obtained by least square fitting,
And horizontal sweep dotted line is obtained with oval intersection point A1、A2, calculate line segment | A1A2| midpoint M1;
C () solves the vertical scanning dotted line of ellipse and the intersection point institute line of ellipse according to step (a), the method for (b)
The midpoint M of section2, with | M1M2| midpoint O1For the center of circle, | M1M2| take round C for diameter1;
D () obtained point O1Horizontal linear with ellipse intersection point P1、P2, with O1For the center of circle, max | O1P1|, | O1P2| be
Radius makees circle C2;
If e () justifies C2There are 4 intersection points with ellipse, P is designated as successively3、P4、P5、P6, or circle C2There are 3 intersection points with ellipse, i.e.,
P3With P4Overlap or P5With P6Overlap, then with arc lengthWithFor scope, circle C is calculated1Each interior point is in the range of being somebody's turn to do
Oval boundary point minimum range dmin, and charge to set H;If circle C2During with oval only one of which or two intersection points, then calculate
Circle C1Minimum range d of each the interior point to oval all boundary pointsmin, and charge to set H;
F () obtains the max { d in set Hmin, and max { dminCorresponding C1Interior point O;
(g) centered on O, max { dminIt is radius, make circle and hand over ellipse in N1、N22 points, this circle is oval most imperial palace
The circle of contact, | ON1| as oval semi-minor axis is long, and the tiltangleθ and ellipse short shaft place straight line of ellipse are tried to achieve respectively
H () is in line segment | N1N2| above take point Kj, j=1,2 ..., n, will | N1N2| n+1 parts are divided into, K is crossedjMake | N1N2| hang down
Line hands over oval and Dj1, Dj2, calculate dj=| Dj1Dj2|/2, by { Kj, djCount set Q;
I () is to the element { K in set Qj, djLeast square fitting is utilized, try to achieve { Kj, djRespective function maximum
dmax, i.e., oval major semiaxis is long.
Present invention additionally comprises the detecting system based on above-mentioned elliptical aperture group detection method, including work stage, light-emitting component, take the photograph
Light source is radiated at work by camera, image pick-up card, data processing module, memory, console and alarm, the light-emitting component
On part platform, video camera shoots the image of workpiece in work stage, and sends workpiece image to data processing by image pick-up card
Module, data processing module calculates the sized data of elliptical aperture group on workpiece using maximum inscribed circle algorithm, and the data are protected
Deposit in memory, while transmit the data to console, console is by the elliptical aperture packet size for calculating and gauge little progress
Row is contrasted, and according to comparison the action of alarm equipment alarm and work stage is driven.
The beneficial effect brought using above-mentioned technical proposal:
Elliptical aperture group detection method of the present invention using machine vision technique in combination with oval maximum inscribed circle algorithm, can
With the size for accurately determining elliptical aperture group in a short period of time.Detect relative to traditional elliptical aperture group, with time-consuming short, essence
The advantages of spending high, can be efficiently applied to the Aulomatizeted Detect of elliptical aperture group workpiece.
Description of the drawings
Fig. 1 is the flow chart of detection method.
Fig. 2~Fig. 6 is each step schematic diagram that elliptical aperture maximum inscribed circle is obtained in detection method.
Fig. 7 is the structural representation of detecting system of the present invention.
Specific embodiment
Below with reference to accompanying drawing, technical scheme is described in detail.
The flow chart of detection method as shown in Figure 1, a kind of elliptical aperture group detection method based on maximum inscribed circle,
Comprise the following steps:
(1) workpiece image information is gathered.
(2) image information to gathering carries out Image semantic classification.Due to there is noise in image sampling process, this is right
The late detection precision of part image and it is time-consuming on can all cause certain error.So, in the image sample of device to hole group workpiece
Before carrying out relative dimensions measurement, noise is first farthest reduced.To reduce noise, using median filtering method and morphology
Opening operation removes the method that Small object method combines.Secondly, rim detection is made to the image after denoising, is calculated using Canny detections
Son.
(3) piecemeal is carried out to image information according to the oval pore size distribution in image information, there is 1 ellipse on every block of image
Hole.
(4) maximum inscribed circle of elliptical aperture in every block of image is gone out using maximum inscribed circle Algorithm for Solving, and according to most imperial palace
The circle of contact calculates semi-minor axis length, major semiaxis length and the inclination angle of elliptical aperture.It is comprised the following steps that:
A () calculates oval m bar horizontal scanning lines, and by i-th horizontal scanning line and oval intersection point ai1、ai2Count collection
Close S, i=1,2 ..., m;
B () calculates all in S set | ai1ai2| midpoint ai, horizontal sweep dotted line is obtained by least square fitting,
And horizontal sweep dotted line is obtained with oval intersection point A1、A2, calculate line segment | A1A2| midpoint M1, as shown in Figure 2;
C () solves the vertical scanning dotted line of ellipse and the intersection points B of ellipse according to step (a), the method for (b)1、B2Institute
The midpoint M of line section2, as shown in Figure 3;Then with | M1M2| midpoint O1For the center of circle, | M1M2| take round C for diameter1;
D () obtained point O1Horizontal linear with ellipse intersection point P1、P2, with O1For the center of circle, max | O1P1|, | O1P2| be
Radius makees circle C2;
If e () justifies C2There are 4 intersection points with ellipse, P is designated as successively3、P4、P5、P6, as shown in Figure 4;Or circle C2Have with ellipse
3 intersection points, i.e. P3With P4Overlap or P5With P6Overlap, then with arc lengthWith(work as P for scope3With P4Overlap or P5With
P6During coincidence, corresponding arc length is 1 point), calculate circle C1Most narrow spacing of each the interior point to the oval boundary point in the range of this
From dmin, and set H is charged to, as shown in Figure 5;If circle C2During with oval only one of which or two intersection points, then circle C is calculated1Interior is every
Minimum range d of the individual point to oval all boundary pointsmin, and charge to set H;
F () obtains the max { d in set Hmin, and max { dminCorresponding C1Interior point O;
(g) centered on O, max { dminIt is radius, make circle and hand over ellipse in N1、N22 points, this circle is oval most imperial palace
The circle of contact, | ON1| as oval semi-minor axis is long, and the tiltangleθ and ellipse short shaft place straight line of ellipse are tried to achieve respectivelyIf maximum
Inscribed circle is N with the intersection point of ellipse1(x1,y1)、N2(x2,y2), then have:
H () is in line segment | N1N2| above take point Kj, j=1,2 ..., n, will | N1N2| n+1 parts are divided into, K is crossedjMake | N1N2| hang down
Line hands over oval and Dj1, Dj2, calculate dj=| Dj1Dj2|/2, by { Kj, djSet Q is counted, as shown in Figure 6;
I () is to the element { K in set Qj, djLeast square fitting is utilized, try to achieve { Kj, djRespective function maximum
dmax, i.e., oval major semiaxis is long.
(5) the semi-minor axis length of elliptical aperture, major semiaxis length and inclination angle and standard ellipse hole size are contrasted, is judged work
Whether the elliptical aperture group on part is qualified.
The present invention also includes a kind of detecting system based on above-mentioned elliptical aperture group detection method, including work stage, luminous unit
Part, video camera, image pick-up card, data processing module, memory, console and alarm, as shown in Figure 7.The detecting system
Workflow:Workpiece for measurement is placed in work stage, the illumination that light-emitting component sends is mapped on workpiece for measurement, clapped by video camera
The image of elliptical aperture ancestral on workpiece for measurement is taken the photograph, and Jing image pick-up cards send image to data processing module, data processing mould
Block tries to achieve elliptical aperture packet size on the workpiece using aforementioned maximum inscribed circle algorithm, and sends the sized data to console,
Console pre-sets standard size and error threshold, and the elliptical aperture packet size of measurement is compared with standard size, if both
Error is more than error threshold, illustrates that the workpiece is unqualified, and console just drives alarm equipment alarm, and controls work stage by work to be measured
Part is moved in substandard product.
Above example technological thought only to illustrate the invention, it is impossible to which protection scope of the present invention is limited with this, it is every
According to technological thought proposed by the present invention, any change done on the basis of technical scheme, the scope of the present invention is each fallen within
Within.