Improved two rectilineal intervals are from sub-pixel precision measuring method
Technical field:
The present invention relates to physical field, relate in particular to measuring technique, particularly in field of machine vision, measure the technology of air line distance, concrete is that a kind of improved two rectilineal intervals are from sub-pixel precision measuring method.
Background technology:
In prior art, machine vision metrology method can be divided into monocular vision measurement, binocular vision measurement in space and used for multi-vision visual according to the number of the sensor adopting and measure three kinds of forms.Wherein, it is high to hardware requirement that binocular vision measurement in space and used for multi-vision visual are measured form, complicated to the demarcation of camera and registration process, and in the online application scenario of measuring in real time, measuring speed is slower.And monocular vision measurement form adopts geometric similarity mensuration, there is feature simple in structure, without complicated demarcation and registration process, still, the geometric distortion meeting of image makes linearity not enough, and measuring error is larger.
Summary of the invention:
The object of the present invention is to provide a kind of improved two rectilineal intervals from sub-pixel precision measuring method, described this improved two rectilineal intervals will solve in prior art piecture geometry fault in monocular camera machine vision measuring method from sub-pixel precision measuring method and cause the technical matters that measuring error is larger.
This improved two rectilineal intervals of the present invention are from sub-pixel precision measuring method, comprise a step of utilizing single camera to gather objects' contour image, an employing sub-pixel edge extraction algorithm obtains the step at edge and sub-pix contour edge is pruned to the step that obtains better linearity from objects' contour image, , wherein, after the described step that obtains edge from objects' contour image completes, from edge, filter out two objective straight lines, then two objective straight lines are pruned respectively, improve the linearity of target line, finally measure the distance between two objective straight lines after pruning.
Further, before the step that adopts sub-pixel edge extraction algorithm to obtain edge from objects' contour image is carried out, the threshold value that image is cut apart is first set, then the objects' contour image of camera being obtained is made Threshold segmentation, select the highlighted part of objects' contour image, then reject fringe region part in addition, select again background area, the structural element of use 3 * 3 corrodes conversion to inside, background area, obtain the border of background area, then this border is carried out just pruning, retain possible boundary profile, then do circular expander computing, obtain the region of edge in-scope, again the field of definition of objects' contour image is dwindled to the size of target area for this reason, then the image in this field of definition is offered to sub-pixel edge extraction algorithm and ask marginal operation.
Further, after the described step that obtains edge from objects' contour image completes, using RAMER algorithm is polygon by edge fitting, and segmenting edge profile, straight-line segment is split and defined ± 10 intervals of spending angles filter out two objective straight lines.
The present invention and prior art are compared, and its effect is actively with obvious.The present invention uses the geometric similarity mensuration in monocular vision measurement, the optical axis of the object plane of testee and one camera system is vertical and be parallel to picture plane, object and its image meet similarity relation, read pixel point parameter from image, and be multiplied by enlargement factor, can obtain the physical dimension parameter of object reality.First from image, obtain the edge of two sub-pixs between straight line, then edge prunes, improve linearity, correct distortion, the image after pruning is carried out to the matching of straight line, finally measure the distance of calculating between two straight lines.The present invention compares binocular and multi-view stereo vision, has feature simple in structure, without complicated demarcation and registration process, has reduced the error that piecture geometry fault produces simultaneously.
Accompanying drawing explanation:
Fig. 1 is that improved two rectilineal intervals of the present invention are from the schematic diagram of an embodiment of sub-pixel precision measuring method.
To be improved two rectilineal intervals of the present invention use from camera in an embodiment of sub-pixel precision measuring method the image obtaining after backlight illumination to Fig. 2 to the right side of target object.
Fig. 3 be improved two rectilineal intervals of the present invention from use in an embodiment of sub-pixel precision measuring method canny operator in field of definition, ask edge, according to the schematic diagram at the resulting three sections of edges of ramer linear feature dividing wheel profile.
Fig. 4 is improved two rectilineal intervals of the present invention from the schematic diagram of the linear edge blocking in an embodiment of sub-pixel precision measuring method.
Fig. 5 is the schematic diagram of the linear edge after improved two rectilineal intervals of the present invention are optimized from an embodiment cathetus degree of sub-pixel precision measuring method.
Embodiment:
Embodiment 1:
As depicted in figs. 1 and 2, improved two rectilineal intervals of the present invention are from sub-pixel precision measuring method, comprise that one is utilized step and the employing sub-pixel edge extraction algorithm that single camera 4 gathers target object 2 contour images from target object 2 contour images, to obtain the step at edge, wherein, after the described step that obtains edge from target object 2 contour images completes, from edge, filter out two objective straight lines, then two objective straight lines are pruned respectively, improve the linearity of target line, finally measure the distance between two objective straight lines after pruning.
At the described single camera 4 that utilizes, gather in the step of target object 2 contour images, utilize 1 pair of target object 2 of a back light to do dark ground illumination, by the optical axis of camera 4 perpendicular to back light 1.
Target object 2 in the present embodiment is annular objects.Target object 2 is placed on the table top of a worktable 3, and the optical axis of camera 4 is parallel with the table top of worktable 3
The threshold value that image is cut apart is first set, and the annular object contour images of then camera being obtained is made Threshold segmentation, selects the highlighted part of target object 2 contour images.
Owing to there being noise, can first calculate the connected region at two places, left and right.
By the area of screening connected region, region, two of the left and right that comprises annular object elevation information is elected, reject unwanted region.
Then select background area, the structural element of use 3 * 3 corrodes conversion to inside, background area, obtain the border of background area, then this border is carried out just pruning, retain interested boundary profile, then do circular expander computing, obtain the target area that comprises needed two straight lines, again the field of definition of target object 2 contour images is dwindled to the size of target area for this reason, then the image in this field of definition is offered to sub-pixel edge extraction algorithm and ask marginal operation.
Re-using the image of canny operator in this field of definition carries out sub-pix and asks marginal operation.Alpha value is made as 1.
As shown in Figure 3, after obtaining edge, using RAMER algorithm is polygon by edge fitting, and segmenting edge profile, straight-line segment is split and defined ± 10 intervals of spending angles filter out two objective straight lines.
As shown in Figure 4, the linear edge blocking, curvature changes greatly.
As shown in Figure 5, before carrying out line measurement, target line is pruned, the straight-line segment that curvature is larger blocks certain distance from end points, and the distance in the present embodiment is 5 to put pixel, to improve linearity, corrects distortion.Finally by calculating, going up each point on outline line, to the vertical range of lower whorl profile, uses the method for adding up to try to achieve the mean distance between the straight line of matching.