Rectangular workpiece dimension measuring method, device, equipment and storage medium

文档序号:909177 发布日期:2021-02-26 浏览:9次 中文

阅读说明:本技术 矩形工件尺寸测量方法、装置、设备及存储介质 (Rectangular workpiece dimension measuring method, device, equipment and storage medium ) 是由 张发恩 权博 郝磊 于 2020-11-25 设计创作,主要内容包括:本申请提供一种矩形工件尺寸测量方法、装置、设备及存储介质,其中,矩形工件尺寸测量方法包括:采集待测量工件的图像,所述待测量工件的图像通过标定后的成像装置采集生成;对所述待测量工件的图像进行预处理,以从所述待测量工件的图像提取工件前景图像和圆弧;根据所述工件前景图像得到最小外接矩形;根据所述最小外接矩形确定所述待测量工件的尺寸;根据所述圆弧确定所述待测量工件的倒角的曲率半径。本申请能够实现基于机器视觉对矩形工件进行精确测量。(The application provides a method, a device, equipment and a storage medium for measuring the size of a rectangular workpiece, wherein the method for measuring the size of the rectangular workpiece comprises the following steps: acquiring an image of a workpiece to be measured, wherein the image of the workpiece to be measured is acquired and generated by a calibrated imaging device; preprocessing the image of the workpiece to be measured to extract a foreground image and a circular arc of the workpiece from the image of the workpiece to be measured; obtaining a minimum circumscribed rectangle according to the workpiece foreground image; determining the size of the workpiece to be measured according to the minimum circumscribed rectangle; and determining the curvature radius of the chamfer of the workpiece to be measured according to the circular arc. The method and the device can realize accurate measurement of the rectangular workpiece based on machine vision.)

1. A method of dimensional measurement of a rectangular workpiece, the method comprising:

acquiring an image of a workpiece to be measured, wherein the image of the workpiece to be measured is acquired and generated by a calibrated imaging device;

preprocessing the image of the workpiece to be measured to extract a foreground image and a circular arc of the workpiece from the image of the workpiece to be measured;

obtaining a minimum circumscribed rectangle according to the workpiece foreground image;

determining the size of the workpiece to be measured according to the minimum circumscribed rectangle;

and determining the curvature radius of the chamfer of the workpiece to be measured according to the circular arc.

2. The method of claim 1, wherein said determining the dimensions of the workpiece to be measured from the minimum bounding rectangle comprises:

detecting the minimum circumscribed rectangle according to an RANSAC algorithm and obtaining four edges of the minimum circumscribed rectangle;

carrying out segmented projection on each group of opposite sides in the four sides of the minimum external rectangle to obtain projection points of segmented points on the opposite sides of one side;

and determining the length and the width of the workpiece to be measured according to the pixel distance between the segmentation point and the projection point.

3. The method of claim 1, wherein said determining the dimensions of the workpiece to be measured from the minimum bounding rectangle comprises:

detecting the minimum circumscribed rectangle according to an RANSAC algorithm and obtaining four edges of the minimum circumscribed rectangle;

carrying out segmented projection on each group of opposite sides in the four sides of the minimum external rectangle to obtain projection points of segmented points on the opposite sides of one side;

when at least two pixel distances are obtained by more than two segmentation points, calculating the average value of the at least two pixel distances;

and determining the length and the width of the workpiece to be measured according to the average value of the at least two pixel distances.

4. The method of claim 1, wherein the preprocessing the image of the workpiece to be measured to extract a workpiece foreground image and an arc from the image of the workpiece to be measured comprises:

determining image characteristics of the workpiece to be measured;

extracting a foreground image of the workpiece according to the image characteristics of the workpiece to be measured;

extracting the circular arc from the image of the workpiece to be measured.

5. The method of claim 4, wherein said extracting the circular arc from the image of the workpiece to be measured comprises:

searching a connected domain in the image of the workpiece to be measured;

and extracting the circular arc according to the connected domain.

6. The method of claim 1, wherein the calibrated imaging device is calibrated using a scanning polynomial calibration method.

7. A rectangular workpiece dimension measuring apparatus, the apparatus comprising:

the acquisition module is used for acquiring an image of a workpiece to be measured, and the image of the workpiece to be measured is acquired and generated by the calibrated imaging device;

the image preprocessing module is used for preprocessing the image of the workpiece to be measured so as to extract a foreground image and an arc of the workpiece from the image of the workpiece to be measured;

the first calculation module is used for obtaining a minimum circumscribed rectangle according to the workpiece foreground image;

the second calculation module is used for determining the size of the workpiece to be measured according to the minimum circumscribed rectangle;

and the third calculation module is used for determining the curvature radius of the chamfer of the workpiece to be measured according to the circular arc.

8. The apparatus of claim 7, wherein the second computing module comprises:

the first calculation submodule is used for detecting the minimum circumscribed rectangle according to the RANSAC algorithm and obtaining four edges of the minimum circumscribed rectangle;

the projection module is used for carrying out segmented projection on each group of opposite sides in the four sides of the minimum external rectangle so as to obtain projection points of segmented points on the opposite sides of one side;

and the second calculation submodule is used for determining the length and the width of the workpiece to be measured according to the pixel distance between the segmentation point and the projection point.

9. A rectangular workpiece dimension measuring apparatus, comprising:

a processor; and

a memory configured to store machine readable instructions which, when executed by the processor, perform the rectangular workpiece dimension measuring method of any of claims 1-6.

10. A storage medium, characterized in that the storage medium stores a computer program which is executed by a processor to perform the rectangular workpiece dimension measuring method according to any one of claims 1 to 6.

Technical Field

The application relates to the technical field of machine vision, in particular to a method, a device, equipment and a storage medium for measuring the size of a rectangular workpiece.

Background

The traditional industrial part size measurement mostly adopts manual detection, has low detection precision, high cost and low efficiency, and has the conditions of misjudgment and misjudgment.

Disclosure of Invention

An object of the embodiments of the present application is to provide a method, an apparatus, a device and a storage medium for measuring dimensions of a rectangular workpiece, so as to accurately measure the dimensions of the rectangular workpiece.

To this end, a first aspect of the embodiments of the present application discloses a method for measuring dimensions of a rectangular workpiece, the method including:

acquiring an image of a workpiece to be measured, wherein the image of the workpiece to be measured is acquired and generated by a calibrated imaging device;

preprocessing the image of the workpiece to be measured to extract a foreground image and a circular arc of the workpiece from the image of the workpiece to be measured;

obtaining a minimum circumscribed rectangle according to the workpiece foreground image;

determining the size of the workpiece to be measured according to the minimum circumscribed rectangle;

and determining the curvature radius of the chamfer of the workpiece to be measured according to the circular arc.

The method can acquire the image of the workpiece to be measured shot by the imaging device, further can obtain the minimum external rectangle according to the workpiece foreground image, further can determine the size of the workpiece to be measured according to the minimum external rectangle, further can determine the curvature radius of the chamfer of the workpiece to be measured according to the circular arc, and thus the length, the width and the chamfer curvature of the workpiece to be measured can be measured based on machine vision.

In the first aspect of the present application, as an optional implementation manner, the determining the size of the workpiece to be measured according to the minimum bounding rectangle includes:

detecting the minimum circumscribed rectangle according to an RANSAC algorithm and obtaining four edges of the minimum circumscribed rectangle;

carrying out segmented projection on each group of opposite sides in the four sides of the minimum external rectangle to obtain projection points of segmented points on the opposite sides of one side;

and determining the length and the width of the workpiece to be measured according to the pixel distance between the segmentation point and the projection point.

In this optional embodiment, the RANSAC algorithm may be used to detect the minimum circumscribed rectangle and obtain four sides of the minimum circumscribed rectangle, and then perform segmented projection on each set of opposite sides of the four sides of the minimum circumscribed rectangle to obtain projection points of the segmentation points on the opposite sides of one side, so as to determine the length and width of the workpiece to be measured according to the pixel distance between the segmentation points and the projection points.

In the first aspect of the present application, as an optional implementation manner, the determining the size of the workpiece to be measured according to the minimum bounding rectangle includes:

detecting the minimum circumscribed rectangle according to an RANSAC algorithm and obtaining four edges of the minimum circumscribed rectangle;

carrying out segmented projection on each group of opposite sides in the four sides of the minimum external rectangle to obtain projection points of segmented points on the opposite sides of one side;

calculating an average value of at least two of the pixel distances when there are at least two of the pixel distances from more than two of the segmentation points;

and determining the length and the width of the workpiece to be measured according to the average value of the at least two pixel distances.

In this optional embodiment, when there is at least two pixel distances obtained from more than two segmentation points, by calculating an average value of the at least two pixel distances, the length and width of the workpiece to be measured can be determined according to the average value of the at least two pixel distances, thereby reducing measurement errors.

In the first aspect of the present application, as an optional implementation manner, the preprocessing the image of the workpiece to be measured to extract a foreground image of the workpiece from the image of the workpiece to be measured includes:

determining image characteristics of the workpiece to be measured;

extracting a foreground image of the workpiece according to the image characteristics of the workpiece to be measured;

extracting the circular arc from the image of the workpiece to be measured.

In this alternative embodiment, since the workpiece to be measured has a rectangular shape, the rectangular shape can be used as the image feature of the workpiece to be measured.

In the first aspect of the present application, as an optional implementation manner, the extracting the circular arc from the image of the workpiece to be measured includes:

searching a connected domain in the image of the workpiece to be measured;

and extracting the circular arc according to the connected domain.

In this optional embodiment, by finding the connected domain in the image of the workpiece to be measured, the arc can be extracted according to the connected domain.

In the first aspect of the present application, as an optional implementation manner, the calibrated imaging device is the imaging device calibrated by a scanning polynomial calibration method.

A second aspect of the present application provides a rectangular workpiece dimension measuring apparatus, the apparatus comprising:

the acquisition module is used for acquiring an image of a workpiece to be measured, and the image of the workpiece to be measured is acquired and generated by the calibrated imaging device;

the image preprocessing module is used for preprocessing the image of the workpiece to be measured so as to extract a foreground image and an arc of the workpiece from the image of the workpiece to be measured;

the first calculation module is used for obtaining a minimum circumscribed rectangle according to the workpiece foreground image;

the second calculation module is used for determining the size of the workpiece to be measured according to the minimum circumscribed rectangle;

and the third calculation module is used for determining the curvature radius of the chamfer of the workpiece to be measured according to the circular arc.

The device of this application can acquire the image of the volume of awaiting measuring work piece that imaging device shot, and then can obtain minimum external rectangle according to work piece prospect image, and then can confirm the size of the volume of awaiting measuring work piece according to minimum external rectangle, and then can confirm the radius of curvature of the chamfer of the volume of awaiting measuring work piece according to the circular arc, so realize measuring the length and width and the chamfer camber of the volume of awaiting measuring work piece based on machine vision.

In the second aspect of the present application, as an optional implementation manner, the second computing module includes:

the first calculation submodule is used for detecting the minimum circumscribed rectangle according to the RANSAC algorithm and obtaining four edges of the minimum circumscribed rectangle;

the projection module is used for carrying out segmented projection on each group of opposite sides in the four sides of the minimum external rectangle so as to obtain projection points of segmented points on the opposite sides of one side;

and the second calculation submodule is used for determining the length and the width of the workpiece to be measured according to the pixel distance between the segmentation point and the projection point.

In this optional embodiment, the RANSAC algorithm may be used to detect the minimum circumscribed rectangle and obtain four sides of the minimum circumscribed rectangle, and then perform segmented projection on each set of opposite sides of the four sides of the minimum circumscribed rectangle to obtain projection points of the segmentation points on the opposite sides of one side, so as to determine the length and width of the workpiece to be measured according to the pixel distance between the segmentation points and the projection points.

A third aspect of the present application discloses a rectangular workpiece dimension measuring apparatus, the apparatus comprising:

a processor; and

a memory configured to store machine readable instructions which, when executed by the processor, perform the rectangular workpiece dimension measuring method of the first aspect of the present application.

The equipment can acquire the image of the workpiece to be measured shot by the imaging device, and then can obtain the minimum external rectangle according to the workpiece foreground image, and then can determine the size of the workpiece to be measured according to the minimum external rectangle, and further can determine the curvature radius of the chamfer of the workpiece to be measured according to the circular arc, so that the length, the width and the chamfer curvature of the workpiece to be measured are measured based on machine vision.

A fourth aspect of the present application discloses a storage medium storing a computer program for executing the rectangular workpiece dimension measuring method of the first aspect of the present application by a processor.

The storage medium of this application can acquire the image of the volume of awaiting measuring work piece that imaging device shot, and then can obtain minimum external rectangle according to work piece prospect image, and then can confirm the size of the volume of awaiting measuring work piece according to minimum external rectangle, and then can confirm the radius of curvature of the chamfer of the volume of awaiting measuring work piece according to the circular arc, so realize measuring the length and width and the chamfer camber of the volume of awaiting measuring work piece based on machine vision.

Drawings

In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and that those skilled in the art can also obtain other related drawings based on the drawings without inventive efforts.

FIG. 1 is a schematic flow chart of a method for measuring dimensions of a rectangular workpiece according to an embodiment of the present disclosure;

FIG. 2 is a schematic diagram of a segmented projection disclosed in an embodiment of the present application;

FIG. 3 is a schematic structural diagram of a rectangular workpiece dimension measuring device disclosed in an embodiment of the present application;

fig. 4 is a schematic structural diagram of a rectangular workpiece dimension measuring apparatus disclosed in an embodiment of the present application.

Detailed Description

The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.

Example one

Referring to fig. 1, fig. 1 is a schematic flow chart illustrating a method for measuring dimensions of a rectangular workpiece according to an embodiment of the present disclosure. As shown in fig. 1, the rectangular workpiece dimension measuring method of the embodiment of the present application includes the steps of:

101. acquiring an image of a workpiece to be measured, wherein the image of the workpiece to be measured is acquired and generated by a calibrated imaging device;

102. preprocessing an image of a workpiece to be measured to extract a foreground image and a circular arc of the workpiece from the image of the workpiece to be measured;

103. obtaining a minimum circumscribed rectangle according to the foreground image of the workpiece;

104. determining the size of the workpiece to be measured according to the minimum circumscribed rectangle;

105. and determining the curvature radius of the chamfer of the workpiece to be measured according to the circular arc.

In the embodiment of the application, the workpiece to be measured is rectangular, wherein the rectangular workpiece to be measured has two groups of opposite sides, so that the length and the width of the workpiece to be measured can be calculated in a manner of projection segmentation of the opposite sides. For a detailed description of the opposite-side projection method, please refer to the following detailed description.

It should be noted that the workpiece to be measured according to the embodiment of the present application is a rectangular workpiece having a chamfer.

In the embodiment of the application, the image of the workpiece to be measured is generated by the imaging device by shooting in the following way:

fixing the imaging device, and enabling the imaging device, the backlight source and the workpiece to be measured to be in the same straight line;

and starting the imaging device, so that the imaging device shoots the workpiece to be measured and generates an image of the workpiece to be measured.

In the embodiment of the present application, the imaging device is calibrated using a calibration plate, wherein the calibration plate is preferably a calibration plate with 1/3 area occupying the field of view of the imaging device. Further, the calibration plate is preferably a 7 x 7 array dot calibration plate.

In the embodiment of the application, the imaging device is an industrial camera carrying a telecentric lens, wherein the magnification of the image of the workpiece to be measured, which can be obtained by the telecentric lens within a certain object distance range, is not changed.

The image of the work piece of measurationing that imaging device shot can be obtained to this application embodiment, and then can obtain minimum external rectangle according to work piece prospect image, and then can confirm the size of the work piece of measurationing according to minimum external rectangle, and then can confirm the radius of curvature of the chamfer of the work piece of measurationing according to the circular arc, so realize measuring the length and width and the chamfer camber of the work piece of measurationing based on machine vision.

For example, assuming that the workpiece to be measured is a rectangular iron plate with a chamfer, the iron plate may be photographed by an imaging device, and an image of the iron plate may be processed by an image processing method based on machine vision, so as to identify the length and width of the iron plate and the curvature of the chamfer, i.e., steps 102, 103, 104, 105.

In the embodiment of the present application, as an optional implementation manner, step 104: determining the size of the workpiece to be measured according to the minimum bounding rectangle, comprising the substeps of:

detecting the minimum circumscribed rectangle according to the RANSAC algorithm and obtaining four edges of the minimum circumscribed rectangle;

carrying out segmented projection on each group of opposite sides in the four sides of the minimum external rectangle to obtain projection points of segmented points on the opposite sides of one side;

and determining the length and the width of the workpiece to be measured according to the pixel distance between the segmentation point and the projection point.

In this optional embodiment, the RANSAC algorithm may be used to detect the minimum circumscribed rectangle and obtain four sides of the minimum circumscribed rectangle, and then perform segmented projection on each set of opposite sides of the four sides of the minimum circumscribed rectangle to obtain projection points of the segmentation points on the opposite sides of one side, so as to determine the length and width of the workpiece to be measured according to the pixel distance between the segmentation points and the projection points.

In this alternative embodiment, the RANSAC algorithm can be an iterative algorithm for correctly estimating the mathematical model parameters from a set of data containing "outliers" (outliers), which generally refer to noise in the data, such as mismatching in the matching and outliers in the estimation curve. Therefore, compared with the prior art, the RANSAC algorithm adopted by the alternative embodiment has the advantage of being more resistant to noise, and further, the linear edge of the workpiece to be measured can be detected more accurately. In the prior art, the least square method is adopted to detect the straight line edge of the image of the workpiece to be measured, wherein the least square method is sensitive to abnormal points in the image, and the fitting process of the straight line is greatly influenced by the abnormal points, so that the detection precision of the straight line edge of the image of the workpiece to be measured is low.

It should be noted that, for a specific implementation process of the RANSAC algorithm, please refer to the description of the prior art, and details thereof are not described in the embodiments of the present application.

In the embodiment of the present application, as an optional implementation manner, determining the size of the workpiece to be measured according to the minimum bounding rectangle includes:

detecting the minimum circumscribed rectangle according to the RANSAC algorithm and obtaining four edges of the minimum circumscribed rectangle;

carrying out segmented projection on each group of opposite sides in the four sides of the minimum external rectangle to obtain projection points of segmented points on the opposite sides of one side;

calculating an average value of at least two pixel distances when there is at least two pixel distances obtained from more than two segmentation points;

the length and width of the workpiece to be measured are determined from the average of the at least two pixel distances.

In this alternative embodiment, one origin of one edge and the projection point of the opposite edge form one pixel distance, where the pixel distance is calculated based on a pixel coordinate system of the imaging device.

Referring to fig. 2, fig. 2 is a schematic diagram of a segmented projection according to an embodiment of the present disclosure. As shown in fig. 2, it is assumed that A, B two minimum rectangles of the workpiece to be measured are opposite to each other, where the a side is divided into a plurality of segments and forms a plurality of segment points, and at this time, based on the segment points on the a side, a plurality of projection points can be formed by one-to-one projection on the B side, and the segment points on the a side and the projection points on the B side form a pixel distance, for example, as shown in fig. 2, the segment points on the a side and the projection points on the B side form three pixel distances of d1, d2, and d3, and further, the average of d1, d2, and d3 can be used as a target pixel distance, and further, the width of the workpiece to be measured can be determined according to the target.

In the present alternative embodiment, after the average values of d1, d2, d3 are determined, the width of the workpiece to be measured can be determined using the imaging principle of the imaging device, the parameters of the imaging device, and the average values of d1, d2, d 3.

In this alternative embodiment, please refer to another pair of paired edges of the rectangle in fig. 2 for determining the length of the workpiece to be measured, which is not described herein again.

In the embodiment of the present application, as an optional implementation manner, step 102: preprocessing an image of a workpiece to be measured to extract a workpiece foreground image from the image of the workpiece to be measured, comprising the substeps of:

determining the image characteristics of a workpiece to be measured;

extracting a foreground image of the workpiece according to the image characteristics of the workpiece to be measured;

an arc is extracted from an image of a workpiece to be measured.

In this alternative embodiment, since the workpiece to be measured has a rectangular shape, the rectangular shape can be used as the image feature of the workpiece to be measured.

Note that a foreground and a background are included in one image, where the foreground is an image of an object close to the imaging device. In the embodiments of the present application, since the workpiece to be measured is generally located close to the imaging device, the foreground in the imaging device is the imaging of the workpiece to be measured.

In the embodiment of the present application, as an optional implementation manner, the steps of: extracting a circular arc from an image of a workpiece to be measured, comprising:

searching a connected domain in an image of a workpiece to be measured;

and extracting the circular arc according to the connected domain.

In this optional embodiment, by finding the connected domain in the image of the workpiece to be measured, the arc can be extracted according to the connected domain.

In the embodiment of the present application, as an optional implementation manner, the calibrated imaging device is an imaging device calibrated by a scanning polynomial calibration method.

In this alternative embodiment, the use of a scanning polynomial calibration method to calibrate the imaging device may further improve the recognition accuracy of the growing device.

Example two

Referring to fig. 3, fig. 3 is a schematic structural diagram of a rectangular workpiece dimension measuring apparatus according to an embodiment of the present disclosure. As shown in fig. 3, the apparatus of the embodiment of the present application includes:

the acquisition module 201 is used for acquiring an image of a workpiece to be measured, and the image of the workpiece to be measured is acquired and generated by a calibrated imaging device;

the image preprocessing module 202 is used for preprocessing the image of the workpiece to be measured so as to extract a foreground image and an arc of the workpiece from the image of the workpiece to be measured;

the first calculation module 203 is used for obtaining a minimum circumscribed rectangle according to the workpiece foreground image;

the second calculation module 204 is used for determining the size of the workpiece to be measured according to the minimum circumscribed rectangle;

and the third calculation module 205 is used for determining the curvature radius of the chamfer of the workpiece to be measured according to the circular arc.

In the embodiment of the application, the workpiece to be measured is rectangular, wherein the rectangular workpiece to be measured has two groups of opposite sides, so that the length and the width of the workpiece to be measured can be calculated in a manner of projection segmentation of the opposite sides. For a detailed description of the opposite-side projection method, please refer to the following detailed description.

It should be noted that the workpiece to be measured according to the embodiment of the present application is a rectangular workpiece having a chamfer.

In the embodiment of the present application, the image of the workpiece to be measured is generated by the imaging device by photographing in the following manner:

fixing the imaging device, and enabling the imaging device, the backlight source and the workpiece to be measured to be in the same straight line;

and starting the imaging device, so that the imaging device shoots the workpiece to be measured and generates an image of the workpiece to be measured.

In the embodiment of the present application, the imaging device is calibrated using a calibration plate, wherein the calibration plate is preferably a calibration plate with 1/3 area occupying the field of view of the imaging device. Further, the calibration plate is preferably a 7 x 7 array dot calibration plate.

In the embodiment of the application, the imaging device is an industrial camera carrying a telecentric lens, wherein the magnification of the image of the workpiece to be measured, which can be obtained by the telecentric lens within a certain object distance range, is not changed.

The image of the work piece of measurationing that imaging device shot can be obtained to this application embodiment, and then can obtain minimum external rectangle according to work piece prospect image, and then can confirm the size of the work piece of measurationing according to minimum external rectangle, and then can confirm the radius of curvature of the chamfer of the work piece of measurationing according to the circular arc, so realize measuring the length and width and the chamfer camber of the work piece of measurationing based on machine vision.

For example, assuming that the workpiece to be measured is a rectangular iron plate with a chamfer, at this time, the iron plate may be photographed by an imaging device, and an image of the iron plate is processed by an image processing method based on machine vision, thereby recognizing the length and width of the iron plate and the curvature of the chamfer.

In the embodiment of the present application, the second calculation module 204 block includes:

the first calculation submodule is used for detecting the minimum external rectangle according to the RANSAC algorithm and obtaining four edges of the minimum external rectangle;

the projection module is used for carrying out segmented projection on each group of opposite sides in the four sides of the minimum external rectangle so as to obtain projection points of segmented points on the opposite sides of one side;

and the second calculation submodule is used for determining the length and the width of the workpiece to be measured according to the pixel distance between the segmentation point and the projection point.

In this optional embodiment, the RANSAC algorithm may be used to detect the minimum circumscribed rectangle and obtain four sides of the minimum circumscribed rectangle, and then perform segmented projection on each set of opposite sides of the four sides of the minimum circumscribed rectangle to obtain projection points of the segmentation points on the opposite sides of one side, so as to determine the length and width of the workpiece to be measured according to the pixel distance between the segmentation points and the projection points.

In this alternative embodiment, the RANSAC algorithm can be an iterative algorithm for correctly estimating the mathematical model parameters from a set of data containing "outliers" (outliers), which generally refer to noise in the data, such as mismatching in the matching and outliers in the estimation curve. Therefore, compared with the prior art, the RANSAC algorithm adopted by the alternative embodiment has the advantage of being more resistant to noise, and further, the linear edge of the workpiece to be measured can be detected more accurately. In the prior art, the least square method is adopted to detect the straight line edge of the image of the workpiece to be measured, wherein the least square method is sensitive to abnormal points in the image, and the fitting process of the straight line is greatly influenced by the abnormal points, so that the detection precision of the straight line edge of the image of the workpiece to be measured is low.

It should be noted that, for a specific implementation process of the RANSAC algorithm, please refer to the description of the prior art, and details thereof are not described in the embodiments of the present application.

In the embodiment of the present application, as an optional implementation manner, the specific manner for the second calculation module 204 to determine the size of the workpiece to be measured according to the minimum bounding rectangle is as follows:

detecting the minimum circumscribed rectangle according to the RANSAC algorithm and obtaining four edges of the minimum circumscribed rectangle;

carrying out segmented projection on each group of opposite sides in the four sides of the minimum external rectangle to obtain projection points of segmented points on the opposite sides of one side;

calculating an average value of at least two pixel distances when there is at least two pixel distances obtained from more than two segmentation points;

the length and width of the workpiece to be measured are determined from the average of the at least two pixel distances.

In this alternative embodiment, one origin of one edge and the projection point of the opposite edge form one pixel distance, where the pixel distance is calculated based on a pixel coordinate system of the imaging device.

Referring to fig. 2, fig. 2 is a schematic diagram of a segmented projection according to an embodiment of the present disclosure. As shown in fig. 2, it is assumed that A, B two minimum rectangles of the workpiece to be measured are opposite to each other, where the a side is divided into a plurality of segments and forms a plurality of segment points, and at this time, based on the segment points on the a side, a plurality of projection points can be formed by one-to-one projection on the B side, and the segment points on the a side and the projection points on the B side form a pixel distance, for example, as shown in fig. 2, the segment points on the a side and the projection points on the B side form three pixel distances of d1, d2, and d3, and further, the average of d1, d2, and d3 can be used as a target pixel distance, and further, the width of the workpiece to be measured can be determined according to the target.

In the present alternative embodiment, after the average values of d1, d2, d3 are determined, the width of the workpiece to be measured can be determined using the imaging principle of the imaging device, the parameters of the imaging device, and the average values of d1, d2, d 3.

In this alternative embodiment, please refer to another pair of paired edges of the rectangle in fig. 2 for determining the length of the workpiece to be measured, which is not described herein again.

In this embodiment of the present application, as an optional implementation manner, the image preprocessing module 202 performs preprocessing on the image of the workpiece to be measured, and a specific manner of extracting the foreground image of the workpiece from the image of the workpiece to be measured is as follows:

determining the image characteristics of a workpiece to be measured;

extracting a foreground image of the workpiece according to the image characteristics of the workpiece to be measured;

an arc is extracted from an image of a workpiece to be measured.

In this alternative embodiment, since the workpiece to be measured has a rectangular shape, the rectangular shape can be used as the image feature of the workpiece to be measured.

Note that a foreground and a background are included in one image, where the foreground is an image of an object close to the imaging device. In the embodiments of the present application, since the workpiece to be measured is generally located close to the imaging device, the foreground in the imaging device is the imaging of the workpiece to be measured.

In the embodiment of the present application, as an optional implementation manner, the specific manner in which the image preprocessing module 202 performs the arc extraction from the image of the workpiece to be measured is as follows:

searching a connected domain in an image of a workpiece to be measured;

and extracting the circular arc according to the connected domain.

In this optional embodiment, by finding the connected domain in the image of the workpiece to be measured, the arc can be extracted according to the connected domain.

In the embodiment of the present application, as an optional implementation manner, the calibrated imaging device is an imaging device calibrated by a scanning polynomial calibration method.

In this alternative embodiment, the use of a scanning polynomial calibration method to calibrate the imaging device may further improve the recognition accuracy of the growing device.

EXAMPLE III

Referring to fig. 4, fig. 4 is a schematic structural diagram of a rectangular workpiece dimension measuring apparatus according to an embodiment of the present disclosure. As shown in fig. 4, the apparatus includes:

a processor 301; and

the memory 302 is configured to store machine readable instructions, which when executed by the processor, perform a rectangular workpiece dimension measuring method according to an embodiment of the present application.

The image of the work piece of measurationing that imaging device shot can be obtained to this application embodiment, and then can obtain minimum external rectangle according to work piece prospect image, and then can confirm the size of the work piece of measurationing according to minimum external rectangle, and then can confirm the radius of curvature of the chamfer of the work piece of measurationing according to the circular arc, so realize measuring the length and width and the chamfer camber of the work piece of measurationing based on machine vision.

Example four

The embodiment of the application discloses a storage medium, wherein a computer program is stored in the storage medium, and the computer program is executed by a processor to execute the rectangular workpiece dimension measuring method in the first embodiment of the application.

The image of the work piece of measurationing that imaging device shot can be obtained to this application embodiment, and then can obtain minimum external rectangle according to work piece prospect image, and then can confirm the size of the work piece of measurationing according to minimum external rectangle, and then can confirm the radius of curvature of the chamfer of the work piece of measurationing according to the circular arc, so realize measuring the length and width and the chamfer camber of the work piece of measurationing based on machine vision.

In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.

In addition, units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.

Furthermore, the functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

It should be noted that the functions, if implemented in the form of software functional modules and sold or used as independent products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.

In this document, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions.

The above description is only an example of the present application and is not intended to limit the scope of the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.

15页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种图像测距方法、装置、设备和存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!